Struct raft::Unstable

source ·
pub struct Unstable {
    pub snapshot: Option<Snapshot>,
    pub entries: Vec<Entry>,
    pub entries_size: usize,
    pub offset: u64,
    pub logger: Logger,
}
Expand description

The unstable.entries[i] has raft log position i+unstable.offset. Note that unstable.offset may be less than the highest log position in storage; this means that the next write to storage might need to truncate the log before persisting unstable.entries.

Fields§

§snapshot: Option<Snapshot>

The incoming unstable snapshot, if any.

§entries: Vec<Entry>

All entries that have not yet been written to storage.

§entries_size: usize

The size of entries

§offset: u64

The offset from the vector index.

§logger: Logger

The tag to use when logging.

Implementations§

source§

impl Unstable

source

pub fn new(offset: u64, logger: Logger) -> Unstable

Creates a new log of unstable entries.

source

pub fn maybe_first_index(&self) -> Option<u64>

Returns the index of the first possible entry in entries if it has a snapshot.

source

pub fn maybe_last_index(&self) -> Option<u64>

Returns the last index if it has at least one unstable entry or snapshot.

source

pub fn maybe_term(&self, idx: u64) -> Option<u64>

Returns the term of the entry at index idx, if there is any.

source

pub fn stable_entries(&mut self, index: u64, term: u64)

Clears the unstable entries and moves the stable offset up to the last index, if there is any.

source

pub fn stable_snap(&mut self, index: u64)

Clears the unstable snapshot.

source

pub fn restore(&mut self, snap: Snapshot)

From a given snapshot, restores the snapshot to self, but doesn’t unpack.

source

pub fn truncate_and_append(&mut self, ents: &[Entry])

Append entries to unstable, truncate local block first if overlapped.

Panics

Panics if truncate logs to the entry before snapshot

source

pub fn slice(&self, lo: u64, hi: u64) -> &[Entry]

Returns a slice of entries between the high and low.

Panics

Panics if the lo or hi are out of bounds. Panics if lo > hi.

source

pub fn must_check_outofbounds(&self, lo: u64, hi: u64)

Asserts the hi and lo values against each other and against the entries themselves.

Trait Implementations§

source§

impl Debug for Unstable

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,