pub struct LifecycleStateMachine { /* private fields */ }Expand description
Lifecycle state machine that manages state transitions.
Implementations§
Source§impl LifecycleStateMachine
impl LifecycleStateMachine
Sourcepub fn new() -> LifecycleStateMachine
pub fn new() -> LifecycleStateMachine
Create a new state machine.
Sourcepub fn with_retries(
self,
max_retries: u32,
retry_delay: Duration,
) -> LifecycleStateMachine
pub fn with_retries( self, max_retries: u32, retry_delay: Duration, ) -> LifecycleStateMachine
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, Error>
pub fn transition_to( &mut self, target: DeviceState, ) -> Result<DeviceState, Error>
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
Source§impl Default for LifecycleStateMachine
impl Default for LifecycleStateMachine
Source§fn default() -> LifecycleStateMachine
fn default() -> LifecycleStateMachine
Returns the “default value” for a type. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more