pub struct HardState {
pub term: Term,
pub voted_for: Option<NodeId>,
}Expand description
The state Raft must persist before responding to any RPC.
Safety depends on current_term and voted_for surviving a crash: a node
that forgot it had already voted in a term could vote twice and help elect
two leaders. The RaftLog stores this alongside the log
entries; the in-memory MemoryLog keeps it in a field.
§Examples
use raft_io::HardState;
let hs = HardState::default();
assert_eq!(hs.term, 0);
assert_eq!(hs.voted_for, None);Fields§
§term: TermThe latest term the node has seen.
voted_for: Option<NodeId>The candidate this node voted for in term, if any.
Trait Implementations§
impl Copy for HardState
impl Eq for HardState
impl StructuralPartialEq for HardState
Auto Trait Implementations§
impl Freeze for HardState
impl RefUnwindSafe for HardState
impl Send for HardState
impl Sync for HardState
impl Unpin for HardState
impl UnsafeUnpin for HardState
impl UnwindSafe for HardState
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