pub trait Transition{
// 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§
Provided Methods§
Sourcefn transition(&mut self, to: Self)
fn transition(&mut self, to: Self)
Calls Self::try_transition, panicking when the transition is not valid.
Sourcefn verified_transition(
&mut self,
to: Self,
) -> Result<(), <Self as Stateful>::Error>where
Self: Verify,
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.