Skip to main content

HostState

Struct HostState 

Source
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: Storage

The 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: u32

The 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

Source

pub fn set_measured_fps(&mut self, fps: f32)

Feed the host frontend’s measured frame rate, surfaced to carts via fps.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.