pub trait TerminalStateInfallible: State<Infallible> {
// Required methods
fn terminate(self);
fn terminate_with(self, ctx: &dyn Any);
}Expand description
Extension trait providing infallible termination methods for states where Error = Infallible.
This trait is automatically implemented for any state satisfying Infallible as Error.
It provides terminate() and
terminate_with() which do not return a
Result.
§Example
#[derive(Debug)]
struct Green;
impl State for Green {}
impl Transition<Green> for Primordial {
fn change(self, _: &dyn Any) -> TransitionResult<Primordial, Green> { Ok(Green) }
}
impl Transition<Terminated> for Green {
fn change(self, _: &dyn Any) -> TransitionResult<Green, Terminated> { Ok(Terminated) }
}
let green = Green::new();
green.terminate();Required Methods§
Sourcefn terminate(self)
fn terminate(self)
Infallible termination. Consumes the state and returns Terminated.
Sourcefn terminate_with(self, ctx: &dyn Any)
fn terminate_with(self, ctx: &dyn Any)
Infallible termination with context.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T> TerminalStateInfallible for T
Implement TerminalStateInfallible for all types that implement Transition<Terminal, Infallible> for T.