Expand description
Opt-in, read-only status. Games own facts, IDs, availability and accepted events.
IDs are unique across all supplied facts and mapped widgets, including omitted
items. Keep each ID attached to one meaning for one owner lifetime. owner is a
nonzero game-assigned provenance token, not an authentication credential. Use a
fresh token after replacing a game; do not reuse it while readers retain state.
A bridge belongs to its Rust owner; browser publication belongs to the calling
thread (single-threaded Wasm only). No scene discovery or input execution occurs.
Epoch starts at 1; serial starts at 0 and increments only on changed, valid publication. It compares retained semantics, including order and truncation counts, not omitted source text or simulation ticks. Reset advances epoch, clears publication and resets serial to 0. Neither counter wraps: exhaustion is an error retaining last-good data. Browser reconnect reads the current complete snapshot; it does not replay announcements. Strings containing u64 values are decimal strings, never JS numbers.
Runnable headless consumer (also see tests/journey400_296.rs):
use ferravex_core::session::{GameSession, SessionState};
use ferravex_render::status::*;
let session = GameSession::new(64., 4, false);
let lifecycle = match session.state() {
SessionState::Ready => "Ready", _ => "Started",
};
let items = [StatusItem { id: 1, kind: StatusKind::Lifecycle, label: lifecycle }];
let mut bridge = StatusBridge::new(42)?;
let facts = || StatusFacts { items: &items, ui: None, ui_actions: &[] };
assert!(bridge.publish(Some(facts()))?.changed);
assert!(!bridge.publish(Some(facts()))?.changed);
assert!(std::str::from_utf8(bridge.bytes()).unwrap().contains("Ready"));
bridge.publish_browser()?; // Explicit opt-in; host calls after its normal update.
assert!(clear_browser(42)?); // Host teardown, on the same thread.Structs§
- Status
Bridge - Fixed retained storage, no allocations during ordinary publication. See module example for complete usage. O(128² + 128×1025 + MAX_WIRE_BYTES) bounded work; labels are measured by byte length without scanning oversized source text.
- Status
Facts - Complete current facts, not a patch.
Nonepassed to publish means unavailable;Somewith empty slices means available and empty. Inspection is immutable and must be from the current finished composition. Host input blocking and semantic availability remain the game’s responsibility: omit blocked mappings yourself. - Status
Item - Borrowed game-authored fact. Action labels may include current remapping hints.
- Status
Update - Bounded publication outcome; truncation counts are for retained labels and omitted available items (including unavailable full UI labels), respectively.
- UiAction
- Explicit supported UI meaning; a button is not automatically a game action.
Enums§
- Status
Error - Reported errors leave the last-good bridge/browser publication unchanged.
- Status
Kind - Explicit semantic category. Only lifecycle and result text is live-announced.
Constants§
- MAX_
ITEMS - Retained/published item ceiling (declaration order, then explicit UI map order).
- MAX_
LABEL_ BYTES - Retained bytes per label. A whole UTF-8 prefix is retained with an explicit flag.
- MAX_
SOURCE_ BYTES - Total full source-label bytes, including labels omitted by item capacity.
- MAX_
SOURCE_ ITEMS - Hard source-entry/work ceiling; exceeding it rejects the entire snapshot.
- MAX_
WIRE_ BYTES - Maximum JSON bytes, including worst-case control-character escaping.
Functions§
- clear_
browser - Remove only this owner’s publication, freeing storage. Checked revision never wraps. No listeners, loops or action exports exist. See module cleanup recipe.
- ferravex_
status_ v1_ len - Initialized JSON byte length (no terminator), zero when absent/reset.
- ferravex_
status_ v1_ ptr - Borrowed initialized-prefix address, null when absent/reset. Valid only until the next same-thread publish/clear; reacquire current memory after growth.
- ferravex_
status_ v1_ revision - Thread-local nonwrapping u64 publication stamp (Wasm i64 / JavaScript BigInt). Wasm returns the signed two’s-complement BigInt view; compare that losslessly, or use BigInt.asUintN(64, value). Semantic JSON counters are decimal strings. Read before and after copying; stamp changes on copy/clear, not no-op copies.
- ferravex_
status_ v1_ version - Readonly ABI version, always 1; this does not imply a publisher exists.