pub struct HostState {
pub fb: Framebuffer,
pub input: InputState,
pub sprites: SpriteSheet,
pub map: MapData,
pub audio: AudioHandle,
pub storage: Storage,
pub logs: Vec<String>,
pub panic_message: Option<String>,
pub frame: u64,
pub fps: u32,
/* private fields */
}Expand description
Everything the host exposes to a running cart.
Fields§
§fb: Framebuffer§input: InputState§sprites: SpriteSheet§map: MapData§audio: AudioHandle§storage: StorageThe cart’s persistent key-value store (the save file). The frontend
decides the backing: a cache-dir JSON file on the desktop console and
player, in-memory in the browser and headless verify.
logs: Vec<String>Messages from the cart’s log calls, drained by the console.
panic_message: Option<String>Message from the cart’s panic hook, captured just before the trap.
frame: u64§fps: u32The cart’s logical frames per second (30 or 60), from its pixel8_fps
export. Drives time() and the host’s update/draw cadence.
Implementations§
Source§impl HostState
impl HostState
Sourcepub fn set_measured_fps(&mut self, fps: f32)
pub fn set_measured_fps(&mut self, fps: f32)
Feed the host frontend’s measured frame rate, surfaced to carts via fps.
Sourcepub fn measured_fps_or_target(&self) -> f32
pub fn measured_fps_or_target(&self) -> f32
The measured frame rate, or the cart’s target rate until a frontend
measures one. Keeps fps() sane on frontends that never measure.
Auto Trait Implementations§
impl Freeze for HostState
impl RefUnwindSafe for HostState
impl Send for HostState
impl Sync for HostState
impl Unpin for HostState
impl UnsafeUnpin for HostState
impl UnwindSafe for HostState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more