pub struct Machine<M: StateMachine> { /* private fields */ }Expand description
The states and transitions of a StateMachine model.
Implementations§
Source§impl<M: StateMachine> Machine<M>
impl<M: StateMachine> Machine<M>
Sourcepub fn state(self, state: impl Display) -> Self
pub fn state(self, state: impl Display) -> Self
Declares a state, to describe with tone and terminal. States that
only transitions mention are declared implicitly.
Sourcepub fn tone(self, tone: impl Into<String>) -> Self
pub fn tone(self, tone: impl Into<String>) -> Self
Sets the tone (neutral, danger, …) of the state just declared.
§Panics
When no state came before it.
Sourcepub fn terminal(self) -> Self
pub fn terminal(self) -> Self
Marks the state just declared as terminal: no transition may leave it.
§Panics
When no state came before it.
Sourcepub fn initial<S: Display>(self, states: impl IntoIterator<Item = S>) -> Self
pub fn initial<S: Display>(self, states: impl IntoIterator<Item = S>) -> Self
The states a new record may be inserted in. With none declared, inserts are unrestricted.
Sourcepub fn transition(self, transition: Transition<M>) -> Self
pub fn transition(self, transition: Transition<M>) -> Self
Adds a transition. Its states are declared if they were not.
§Panics
When it has no to state, no from state, leaves a terminal state,
or its name is already taken: a machine is code, so these are
mistakes found the first time it is built.
Sourcepub fn initial_states(&self) -> &[String]
pub fn initial_states(&self) -> &[String]
The states inserts are limited to; empty when unrestricted.
Sourcepub fn transitions(&self) -> &[Transition<M>]
pub fn transitions(&self) -> &[Transition<M>]
Every transition, in the order added.
Sourcepub fn find(&self, name: &str) -> Result<&Transition<M>, TransitionError>
pub fn find(&self, name: &str) -> Result<&Transition<M>, TransitionError>
The transition called name.
Sourcepub fn from_state<'a>(
&'a self,
state: &'a str,
) -> impl Iterator<Item = &'a Transition<M>> + 'a
pub fn from_state<'a>( &'a self, state: &'a str, ) -> impl Iterator<Item = &'a Transition<M>> + 'a
The transitions that leave state, in the order added.
Trait Implementations§
Auto Trait Implementations§
impl<M> !RefUnwindSafe for Machine<M>
impl<M> !UnwindSafe for Machine<M>
impl<M> Freeze for Machine<M>
impl<M> Send for Machine<M>
impl<M> Sync for Machine<M>
impl<M> Unpin for Machine<M>
impl<M> UnsafeUnpin for Machine<M>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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