pub trait TryState {
type Error;
fn try_entry(&mut self) -> Result<(), Self::Error> { ... }
fn try_execute(&mut self) -> Result<(), Self::Error> { ... }
fn try_exit(&mut self) -> Result<(), Self::Error> { ... }
}
Expand description
Trait that must be implemented by all states that are used by the fallible state machine.
Behaves similar to the normal State
trait, but requires the user to specify
an Error type. If this error is returned, the state machine immediately transitions into the
error state.
Required Associated Types
Provided Methods
Implement any behavior that hast to be executed when entering the state.
Return Ok(())
if no error occurred or Err(Self::Error)
if something happened.
fn try_entry(&mut self) -> Result<(), Self::Error> {
println!("Called right after being transitioned into");
return Ok(());
}
fn try_execute(&mut self) -> Result<(), Self::Error>
fn try_execute(&mut self) -> Result<(), Self::Error>
Implement any behavior that hast to be stepping.
Return Ok(())
if no error occurred or Err(Self::Error)
if something happened.
fn try_entry(&mut self) -> Result<(), Self::Error> {
println!("Called during every step");
return Ok(());
}
Implement any behavior that hast to be executed when exiting the state.
Return Ok(())
if no error occurred or Err(Self::Error)
if something happened.
fn try_entry(&mut self) -> Result<(), Self::Error> {
println!("Called before transitioning to another state");
return Ok(());
}