pub struct RaftLog { /* private fields */ }Expand description
In-memory log with persistent backing
Implementations§
Source§impl RaftLog
impl RaftLog
Sourcepub fn append(&mut self, term: Term, command: Command) -> LogIndex
pub fn append(&mut self, term: Term, command: Command) -> LogIndex
Append a new entry to the log
Sourcepub fn append_entries(&mut self, entries: Vec<LogEntry>) -> RaftResult<()>
pub fn append_entries(&mut self, entries: Vec<LogEntry>) -> RaftResult<()>
Append multiple entries to the log
Sourcepub fn get_entries_from(
&self,
start_index: LogIndex,
max_count: usize,
) -> Vec<LogEntry>
pub fn get_entries_from( &self, start_index: LogIndex, max_count: usize, ) -> Vec<LogEntry>
Get entries starting from a given index
Sourcepub fn last_index(&self) -> LogIndex
pub fn last_index(&self) -> LogIndex
Get the index of the last entry
Sourcepub fn truncate_from(&mut self, from_index: LogIndex) -> RaftResult<()>
pub fn truncate_from(&mut self, from_index: LogIndex) -> RaftResult<()>
Delete entries from a given index onwards
Sourcepub fn matches(&self, index: LogIndex, term: Term) -> bool
pub fn matches(&self, index: LogIndex, term: Term) -> bool
Check if the log contains an entry at the given index with the given term
Sourcepub fn commit_index(&self) -> LogIndex
pub fn commit_index(&self) -> LogIndex
Get the commit index
Sourcepub fn set_commit_index(&mut self, index: LogIndex) -> RaftResult<()>
pub fn set_commit_index(&mut self, index: LogIndex) -> RaftResult<()>
Set the commit index (must be monotonically increasing)
Sourcepub fn applied_index(&self) -> LogIndex
pub fn applied_index(&self) -> LogIndex
Get the applied index
Sourcepub fn set_applied_index(&mut self, index: LogIndex) -> RaftResult<()>
pub fn set_applied_index(&mut self, index: LogIndex) -> RaftResult<()>
Set the applied index (must be monotonically increasing)
Sourcepub fn get_uncommitted_entries(&self) -> Vec<LogEntry>
pub fn get_uncommitted_entries(&self) -> Vec<LogEntry>
Get entries that are committed but not yet applied
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RaftLog
impl RefUnwindSafe for RaftLog
impl Send for RaftLog
impl Sync for RaftLog
impl Unpin for RaftLog
impl UnwindSafe for RaftLog
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