Skip to main content

State

Struct State 

Source
pub struct State {
Show 21 fields pub path: Option<PathBuf>, pub version: u32, pub times: Vec<BestTimes>, pub players: Vec<PlayerEntry>, pub player_a_name: String, pub player_b_name: String, pub player_a_keys: PlayerKeys, pub player_b_keys: PlayerKeys, pub sound_enabled: bool, pub sound_optimization: SoundOptimization, pub play_mode: PlayMode, pub flagtag: bool, pub swap_bikes: bool, pub video_detail: VideoDetail, pub animated_objects: bool, pub animated_menus: bool, pub inc_screen_size_key: u32, pub dec_screen_size_key: u32, pub screenshot_key: u32, pub last_edited_lev_name: String, pub last_played_external: String,
}
Expand description

State.dat struct

Fields§

§path: Option<PathBuf>

Path to State file.

§version: u32

State file version; the only supported value is 200.

§times: Vec<BestTimes>

Best times lists. state.dat has a fixed-size array of 90 of these.

§players: Vec<PlayerEntry>

List of players. state.dat has a fixed-size array of 50 of these.

§player_a_name: String

Name of player A, maximum 14 characters.

§player_b_name: String

Name of player B, maximum 14 characters.

§player_a_keys: PlayerKeys

Keys for player A.

§player_b_keys: PlayerKeys

Keys for player B.

§sound_enabled: bool

Whether sound is enabled.

§sound_optimization: SoundOptimization

Sound optimization.

§play_mode: PlayMode

Play mode.

§flagtag: bool

Whether flag tag mode is enabled.

§swap_bikes: bool

Whether bikes are swapped.

§video_detail: VideoDetail

Video detail.

§animated_objects: bool

Whether objects are animated.

§animated_menus: bool

Whether menus are animated.

§inc_screen_size_key: u32

Key for increasing screen size.

§dec_screen_size_key: u32

Key for decreasing screen size.

§screenshot_key: u32

Key for taking a screenshot.

§last_edited_lev_name: String

Name of last edited level.

§last_played_external: String

Name of last played external level.

Implementations§

Source§

impl State

Source

pub fn new() -> Self

Create a new state.dat.

Source

pub fn load<P: Into<PathBuf>>(path: P) -> Result<Self, ElmaError>

Load a state.dat file.

§Examples
let state = State::load("state.dat").unwrap();
Source

pub fn from_bytes<B: AsRef<[u8]>>(buffer: B) -> Result<Self, ElmaError>

Load a state.dat file from bytes.

§Examples
let state = State::from_bytes(&[0,1,2]).unwrap();
Source

pub fn to_bytes(&self) -> Result<Vec<u8>, ElmaError>

Returns state.dat as a stream of bytes.

§Examples
let mut state = State::load("state.dat").unwrap();
let buffer = state.to_bytes().unwrap();
Source

pub fn save<P: Into<PathBuf>>(&mut self, path: P) -> Result<(), ElmaError>

Save state.dat

§Examples
let mut state = State::load("state.dat").unwrap();
state.save("newstate.dat").unwrap();

Trait Implementations§

Source§

impl Clone for State

Source§

fn clone(&self) -> State

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for State

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for State

Source§

fn default() -> State

Returns the “default value” for a type. Read more
Source§

impl PartialEq for State

Source§

fn eq(&self, other: &State) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for State

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnsafeUnpin for State

§

impl UnwindSafe for State

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V