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
impl MemoryStorage
Trait Implementations§
Source§impl Clone for MemoryStorage
impl Clone for MemoryStorage
Source§fn clone(&self) -> MemoryStorage
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryStorage
impl Debug for MemoryStorage
Source§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§fn default() -> MemoryStorage
fn default() -> MemoryStorage
Returns the “default value” for a type. Read more
Source§impl Storage for MemoryStorage
impl Storage for MemoryStorage
Source§type Error = MemoryStorageError
type Error = MemoryStorageError
Error type for storage operations.
Source§async fn store_leaf(
&mut self,
index: u64,
data: &[u8],
) -> Result<(), Self::Error>
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>
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>
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>
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>
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>
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>
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>
async fn load_log_meta(&self) -> Result<Option<(u64, u8)>, Self::Error>
Load authoritative log metadata written by
write_batch. Read moreSource§async fn load_checkpoint_roots(
&self,
) -> Result<Vec<(u64, Vec<u8>)>, Self::Error>
async fn load_checkpoint_roots( &self, ) -> Result<Vec<(u64, Vec<u8>)>, Self::Error>
Load per-algorithm checkpoint roots last written by
write_batch. Read moreSource§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>
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
Auto Trait Implementations§
impl Freeze for MemoryStorage
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl UnwindSafe for MemoryStorage
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