pub struct StateMachine { /* private fields */ }Expand description
Connection state machine with transition validation
Implementations§
Source§impl StateMachine
impl StateMachine
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get current state
Sourcepub fn time_in_state(&self) -> Duration
pub fn time_in_state(&self) -> Duration
Get time spent in current state
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Check if current state has timed out
Sourcepub fn can_send_data(&self) -> bool
pub fn can_send_data(&self) -> bool
Check if data can be sent
Sourcepub fn can_receive_data(&self) -> bool
pub fn can_receive_data(&self) -> bool
Check if data can be received
Sourcepub fn transition(
&mut self,
event: StateEvent,
) -> Result<ConnectionState, ConstrainedError>
pub fn transition( &mut self, event: StateEvent, ) -> Result<ConnectionState, ConstrainedError>
Process an event and transition to new state
Returns the new state if transition is valid, or an error if invalid.
Sourcepub fn history(&self) -> &[(ConnectionState, StateEvent, ConnectionState)]
pub fn history(&self) -> &[(ConnectionState, StateEvent, ConnectionState)]
Get transition history
Trait Implementations§
Source§impl Debug for StateMachine
impl Debug for StateMachine
Auto Trait Implementations§
impl Freeze for StateMachine
impl RefUnwindSafe for StateMachine
impl Send for StateMachine
impl Sync for StateMachine
impl Unpin for StateMachine
impl UnsafeUnpin for StateMachine
impl UnwindSafe for StateMachine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more