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
fn current_term(&self) -> Result<Term, Self::Error>
Returns the latest known term.
fn set_current_term(&mut self, term: Term) -> Result<(), Self::Error>
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`.
fn inc_current_term(&mut self) -> Result<Term, Self::Error>
Increment the current term. The voted_for
value will be reset.
fn voted_for(&self) -> Result<Option<ServerId>, Self::Error>
Returns the candidate id of the candidate voted for in the current term (or none).
fn set_voted_for(&mut self, server: ServerId) -> Result<(), Self::Error>
Sets the candidate id voted for in the current term.
fn latest_log_index(&self) -> Result<LogIndex, Self::Error>
Returns the index of the latest persisted log entry (0 if the log is empty).
fn latest_log_term(&self) -> Result<Term, Self::Error>
Returns the term of the latest persisted log entry (0 if the log is empty).
fn entry<W: Write>(
&self,
index: LogIndex,
buf: Option<W>
) -> Result<Term, Self::Error>
&self,
index: LogIndex,
buf: Option<W>
) -> Result<Term, Self::Error>
Returns the term for the entry at the provided log index writing entry itself to writer if requested
fn append_entries<R: Read, I: Iterator<Item = (Term, R)>>(
&mut self,
from: LogIndex,
entries: I
) -> Result<(), Self::Error>
&mut self,
from: LogIndex,
entries: I
) -> Result<(), Self::Error>
Appends the provided entries to the log beginning at the given index.