pub trait TryTransition<DestinationState>: Into<DestinationState> + TryState {
    fn guard(&self) -> TransitGuard;

    fn try_action(&mut self) -> Result<(), Self::Error> { ... }
}
Expand description

Trait that must be implemented by all states have a transition.

Behaves similar to the TryTransition trait but errors can be returned during every call.

Required Methods

Specifies when the state has to transit. Return TransitGuard::Remain to remain in the current state and TransitGuard::Transit to transit into the next one. This is the only function that must be implemented by the transition. The others are optional and situational.

    fn guard(&self) -> TransitGuard {
        let foo = 0;
        if foo == 0 {
            TransitGuard::Remain
        } else {
            TransitGuard::Transit
        }
    }

Provided Methods

Implement any behavior that hast to be executed when transitioning to the next the state. Return Ok(()) if no error occurred or Err(Self::Error) if something happened.


    fn try_action(&mut self) -> Result<(), Self::Error> {
        println!("Called right after being transitioned into");
        Ok(())
    }

Implementors