pub struct LifecycleStateMachine { /* private fields */ }Expand description
Lifecycle state machine that manages state transitions.
Implementations§
Source§impl LifecycleStateMachine
impl LifecycleStateMachine
Sourcepub fn with_retries(self, max_retries: u32, retry_delay: Duration) -> Self
pub fn with_retries(self, max_retries: u32, retry_delay: Duration) -> Self
Create with custom retry settings.
Sourcepub fn state(&self) -> DeviceState
pub fn state(&self) -> DeviceState
Get the current state.
Sourcepub fn can_transition_to(&self, target: DeviceState) -> bool
pub fn can_transition_to(&self, target: DeviceState) -> bool
Check if a transition is valid.
Sourcepub fn transition_to(&mut self, target: DeviceState) -> Result<DeviceState>
pub fn transition_to(&mut self, target: DeviceState) -> Result<DeviceState>
Attempt to transition to a new state.
Sourcepub fn record_error(&mut self) -> bool
pub fn record_error(&mut self) -> bool
Record an error and check if retries are exhausted.
Sourcepub fn error_count(&self) -> u32
pub fn error_count(&self) -> u32
Get the current error count.
Sourcepub fn reset_errors(&mut self)
pub fn reset_errors(&mut self)
Reset the error count.
Sourcepub fn time_in_state(&self) -> Option<Duration>
pub fn time_in_state(&self) -> Option<Duration>
Get time since last transition.
Trait Implementations§
Source§impl Clone for LifecycleStateMachine
impl Clone for LifecycleStateMachine
Source§fn clone(&self) -> LifecycleStateMachine
fn clone(&self) -> LifecycleStateMachine
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LifecycleStateMachine
impl Debug for LifecycleStateMachine
Auto Trait Implementations§
impl Freeze for LifecycleStateMachine
impl RefUnwindSafe for LifecycleStateMachine
impl Send for LifecycleStateMachine
impl Sync for LifecycleStateMachine
impl Unpin for LifecycleStateMachine
impl UnsafeUnpin for LifecycleStateMachine
impl UnwindSafe for LifecycleStateMachine
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