pub struct HardState {
pub current_term: u64,
pub voted_for: Option<VotedFor>,
}Expand description
Hard state (Raft persistent state: term, voted_for, log)
Fields§
§current_term: u64Persistent state on all servers(Updated on stable storage before responding to RPCs): latest term server has seen (initialized to 0 on first boot, increases monotonically) Terms act as a logical clock in Raft, and they allow servers to detect obsolete information such as stale leaders. Each server stores a current term number, which increases monotonically over time.
voted_for: Option<VotedFor>Persistent state on all servers(Updated on stable storage before responding to RPCs): candidateId that received vote in current term (or null if none)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HardState
impl<'de> Deserialize<'de> for HardState
Source§fn deserialize<D>(
deserializer: D,
) -> Result<HardState, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<HardState, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for HardState
impl Serialize for HardState
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy 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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request