pub struct Log { /* private fields */ }Expand description
A node’s log: the snapshot base plus every entry after it.
Implementations§
Source§impl Log
impl Log
Sourcepub const fn base_index(&self) -> LogIndex
pub const fn base_index(&self) -> LogIndex
The index of the snapshot base (0 before any snapshot is installed).
Sourcepub const fn last_index(&self) -> LogIndex
pub const fn last_index(&self) -> LogIndex
The index of the last entry, or the base index when empty.
Sourcepub fn term_at(&self, index: LogIndex) -> Option<Term>
pub fn term_at(&self, index: LogIndex) -> Option<Term>
The term of the entry at index, the base term at the base index,
term 0 at the sentinel, and None outside the log.
Sourcepub fn entry_at(&self, index: LogIndex) -> Option<&LogEntry>
pub fn entry_at(&self, index: LogIndex) -> Option<&LogEntry>
The entry at index, or None at or below the base and beyond
the tail.
Sourcepub fn append(&mut self, new_entries: &[LogEntry]) -> LogIndex
pub fn append(&mut self, new_entries: &[LogEntry]) -> LogIndex
Append entries at the tail. Returns the index of the first appended entry.
Sourcepub const fn base_term(&self) -> Term
pub const fn base_term(&self) -> Term
The term of the snapshot base entry (term 0 at the sentinel).
Sourcepub fn advance_base(&mut self, index: LogIndex, term: Term)
pub fn advance_base(&mut self, index: LogIndex, term: Term)
Advance the snapshot base to (index, term), discarding every
entry at or below index. The caller (snapshot install)
guarantees term is the term of the entry at index and that
index does not pass the node’s commit boundary (invariant
N-05). Advancing to or below the current base is a no-op.
Sourcepub fn clear_entries(&mut self)
pub fn clear_entries(&mut self)
Discard the entire entry vector, keeping the snapshot base. Used by snapshot install when the follower’s log holds no entry matching the snapshot’s last included entry (invariant N-04).
Sourcepub fn truncate_from(&mut self, index: LogIndex)
pub fn truncate_from(&mut self, index: LogIndex)
Delete every entry at or after index. Deleting at or below the
base index is a no-op: compacted history is never resurrected.
Sourcepub fn first_index_of_term(&self, term: Term) -> Option<LogIndex>
pub fn first_index_of_term(&self, term: Term) -> Option<LogIndex>
The first index whose entry carries term, if any.
Sourcepub fn last_index_of_term(&self, term: Term) -> Option<LogIndex>
pub fn last_index_of_term(&self, term: Term) -> Option<LogIndex>
The last index whose entry carries term, if any.