pub struct RaftLog { /* private fields */ }Expand description
The Raft replicated log
Implementations§
Source§impl RaftLog
impl RaftLog
Sourcepub fn last_index(&self) -> LogIndex
pub fn last_index(&self) -> LogIndex
Get the index of the last log entry
Sourcepub fn entries_from(&self, start_index: LogIndex) -> Vec<LogEntry>
pub fn entries_from(&self, start_index: LogIndex) -> Vec<LogEntry>
Get entries starting from an index
Sourcepub fn append(&mut self, term: Term, command: Vec<u8>) -> LogIndex
pub fn append(&mut self, term: Term, command: Vec<u8>) -> 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 (for replication)
Sourcepub fn truncate_from(&mut self, index: LogIndex) -> RaftResult<()>
pub fn truncate_from(&mut self, index: LogIndex) -> RaftResult<()>
Truncate log from a given index (delete entries >= index)
Sourcepub fn matches(&self, index: LogIndex, term: Term) -> bool
pub fn matches(&self, index: LogIndex, term: Term) -> bool
Check if log contains an entry at index with the given term
Sourcepub fn install_snapshot(&mut self, snapshot: Snapshot) -> RaftResult<()>
pub fn install_snapshot(&mut self, snapshot: Snapshot) -> RaftResult<()>
Install a snapshot and compact the log
Sourcepub fn create_snapshot(
&mut self,
up_to_index: LogIndex,
data: Vec<u8>,
configuration: Vec<String>,
) -> RaftResult<Snapshot>
pub fn create_snapshot( &mut self, up_to_index: LogIndex, data: Vec<u8>, configuration: Vec<String>, ) -> RaftResult<Snapshot>
Create a snapshot up to the given index
Sourcepub fn base_index(&self) -> LogIndex
pub fn base_index(&self) -> LogIndex
Get the base index from snapshot
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RaftLog
impl<'de> Deserialize<'de> for RaftLog
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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