Skip to main content

Start

Struct Start 

Source
#[non_exhaustive]
pub struct Start<G>
where G: GameData,
{ pub card: Card, pub load: Box<dyn FnOnce(Setup) -> Result<Game<G>, String>>, pub look: fn(&G) -> Look<'_>, pub on_system: Option<fn(&mut Game<G>, SystemEvent)>, pub made: Option<Made>, pub state_hash: Option<fn(&Game<G>) -> Option<StateHash>>, pub crash_record: Option<fn(&Game<G>) -> Option<String>>, }
Expand description

How a game starts: the card shown while it loads, the load, where its look is and its hook for the system’s events. Built with Start::new, its optional parts set by the methods named for them (ADR-0039).

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.
§card: Card

What the first frame shows.

§load: Box<dyn FnOnce(Setup) -> Result<Game<G>, String>>

Runs on the second frame, the card on the screen.

§look: fn(&G) -> Look<'_>

What the game’s frames are painted with.

§on_system: Option<fn(&mut Game<G>, SystemEvent)>

The game’s hook for the system’s events, if it has one.

§made: Option<Made>

The build’s stamp, copied into a session record.

§state_hash: Option<fn(&Game<G>) -> Option<StateHash>>

The game’s own state hash, in each frame’s hash.

§crash_record: Option<fn(&Game<G>) -> Option<String>>

The game’s record of its play, for a crash report.

Implementations§

Source§

impl<G> Start<G>
where G: GameData,

Source

pub fn new( card: Card, look: fn(&G) -> Look<'_>, load: impl FnOnce(Setup) -> Result<Game<G>, String> + 'static, ) -> Start<G>

A game that shows card, then loads with load, painted with what look finds in its data.

Source

pub fn on_system(self, hook: fn(&mut Game<G>, SystemEvent)) -> Start<G>

The same start with the game’s hook for the system’s events.

Source

pub fn made(self, made: Made) -> Start<G>

The same start with the build’s stamp, copied into a session record and checked when one is played (session::prepare).

Source

pub fn state_hash(self, hash: fn(&Game<G>) -> Option<StateHash>) -> Start<G>

The same start with the game’s own state hash, in each frame’s hash (App::frame_hash): so a playback that plays differently is found at the frame the game’s state moved, not only when a screen or a sound shows it.

Source

pub fn crash_record(self, hook: fn(&Game<G>) -> Option<String>) -> Start<G>

The same start with the game’s record of its play, which a backend that catches a panic adds to its crash report (App::crash_record). A record should not hold what the player typed (a name).

Source

pub fn before_load(self, before: impl FnOnce(&mut Setup) + 'static) -> Start<G>

The same start with before run on the setup ahead of the game’s load: a backend’s own part (the voice manifest it read).

Auto Trait Implementations§

§

impl<G> !RefUnwindSafe for Start<G>

§

impl<G> !Send for Start<G>

§

impl<G> !Sync for Start<G>

§

impl<G> !UnwindSafe for Start<G>

§

impl<G> Freeze for Start<G>

§

impl<G> Unpin for Start<G>

§

impl<G> UnsafeUnpin for Start<G>

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
§

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.

§

impl<S> FromSample<S> for S

§

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.

§

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

§

fn to_sample_(self) -> U

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.