Skip to main content

MemLog

Struct MemLog 

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

Primary in-memory implementation (also the dev/test runtime).

Implementations§

Source§

impl MemLog

Source

pub fn new() -> Self

Creates an empty in-memory log.

Trait Implementations§

Source§

impl Default for MemLog

Source§

fn default() -> MemLog

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

impl OpLog for MemLog

Source§

fn sync(&mut self) -> Result<(), LogError>

Nothing to do: a MemLog never outlives its process, so there is no weaker state for sync to strengthen. The default would serve; it is spelled out because “in-memory logs cannot be made durable” is the reason, not an oversight.

Source§

fn append(&mut self, entry: OpEntry) -> Result<ContentHash, LogError>

Appends entry and returns its content hash (the new head). Read more
Source§

fn head(&self) -> Option<ContentHash>

Content hash of the newest entry, or None for an empty log.
Source§

fn len(&self) -> u64

Number of entries in the log.
Source§

fn get(&self, seq: u64) -> Option<OpEntry>

Entry at sequence number seq, or None if out of range.
Source§

fn last(&self) -> Option<&OpEntry>

Borrows the newest entry without cloning it. Read more
Source§

fn is_empty(&self) -> bool

Whether the log has no entries.

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

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.