pub struct ElectionTimer { /* private fields */ }Expand description
Election timer with randomized timeout
Implementations§
Source§impl ElectionTimer
impl ElectionTimer
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default timeouts (150-300ms as per Raft paper)
Sourcepub fn is_elapsed(&self) -> bool
pub fn is_elapsed(&self) -> bool
Check if the election timeout has elapsed
Sourcepub fn time_remaining(&self) -> Duration
pub fn time_remaining(&self) -> Duration
Get time remaining until timeout
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ElectionTimer
impl RefUnwindSafe for ElectionTimer
impl Send for ElectionTimer
impl Sync for ElectionTimer
impl Unpin for ElectionTimer
impl UnwindSafe for ElectionTimer
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