Trait raft_consensus::persistent_log::Log [] [src]

pub trait Log: Clone + Debug + 'static {
    type Error: Error + Debug + Sized + 'static + Send + Sync;
    fn current_term(&self) -> Result<Term, Self::Error>;
fn set_current_term(&mut self, term: Term) -> Result<(), Self::Error>;
fn inc_current_term(&mut self) -> Result<Term, Self::Error>;
fn voted_for(&self) -> Result<Option<ServerId>, Self::Error>;
fn set_voted_for(&mut self, server: ServerId) -> Result<(), Self::Error>;
fn latest_log_index(&self) -> Result<LogIndex, Self::Error>;
fn latest_log_term(&self) -> Result<Term, Self::Error>;
fn entry<W: Write>(
        &self,
        index: LogIndex,
        buf: Option<W>
    ) -> Result<Term, Self::Error>;
fn append_entries<R: Read, I: Iterator<Item = (Term, R)>>(
        &mut self,
        from: LogIndex,
        entries: I
    ) -> Result<(), Self::Error>; }

A store of persistent Raft state.

Associated Types

Required Methods

Returns the latest known term.

Sets the current term to the provided value. The provided term must be greater than the current term. The voted_for value will be reset`.

Increment the current term. The voted_for value will be reset.

Returns the candidate id of the candidate voted for in the current term (or none).

Sets the candidate id voted for in the current term.

Returns the index of the latest persisted log entry (0 if the log is empty).

Returns the term of the latest persisted log entry (0 if the log is empty).

Returns the term for the entry at the provided log index writing entry itself to writer if requested

Appends the provided entries to the log beginning at the given index.

Implementors