Transition

Trait Transition 

Source
pub trait Transition
where Self: Debug + Stateful + Sized,
{ // Required method fn try_transition( &mut self, to: Self, ) -> Result<(), <Self as Stateful>::Error>; // Provided methods fn transition(&mut self, to: Self) { ... } fn verified_transition( &mut self, to: Self, ) -> Result<(), <Self as Stateful>::Error> where Self: Verify { ... } }
Expand description

Trait implemented by structs whose state can be characterized as having one of a few discrete states at any given time. stateful structs or enumerations (usually enumerations) that can be at one of a few states known at compile time. Some of the transitions from state T->U might be invalid and must be specified at the implementation of self.transition. TODO rename to transition?

Required Methods§

Source

fn try_transition(&mut self, to: Self) -> Result<(), <Self as Stateful>::Error>

Modifies Self by setting it to another value at to. It might be the case that there isn’t a valid transition between the current state and the state represented at to, in which case

Provided Methods§

Source

fn transition(&mut self, to: Self)

Calls Self::try_transition, panicking when the transition is not valid.

Source

fn verified_transition( &mut self, to: Self, ) -> Result<(), <Self as Stateful>::Error>
where Self: Verify,

Checks if a transition is legal by verifying the current state and the next possible state before attempting the transition. If transition from state T->U is invalid, overwrite this method.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§