Skip to main content

MemoryStorage

Struct MemoryStorage 

Source
pub struct MemoryStorage {
    pub leaves: Vec<Vec<u8>>,
    pub nodes: HashMap<(u64, u64, u32), Vec<u8>>,
    pub algorithm_metas: HashMap<u64, Vec<(u64, u64)>>,
    pub log_meta: Option<(u64, u8)>,
    pub checkpoint_roots: HashMap<u64, Vec<u8>>,
}
Expand description

In-memory leaf and node storage backed by collections.

Fields§

§leaves: Vec<Vec<u8>>

Raw leaf payloads.

§nodes: HashMap<(u64, u64, u32), Vec<u8>>

Sealed internal node hashes, keyed by (alg_id, left, height).

§algorithm_metas: HashMap<u64, Vec<(u64, u64)>>

Algorithm epoch metadata, keyed by algorithm ID.

§log_meta: Option<(u64, u8)>

Authoritative log metadata: (total_append_count, kind_byte).

§checkpoint_roots: HashMap<u64, Vec<u8>>

Per-algorithm checkpoint roots: the root hash at the last append.

Implementations§

Source§

impl MemoryStorage

Source

pub fn new() -> Self

Create a new empty in-memory storage.

Trait Implementations§

Source§

impl Clone for MemoryStorage

Source§

fn clone(&self) -> MemoryStorage

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 MemoryStorage

Source§

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

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

impl Default for MemoryStorage

Source§

fn default() -> MemoryStorage

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

impl Storage for MemoryStorage

Source§

type Error = MemoryStorageError

Error type for storage operations.
Source§

async fn store_leaf( &mut self, index: u64, data: &[u8], ) -> Result<(), Self::Error>

Persist a raw leaf payload at the given index.
Source§

async fn get_leaf(&self, index: u64) -> Result<Vec<u8>, Self::Error>

Retrieve the raw leaf payload at the given index.
Source§

async fn len(&self) -> Result<u64, Self::Error>

The number of leaves currently stored, or an error if storage is unreadable. Never returns 0 on error; a storage failure must be propagated so callers can distinguish “empty log” from “broken store”.
Source§

async fn store_node( &mut self, alg_id: u64, left: u64, height: u32, hash: &[u8], ) -> Result<(), Self::Error>

Persist a sealed internal node hash.
Source§

async fn get_node( &self, alg_id: u64, left: u64, height: u32, ) -> Result<Option<Vec<u8>>, Self::Error>

Retrieve a sealed internal node hash.
Source§

async fn store_algorithm_meta( &mut self, alg_id: u64, epochs: &[(u64, u64)], ) -> Result<(), Self::Error>

Persist algorithm metadata (epoch boundaries) for add/remove operations. Read more
Source§

async fn load_algorithm_metas(&self) -> Result<AlgorithmMetas, Self::Error>

Load all persisted algorithm metadata.
Source§

async fn load_log_meta(&self) -> Result<Option<(u64, u8)>, Self::Error>

Load authoritative log metadata written by write_batch. Read more
Source§

async fn load_checkpoint_roots( &self, ) -> Result<Vec<(u64, Vec<u8>)>, Self::Error>

Load per-algorithm checkpoint roots last written by write_batch. Read more
Source§

async fn write_batch( &mut self, leaves: &[(u64, &[u8])], nodes: &[(u64, u64, u32, &[u8])], algorithm_metas: &[(u64, &[(u64, u64)])], log_meta: Option<(u64, u8)>, checkpoint_roots: &[(u64, &[u8])], ) -> Result<(), Self::Error>

Atomically commit leaves, nodes, algorithm epoch updates, log metadata, and per-algorithm checkpoint roots in a single durable transaction. Read more
Source§

fn is_empty(&self) -> impl Future<Output = Result<bool, Self::Error>> + Send

Whether the storage contains no leaves.

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