pub struct History<R: TurnRules> { /* private fields */ }Expand description
A game’s first state and the commands applied since, oldest first.
Implementations§
Source§impl<R: TurnRules> History<R>
impl<R: TurnRules> History<R>
Sourcepub fn from_parts(initial: R, commands: Vec<R::Command>) -> Self
pub fn from_parts(initial: R, commands: Vec<R::Command>) -> Self
A history from its first state and the commands applied since, oldest first (as a save holds them).
Sourcepub fn into_parts(self) -> (R, Vec<R::Command>)
pub fn into_parts(self) -> (R, Vec<R::Command>)
Its first state and its commands, oldest first.
Sourcepub fn initial_mut(&mut self) -> &mut R
pub fn initial_mut(&mut self) -> &mut R
The state the game started in, to change: for putting back what a save leaves out of it. A change to how its commands apply changes every later point.
Source§impl<R: TurnRules + Clone> History<R>
impl<R: TurnRules + Clone> History<R>
Sourcepub fn state_at(&self, n: usize) -> R
pub fn state_at(&self, n: usize) -> R
The game after its first n commands (all of them if n is past
the end).
Sourcepub fn replay(&self) -> Vec<Replayed<R>>
pub fn replay(&self) -> Vec<Replayed<R>>
Every command replayed in order, with the game just before it and its events: one replay for the whole list.
Sourcepub fn rewind_to(&mut self, n: usize) -> Result<R, NoSuchPoint>
pub fn rewind_to(&mut self, n: usize) -> Result<R, NoSuchPoint>
Goes back to point n (before command n), forgetting that command
and every later one, and returns the game at that point.
Trait Implementations§
Source§impl<'de, R> Deserialize<'de> for History<R>
impl<'de, R> Deserialize<'de> for History<R>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<R: Eq + TurnRules> Eq for History<R>
impl<R: PartialEq + TurnRules> StructuralPartialEq for History<R>
Auto Trait Implementations§
impl<R> Freeze for History<R>where
R: Freeze,
impl<R> RefUnwindSafe for History<R>
impl<R> Send for History<R>
impl<R> Sync for History<R>
impl<R> Unpin for History<R>
impl<R> UnsafeUnpin for History<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for History<R>
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