pub struct CandidateState {
pub votes_received: Vec<NodeId>,
}Expand description
Volatile state for candidates (during election)
Fields§
§votes_received: Vec<NodeId>Votes received from peers (including self)
Implementations§
Source§impl CandidateState
impl CandidateState
Sourcepub fn record_vote(&mut self, peer: NodeId)
pub fn record_vote(&mut self, peer: NodeId)
Record a vote from a peer
Sourcepub fn has_quorum(&self, quorum_size: usize) -> bool
pub fn has_quorum(&self, quorum_size: usize) -> bool
Check if we have a quorum of votes
Sourcepub fn vote_count(&self) -> usize
pub fn vote_count(&self) -> usize
Get the number of votes received
Trait Implementations§
Source§impl Clone for CandidateState
impl Clone for CandidateState
Source§fn clone(&self) -> CandidateState
fn clone(&self) -> CandidateState
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 moreAuto Trait Implementations§
impl Freeze for CandidateState
impl RefUnwindSafe for CandidateState
impl Send for CandidateState
impl Sync for CandidateState
impl Unpin for CandidateState
impl UnwindSafe for CandidateState
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