Skip to main content

Log

Struct Log 

Source
pub struct Log { /* private fields */ }
Expand description

A node’s log: the snapshot base plus every entry after it.

Implementations§

Source§

impl Log

Source

pub fn new() -> Self

An empty log with only the sentinel base.

Source

pub const fn base_index(&self) -> LogIndex

The index of the snapshot base (0 before any snapshot is installed).

Source

pub const fn last_index(&self) -> LogIndex

The index of the last entry, or the base index when empty.

Source

pub fn last_term(&self) -> Term

The term of the last entry, or the base term when empty.

Source

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.

Source

pub fn entry_at(&self, index: LogIndex) -> Option<&LogEntry>

The entry at index, or None at or below the base and beyond the tail.

Source

pub fn append(&mut self, new_entries: &[LogEntry]) -> LogIndex

Append entries at the tail. Returns the index of the first appended entry.

Source

pub const fn base_term(&self) -> Term

The term of the snapshot base entry (term 0 at the sentinel).

Source

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.

Source

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).

Source

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.

Source

pub fn first_index_of_term(&self, term: Term) -> Option<LogIndex>

The first index whose entry carries term, if any.

Source

pub fn last_index_of_term(&self, term: Term) -> Option<LogIndex>

The last index whose entry carries term, if any.

Source

pub fn entries_from( &self, index: LogIndex, max_count: usize, max_bytes: usize, ) -> Vec<LogEntry>

Up to max_count entries starting at index, bounded also by the approximate byte budget max_bytes. Empty when index is past the tail.

Source

pub fn entries(&self) -> &[LogEntry]

Every entry in index order, for oracles and tests.

Trait Implementations§

Source§

impl Clone for Log

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Log

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Log

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Log

Source§

impl PartialEq for Log

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Log

Auto Trait Implementations§

§

impl Forget for Log

§

impl Freeze for Log

§

impl Move for Log

§

impl RefUnwindSafe for Log

§

impl Send for Log

§

impl Sync for Log

§

impl Unpin for Log

§

impl UnsafeUnpin for Log

§

impl UnwindSafe for Log

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.