pub struct LeaderId<NID>where
NID: NodeId,{
pub term: u64,
pub node_id: NID,
}
Expand description
LeaderId is identifier of a leader
.
In raft spec that in a term there is at most one leader, thus a term
is enough to
differentiate leaders. That is why raft uses (term, index)
to uniquely identify a log
entry.
Under this dirty simplification, a Leader
is actually identified by (term, voted_for:Option<node_id>)
.
By introducing LeaderId {term, node_id}
, things become easier to understand.
Fields§
§term: u64
§node_id: NID
Implementations§
Trait Implementations§
source§impl<'de, NID> Deserialize<'de> for LeaderId<NID>where
NID: NodeId,
impl<'de, NID> Deserialize<'de> for LeaderId<NID>where
NID: NodeId,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<NID> Ord for LeaderId<NID>
impl<NID> Ord for LeaderId<NID>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<NID> PartialEq for LeaderId<NID>
impl<NID> PartialEq for LeaderId<NID>
source§impl<NID> PartialOrd for LeaderId<NID>where
NID: NodeId + PartialOrd,
impl<NID> PartialOrd for LeaderId<NID>where
NID: NodeId + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<NID> Copy for LeaderId<NID>
impl<NID> Eq for LeaderId<NID>
impl<NID> StructuralPartialEq for LeaderId<NID>where
NID: NodeId,
Auto Trait Implementations§
impl<NID> Freeze for LeaderId<NID>where
NID: Freeze,
impl<NID> RefUnwindSafe for LeaderId<NID>where
NID: RefUnwindSafe,
impl<NID> Send for LeaderId<NID>
impl<NID> Sync for LeaderId<NID>
impl<NID> Unpin for LeaderId<NID>where
NID: Unpin,
impl<NID> UnwindSafe for LeaderId<NID>where
NID: UnwindSafe,
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