State

Struct State 

Source
pub struct State<Substates: ModelState> {
    pub uid_source: Uid,
    pub substates: Vec<Substates>,
    /* private fields */
}
Expand description

State struct encapsulates the state-machine’s state.

This includes a Uid generator, a vector of one or more Substates instances, and the current_instance field holding the index of the currently active instance in the state-machine’s main loop.

In most scenarios, the Substates vector contains a single element. Multiple elements mainly occur in testing scenarios where multiple instances are simulated.

Fields§

§uid_source: Uid§substates: Vec<Substates>

Implementations§

Source§

impl<Substates: ModelState> State<Substates>

Source

pub fn new() -> Self

Source

pub fn new_uid(&mut self) -> Uid

Generates a new unique identifier (Uid).

Source

pub fn get_current_instance(&self) -> usize

Source

pub fn set_current_instance(&mut self, instance: usize)

Source

pub fn substate<T: 'static + Any>(&self) -> &T

Returns a reference to the state of the currently active substate.

Source

pub fn substate_mut<T: 'static + Any>(&mut self) -> &mut T

Returns a mutable reference to the state of the currently active substate.

Auto Trait Implementations§

§

impl<Substates> Freeze for State<Substates>

§

impl<Substates> RefUnwindSafe for State<Substates>
where Substates: RefUnwindSafe,

§

impl<Substates> Send for State<Substates>
where Substates: Send,

§

impl<Substates> Sync for State<Substates>
where Substates: Sync,

§

impl<Substates> Unpin for State<Substates>
where Substates: Unpin,

§

impl<Substates> UnwindSafe for State<Substates>
where Substates: UnwindSafe,

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.
Source§

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

Source§

fn vzip(self) -> V