Skip to main content

Module platform

Module platform 

Source
Expand description

Platform abstraction layer.

Two impls are kept in lockstep: native (filesystem + std::fs locking) and web (localStorage + no-op locking, added when the wasm port lands). Both expose the same set of types and methods — code outside this module doesn’t know which one it’s compiled against. Drift is caught at compile time because both impls have to satisfy the same callers.

See tracking issue #13 for the discovery rationale and gotchas.

Structs§

Capabilities
Static feature-flag struct describing what the host environment supports. Each platform impl exposes a CAPABILITIES constant of this type. UI / input code reads it to gate affordances that have no meaning on a given platform — e.g. the [q] quit help-bar hint is hidden in the browser, where the wasm bundle has no authority to close the tab.
InstanceLock
Holds an exclusive OS-level lock on the save directory for the lifetime of the process. std::fs::File::try_lock is stdlib (since Rust 1.89): flock on Unix, LockFileEx on Windows.
Persistence
Filesystem-backed persistence. Stateless — the save path is derived from environment variables on every call.

Constants§

CAPABILITIES
Native is the canonical surface — every game-side affordance maps to something the OS can actually do.