Trait StateBehavior

Source
pub trait StateBehavior {
    type State: Clone + Copy + PartialEq + Default;
    type Event: Clone + Copy + PartialEq;
    type Context: Default;

    // Required method
    fn handle(
        &self,
        event: &Self::Event,
        _context: &mut Self::Context,
    ) -> Option<Self::State>;

    // Provided methods
    fn enter(&self, _context: &mut Self::Context) { ... }
    fn exit(&self, _context: &mut Self::Context) { ... }
}
Expand description

Trait for the state behavior.

Required Associated Types§

Required Methods§

Source

fn handle( &self, event: &Self::Event, _context: &mut Self::Context, ) -> Option<Self::State>

Handle an event and return the next state (if a transition occurs).

Provided Methods§

Source

fn enter(&self, _context: &mut Self::Context)

State entry

Source

fn exit(&self, _context: &mut Self::Context)

State exit

Implementors§