Module status

Source
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§

StatusBridge
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.
StatusFacts
Complete current facts, not a patch. None passed to publish means unavailable; Some with 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.
StatusItem
Borrowed game-authored fact. Action labels may include current remapping hints.
StatusUpdate
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§

StatusError
Reported errors leave the last-good bridge/browser publication unchanged.
StatusKind
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.