pub struct NodeStateMachine { /* private fields */ }Expand description
Manages state transitions for a replication node.
encapsulates the current replicator state, validates transitions, and tracks timing.
All methods are thread-safe. The state machine enforces that only valid transitions are permitted according to the replication protocol.
Implementations§
Source§impl NodeStateMachine
impl NodeStateMachine
Sourcepub fn get_state_change_time(&self) -> Instant
pub fn get_state_change_time(&self) -> Instant
Get the time at which the last state change occurred.
Sourcepub fn get_transition_count(&self) -> u64
pub fn get_transition_count(&self) -> u64
Get the total number of state transitions.
Sourcepub fn transition_to(&self, new_state: NodeState) -> Result<NodeState>
pub fn transition_to(&self, new_state: NodeState) -> Result<NodeState>
Transition to a new state, validating the transition is legal.
Returns the previous state on success.
§Errors
Returns RepError::InvalidStateTransition if the transition from the
current state to the new state is not permitted.
Sourcepub fn can_transition_to(&self, new_state: NodeState) -> bool
pub fn can_transition_to(&self, new_state: NodeState) -> bool
Check if a transition to the given state is valid from the current state.
Sourcepub fn time_in_state(&self) -> Duration
pub fn time_in_state(&self) -> Duration
Get the time spent in the current state.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for NodeStateMachine
impl !RefUnwindSafe for NodeStateMachine
impl Send for NodeStateMachine
impl Sync for NodeStateMachine
impl Unpin for NodeStateMachine
impl UnsafeUnpin for NodeStateMachine
impl UnwindSafe for NodeStateMachine
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> 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