pub struct PersistentState {
pub current_term: Term,
pub voted_for: Option<NodeId>,
}Expand description
Persistent state on all servers (must be persisted before responding to RPCs)
Fields§
§current_term: TermLatest term server has seen (initialized to 0, increases monotonically)
voted_for: Option<NodeId>Candidate ID that received vote in current term (None if none)
Implementations§
Source§impl PersistentState
impl PersistentState
Sourcepub fn update_term(&mut self, new_term: Term)
pub fn update_term(&mut self, new_term: Term)
Update the current term (clears voted_for if term increases)
Sourcepub fn grant_vote(&mut self, candidate_id: NodeId)
pub fn grant_vote(&mut self, candidate_id: NodeId)
Grant a vote to a candidate
Trait Implementations§
Source§impl Clone for PersistentState
impl Clone for PersistentState
Source§fn clone(&self) -> PersistentState
fn clone(&self) -> PersistentState
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 PersistentState
impl Debug for PersistentState
Auto Trait Implementations§
impl Freeze for PersistentState
impl RefUnwindSafe for PersistentState
impl Send for PersistentState
impl Sync for PersistentState
impl Unpin for PersistentState
impl UnwindSafe for PersistentState
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