misc/buildinfo
빌드 정보. (원본 misc/buildinfo.js)
- 배포 빌드가 적어 둔 판을 앱이 켜질 때 한 번 읽는다. 읽는 차례: 1. 문서 머리의 <meta name="build-version" content="..."> 의 content. (있으면 그 글 그대로, platform/document.rs 의 Document::get_meta_content) 웹은 원본처럼 페이지의 meta 다. 데스크탑은 엔진이 든 문서의 meta 이고, 배포 빌드가 EngineConfiguration.document_meta_list 에 넣는다. (웹 판 index.html 의 meta 자리, build.rs 의 rustc-env 를 env! 로 읽어 넣는 것 같은 것) 2. 없으면 version.json. { version, date, time, hash, ... } 꼴이고, 글은 "날짜 시각 (해시)" 이다. 해시가 없으면 version. 웹은 페이지 기준 주소를 캐시 없이(fetch 의 cache: "no-cache") 받는다. 새 판을 올려도 옛 판 표시가 남지 않게 한다. 데스크탑은 애셋 폴더에서 읽는다. (그 자리에서 끝난다, 파일이라 옛 판이 남는 캐시가 없다) 받지 못하면(파일 없음, HTTP 오류, 네트워크 오류) 원본 load 가 오류를 삼키는 것처럼 조용히 넘어간다. 손잡이는 빈 바이트로 끝나 실패로 치지 않으니 AssetLoader 에 넣어도 실패 목록에 들지 않는다. 3. 둘 다 없으면 set_package_version 으로 넣은 판. (게임 크레이트가 env!("CARGO_PKG_VERSION") 을 넘긴다, 넣지 않았으면 원본처럼 빈 글)
- 원본과 다른 점: 원본 생성자의 version.json 주소 기본 인자는 new()(기본 주소)와 set_version_json_path 로 나눴다. 원본 await load() 는 받을 때까지 기다린다. 러스트 판도 load(engine) 가 await 할 수 있는 BuildInfoLoadHandle 을 돌려준다. (wait_for_load().await 도 같다) await 없이는 마쳤는지를 is_loaded() 로 보고, 씬은 get_load_handle() 을 track_load_handle 로 맡긴다.
Build info. (original misc/buildinfo.js)
- Reads the version written by the release build once when the app starts. Reading order: 1. The content of <meta name="build-version" content="..."> in the document head. (that text as is if present, Document::get_meta_content of platform/document.rs) On the web it is the page's meta, as in the original. On desktop it is the meta of the document held by the engine, which the release build puts in EngineConfiguration.document_meta_list. (the meta slot of the web version's index.html, something like reading build.rs's rustc-env with env! and putting it in) 2. Otherwise version.json. In the form { version, date, time, hash, ... }, and the text is "date time (hash)". version if there is no hash. On the web, fetches the page-relative address without the cache (fetch's cache: "no-cache"). So the old version display does not linger after uploading a new version. On desktop it reads from the asset folder. (finishes on the spot, and as a file it has no cache that keeps the old version) If it cannot be fetched (no file, HTTP error, network error), it quietly moves on, just as the original load swallows the error. The handle finishes with empty bytes and does not count as a failure, so it is not in the failed list even when added to an AssetLoader. 3. If neither, the version put in with set_package_version. (the game crate passes env!("CARGO_PKG_VERSION"), an empty string if not set, as in the original)
- Differences from the original: The default version.json address argument of the original constructor is split into new() (default address) and set_version_json_path. The original await load() waits until it is fetched. The Rust version's load(engine) also returns a BuildInfoLoadHandle that can be awaited. (wait_for_load().await is the same) Without await, check completion with is_loaded(), and scenes hand get_load_handle() over to track_load_handle.
BuildInfoLoadHandlestruct traits Clone, Debug, IntoFuture
빌드 정보 읽기 손잡이. (BuildInfo::load 가 돌려준다. 원본 load 의 Promise 자리, meta 로 읽었으면 바로 끝난다)
- 엔진 작업 안에서 그대로 await 한다. 읽기에 실패해도 끝난다.
Build info load handle. (returned by BuildInfo::load. In place of the original load's Promise, it finishes immediately if read from meta)
- Await it as is inside an engine task. It also finishes if reading fails.
use std::cell::RefCell;
use std::rc::Rc;
use vanilla::{BuildInfo, Engine, EngineConfiguration};
let mut engine_configuration = EngineConfiguration::new();
engine_configuration.document_meta_list = vec![(String::from("build-version"), String::from("1.2.3"))];
let engine = Engine::new(engine_configuration);
let version_text = Rc::new(RefCell::new(String::new()));
let version_text_for_task = version_text.clone();
let task_handle = engine.spawn_task(|mut engine_context| async move {
let mut build_info = BuildInfo::new();
let load_handle = engine_context.with(|engine| build_info.load(engine));
load_handle.await;
*version_text_for_task.borrow_mut() = build_info.read_text();
});
assert!(task_handle.is_finished());
assert_eq!(*version_text.borrow(), "1.2.3");BuildInfoLoadFuturestruct traits Clone, Debug, Future
빌드 정보 읽기를 기다리는 퓨처. (실패해도 마친 것이다)
- BuildInfo::wait_for_load 나 BuildInfoLoadHandle 의 into_future 로 얻는다. 아직이면 다음 프레임에 다시 본다.
Future that waits for the build info to load. (finished even if it fails)
- Obtained with BuildInfo::wait_for_load or BuildInfoLoadHandle's into_future. If not ready, checks again on the next frame.
use std::cell::RefCell;
use std::rc::Rc;
use vanilla::{BuildInfo, Engine, EngineConfiguration};
let mut engine_configuration = EngineConfiguration::new();
engine_configuration.document_meta_list = vec![(String::from("build-version"), String::from("2026-11-26 def5678"))];
let engine = Engine::new(engine_configuration);
let build_info = Rc::new(RefCell::new(BuildInfo::new()));
build_info.borrow_mut().load(&engine);
let build_info_for_task = build_info.clone();
let task_handle = engine.spawn_task(|_engine_context| async move {
let load_future = build_info_for_task.borrow().wait_for_load();
load_future.await;
assert!(build_info_for_task.borrow().is_loaded());
});
assert!(task_handle.is_finished());
assert_eq!(build_info.borrow_mut().read_text(), "2026-11-26 def5678");BuildInfostruct traits Default
빌드 정보.
- 켜질 때 load 를 한 번 부르고, 마친 뒤 read_text 로 판의 글을 읽는다. (meta, version.json, 빌드 때 넣은 판 차례)
Build info.
- Call load once at startup, and after it finishes read the version text with read_text. (in order: meta, version.json, the version set at build time)
use vanilla::{BuildInfo, Engine, EngineConfiguration};
let mut engine_configuration = EngineConfiguration::new();
engine_configuration.document_meta_list = vec![(String::from("build-version"), String::from(" 2026-11-26 def5678 "))];
let engine = Engine::new(engine_configuration);
let mut build_info = BuildInfo::new();
build_info.set_package_version(env!("CARGO_PKG_VERSION"));
assert!(!build_info.is_loaded());
build_info.load(&engine);
assert!(build_info.is_loaded());
assert!(build_info.get_load_handle().is_none());
assert_eq!(build_info.read_text(), "2026-11-26 def5678");생성. (version.json 주소는 기본 "version.json")
Constructor. (the version.json address defaults to "version.json")
반환ReturnsBuildInfo 아직 읽지 않은 새 빌드 정보. (meta 이름 "build-version", 빌드 때 넣은 판은 빈 글)New build info not read yet. (meta name "build-version", the build-time version is an empty string)
짝Counterpart: vanilla.js BuildInfo.constructor
version.json 값으로 판의 글 만들기. (정적, "날짜 시각 (해시)", 해시가 없으면 version, 그것도 없으면 빈 글)
Builds the version text from a version.json value. (Static, "date time (hash)", version if there is no hash, empty text if that is also missing)
- version_data&Value
- version.json 의 JSON 값. (글 칸만 읽고 앞뒤 빈칸을 뗀다)JSON value of version.json. (reads only string fields and trims them)
반환ReturnsString 판의 글. 날짜나 시각이 없으면 그 조각을 빼고 잇는다.Version text. If the date or time is missing, joins without that piece.
짝Counterpart: vanilla.js BuildInfo.composeText
use vanilla::BuildInfo;
let version_data = serde_json::json!({ "version": "1.2.3", "date": "2026-11-25", "time": "04:00", "hash": "abc1234" });
assert_eq!(BuildInfo::compose_text(&version_data), "2026-11-25 04:00 (abc1234)");
assert_eq!(BuildInfo::compose_text(&serde_json::json!({ "version": " 2.0.0 " })), "2.0.0");
assert_eq!(BuildInfo::compose_text(&serde_json::json!({ "hash": "def5678" })), "(def5678)");meta 이름 설정. (기본 "build-version")
Sets the meta name. (default "build-version")
- meta_name&str
- 판을 적은 meta 의 name.name of the meta that holds the version.
짝Counterpart: vanilla.js BuildInfo.setMetaName
빌드 판 파일 경로 설정. (기본 "version.json", 빈 글이면 파일을 받지 않는다)
Sets the build version file path. (default "version.json", an empty string means the file is not fetched)
- version_json_path&str
- version.json 경로. (웹은 페이지 기준 주소, 데스크탑은 애셋 폴더 기준)version.json path. (page-relative address on the web, relative to the asset folder on desktop)
짝Counterpart: vanilla.js BuildInfo.setVersionJsonPath
읽기 요청. (문서의 meta 를 바로 읽고, 없으면 웹은 version.json 을 캐시 없이 요청한다. 데스크탑은 애셋 폴더의 version.json 을 읽는다. await 할 수 있는 손잡이를 돌려준다)
- 다시 부르면 앞에서 읽은 것을 비우고 처음부터 읽는다.
Requests reading. (reads the document's meta immediately, and if absent, the web requests version.json without the cache. Desktop reads version.json from the asset folder. Returns a handle that can be awaited)
- Calling again clears what was read before and reads from the beginning.
- engine&Engine
- 애셋을 받을 엔진.Engine to load the asset with.
반환ReturnsBuildInfoLoadHandle 읽기를 기다리는 손잡이. meta 로 읽었거나 파일 경로가 빈 글이면 바로 끝난 손잡이.Handle that waits for reading. An already finished handle if read from meta or the file path is an empty string.
짝Counterpart: vanilla.js BuildInfo.load
use vanilla::{BuildInfo, Engine, EngineConfiguration};
let engine = Engine::new(EngineConfiguration::new());
let mut build_info = BuildInfo::new();
build_info.set_package_version("0.4.0");
build_info.set_version_json_path("missing-version.json");
build_info.load(&engine);
assert!(build_info.is_loaded());
assert!(build_info.read_version_data().is_none());
assert_eq!(build_info.read_text(), "0.4.0");읽기를 마쳤는지. (원본 isLoaded, load 전이면 거짓, 실패해도 마친 것)
Whether reading has finished. (original isLoaded, false before load, finished even if it fails)
반환Returnsbool load 를 불렀고 meta 로 읽었거나 version.json 받기가 끝났으면 true.true if load was called and it was read from meta or fetching version.json has finished.
짝Counterpart: vanilla.js BuildInfo.isLoaded
읽기를 마치기를 기다리는 퓨처. (원본 await load() 의 await 자리, load 를 부른 뒤 엔진 작업 안에서 await 한다. 실패해도 마친 것)
- meta 로 읽었으면 바로 끝난다. 손잡이를 나눠 들어 빌리지 않는다.
Future that waits for reading to finish. (in place of the await in the original await load(), await it inside an engine task after calling load. Finished even if it fails)
- Finishes immediately if read from meta. Shares the handle instead of borrowing.
반환ReturnsBuildInfoLoadFuture 지금 읽기를 기다리는 퓨처. load 전에 부르면 바로 끝난다.Future waiting for the current read. Finishes immediately if called before load.
version.json 읽기 손잡이. (씬이 track_load_handle 로 맡긴다. meta 로 읽었으면 None)
- 받지 못했어도 실패가 아니라 빈 바이트로 끝난다. (원본 load 의 try/catch 처럼, AssetLoader 의 실패 목록에 들지 않는다)
version.json load handle. (scenes hand it over with track_load_handle. None if read from meta)
- Finishes with empty bytes, not a failure, even if it could not be fetched. (like the try/catch of the original load, it is not in the AssetLoader failed list)
반환ReturnsOption<&AssetLoadHandle> version.json 받기 손잡이. load 전이거나 meta 로 읽었거나 파일 경로가 빈 글이면 None.version.json fetch handle. None before load, if read from meta, or if the file path is an empty string.
version.json 에서 읽은 값. (받기 전이거나 meta 로 읽었거나 풀 수 없으면 None)
- 처음 받은 뒤 한 번만 풀어 두고 같은 값을 돌려준다.
Value read from version.json. (None before fetching, if read from meta, or if unparsable)
- Parsed only once after the first fetch, and the same value is returned.
반환ReturnsOption<&Value> JSON 객체 값. 객체가 아니거나, 받지 못했거나, 아직이면 None.JSON object value. None if not an object, not fetched, or not ready yet.
짝Counterpart: vanilla.js BuildInfo.readVersionData
판의 글. (meta > version.json > 빌드 때 넣은 판)
Version text. (meta > version.json > build-time version)
반환ReturnsString meta 의 글(앞뒤 빈칸을 뗀 것), 없으면 compose_text 로 만든 version.json 의 글, 그것도 비면 빌드 때 넣은 판. (넣지 않았으면 빈 글)The meta text (trimmed), otherwise the version.json text built with compose_text, and if that is empty too, the build-time version. (an empty string if not set)
짝Counterpart: vanilla.js BuildInfo.readText
문서의 meta 에 적힌 판. (원본 readMetaText, 없으면 빈 글. 데스크탑은 엔진이 든 문서의 meta)
Version written in the document's meta. (original readMetaText, an empty string if none. On desktop, the meta of the document held by the engine)
반환ReturnsString meta 이름이 같은 meta 의 content 에서 앞뒤 빈칸을 뗀 글. 없으면 빈 글.The trimmed content of the meta with the same meta name. An empty string if none.
짝Counterpart: vanilla.js BuildInfo.readMetaText
빌드 때 넣은 판 설정. (meta 도 version.json 도 없을 때의 글, 보통 env!("CARGO_PKG_VERSION"))
Sets the build-time version. (the text when there is neither meta nor version.json, usually env!("CARGO_PKG_VERSION"))
- package_version&str
- 판의 글.The version text.
짝Counterpart: vanilla.js BuildInfo.setPackageVersion
빌드 때 넣은 판.
Build-time version.
반환Returns&str set_package_version 으로 넣은 글. (처음은 빈 글)Text put in with set_package_version. (initially an empty string)
짝Counterpart: vanilla.js BuildInfo.getPackageVersion