Skip to main content

Setup

Struct Setup 

Source
#[non_exhaustive]
pub struct Setup { pub display: DisplayInfo, pub storage: Box<dyn Storage>, pub seed: u64, pub voice_manifest: Option<String>, pub platform: PlatformFacts, pub key_prompt: KeyPrompt, pub last_crash: Option<LastCrash>, }
Expand description

What the platform gives a game as it loads: what goes into its context (ctx). A backend with more to give (the voice manifest it read) adds it with Start::before_load.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§display: DisplayInfo

The display, for a game that picks its console to fit it.

§storage: Box<dyn Storage>

Where the game’s saves and settings persist (Platform::storage).

§seed: u64

A seed from the clock, different each launch: the music’s random picks, and a game’s own luck where it wants that.

§voice_manifest: Option<String>

The text of the voice manifest the backend read, if it found one.

§platform: PlatformFacts

Where the game runs: the target’s id, whether the game may quit, whether its window goes full screen, and the keyboard, pointer and touch screen the device has (Platform::facts).

§key_prompt: KeyPrompt

Whether the game waits for a first key press (browsers block sound until one): KeyPrompt::Waiting unless the backend says not.

§last_crash: Option<LastCrash>

The last crash, if the game hasn’t heard of it: the newest report in storage newer than the last one offered (crash::offer_last_crash), so each is offered once. What the player sees of it, if anything, is the game’s to word.

Implementations§

Source§

impl Setup

Source

pub fn ctx<G: GameData>(self, ctx: Ctx<G>) -> Ctx<G>

ctx on this platform: its saves and settings in the platform’s storage, the voices the voice manifest allows, idle motion on, the platform’s facts and the key prompt the backend says, and the music seeded from the clock so each launch picks differently.

Trait Implementations§

Source§

impl Debug for Setup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Setup

§

impl !Send for Setup

§

impl !Sync for Setup

§

impl !UnwindSafe for Setup

§

impl Freeze for Setup

§

impl Unpin for Setup

§

impl UnsafeUnpin for Setup

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.