Struct openraft::RaftState

source ·
pub struct RaftState<NID, N, I>
where NID: NodeId, N: Node, I: Instant,
{ pub committed: Option<LogId<NID>>, pub log_ids: LogIdList<NID>, pub membership_state: MembershipState<NID, N>, pub snapshot_meta: SnapshotMeta<NID, N>, pub server_state: ServerState, /* private fields */ }
Expand description

A struct used to represent the raft state which a Raft node needs.

Fields§

§committed: Option<LogId<NID>>

The LogId of the last log committed(AKA applied) to the state machine.

  • Committed means: a log that is replicated to a quorum of the cluster and it is of the term of the leader.

  • A quorum could be a uniform quorum or joint quorum.

§log_ids: LogIdList<NID>

All log ids this node has.

§membership_state: MembershipState<NID, N>

The latest cluster membership configuration found, in log or in state machine.

§snapshot_meta: SnapshotMeta<NID, N>

The metadata of the last snapshot.

§server_state: ServerState

The state of a Raft node, such as Leader or Follower.

Implementations§

source§

impl<NID, N, I> RaftState<NID, N, I>
where NID: NodeId, N: Node, I: Instant,

source

pub fn vote_ref(&self) -> &Vote<NID>

Get a reference to the current vote.

source

pub fn vote_last_modified(&self) -> Option<I>

Return the last updated time of the vote.

Trait Implementations§

source§

impl<NID, N, I> Clone for RaftState<NID, N, I>
where NID: NodeId + Clone, N: Node + Clone, I: Instant + Clone,

source§

fn clone(&self) -> RaftState<NID, N, I>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<NID, N, I> Debug for RaftState<NID, N, I>
where NID: NodeId + Debug, N: Node + Debug, I: Instant + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<NID, N, I> Default for RaftState<NID, N, I>
where NID: NodeId, N: Node, I: Instant,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<NID, N, I> PartialEq for RaftState<NID, N, I>
where NID: NodeId + PartialEq, N: Node + PartialEq, I: Instant + PartialEq,

source§

fn eq(&self, other: &RaftState<NID, N, I>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<NID, N, I> Validate for RaftState<NID, N, I>
where NID: NodeId, N: Node, I: Instant,

source§

fn validate(&self) -> Result<(), Box<dyn Error>>

Validate the internal state.
source§

impl<NID, N, I> Eq for RaftState<NID, N, I>
where NID: NodeId + Eq, N: Node + Eq, I: Instant + Eq,

source§

impl<NID, N, I> StructuralPartialEq for RaftState<NID, N, I>
where NID: NodeId, N: Node, I: Instant,

Auto Trait Implementations§

§

impl<NID, N, I> Freeze for RaftState<NID, N, I>
where I: Freeze, NID: Freeze,

§

impl<NID, N, I> RefUnwindSafe for RaftState<NID, N, I>

§

impl<NID, N, I> Send for RaftState<NID, N, I>

§

impl<NID, N, I> Sync for RaftState<NID, N, I>

§

impl<NID, N, I> Unpin for RaftState<NID, N, I>
where NID: Unpin,

§

impl<NID, N, I> UnwindSafe for RaftState<NID, N, I>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> ValidateExt for T
where T: Validate,

source§

fn valid(self) -> Valid<T>

Return an always valid instance Valid<Self> that enables internal state validation.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> OptionalSend for T
where T: Send + ?Sized,

source§

impl<T> OptionalSync for T
where T: Sync + ?Sized,