Trait merkletree::store::Store

source ·
pub trait Store<E: Element>: Debug + Send + Sync + Sized {
Show 23 methods // Required methods fn new_with_config( size: usize, branches: usize, config: StoreConfig, ) -> Result<Self>; fn new(size: usize) -> Result<Self>; fn new_from_slice_with_config( size: usize, branches: usize, data: &[u8], config: StoreConfig, ) -> Result<Self>; fn new_from_slice(size: usize, data: &[u8]) -> Result<Self>; fn new_from_disk( size: usize, branches: usize, config: &StoreConfig, ) -> Result<Self>; fn write_at(&mut self, el: E, index: usize) -> Result<()>; fn copy_from_slice(&mut self, buf: &[u8], start: usize) -> Result<()>; fn compact( &mut self, branches: usize, config: StoreConfig, store_version: u32, ) -> Result<bool>; fn delete(config: StoreConfig) -> Result<()>; fn read_at(&self, index: usize) -> Result<E>; fn read_range(&self, r: Range<usize>) -> Result<Vec<E>>; fn read_into(&self, pos: usize, buf: &mut [u8]) -> Result<()>; fn read_range_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>; fn len(&self) -> usize; fn loaded_from_disk(&self) -> bool; fn is_empty(&self) -> bool; fn push(&mut self, el: E) -> Result<()>; // Provided methods fn reinit(&mut self) -> Result<()> { ... } fn last(&self) -> Result<E> { ... } fn sync(&self) -> Result<()> { ... } fn build_small_tree<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, ) -> Result<E> { ... } fn process_layer<A: Algorithm<E>, U: Unsigned>( &mut self, width: usize, level: usize, read_start: usize, write_start: usize, ) -> Result<()> { ... } fn build<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, _config: Option<StoreConfig>, ) -> Result<E> { ... }
}
Expand description

Backing store of the merkle tree.

Required Methods§

source

fn new_with_config( size: usize, branches: usize, config: StoreConfig, ) -> Result<Self>

Creates a new store which can store up to size elements.

source

fn new(size: usize) -> Result<Self>

source

fn new_from_slice_with_config( size: usize, branches: usize, data: &[u8], config: StoreConfig, ) -> Result<Self>

source

fn new_from_slice(size: usize, data: &[u8]) -> Result<Self>

source

fn new_from_disk( size: usize, branches: usize, config: &StoreConfig, ) -> Result<Self>

This constructor is used for instantiating stores ONLY from existing (potentially read-only) files

source

fn write_at(&mut self, el: E, index: usize) -> Result<()>

source

fn copy_from_slice(&mut self, buf: &[u8], start: usize) -> Result<()>

source

fn compact( &mut self, branches: usize, config: StoreConfig, store_version: u32, ) -> Result<bool>

source

fn delete(config: StoreConfig) -> Result<()>

source

fn read_at(&self, index: usize) -> Result<E>

source

fn read_range(&self, r: Range<usize>) -> Result<Vec<E>>

source

fn read_into(&self, pos: usize, buf: &mut [u8]) -> Result<()>

source

fn read_range_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>

source

fn len(&self) -> usize

source

fn loaded_from_disk(&self) -> bool

source

fn is_empty(&self) -> bool

source

fn push(&mut self, el: E) -> Result<()>

Provided Methods§

source

fn reinit(&mut self) -> Result<()>

source

fn last(&self) -> Result<E>

source

fn sync(&self) -> Result<()>

source

fn build_small_tree<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, ) -> Result<E>

source

fn process_layer<A: Algorithm<E>, U: Unsigned>( &mut self, width: usize, level: usize, read_start: usize, write_start: usize, ) -> Result<()>

source

fn build<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, _config: Option<StoreConfig>, ) -> Result<E>

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<E: Element> Store<E> for DiskStore<E>

source§

impl<E: Element> Store<E> for MmapStore<E>

source§

impl<E: Element> Store<E> for VecStore<E>

source§

impl<E: Element, R: Read + Send + Sync> Store<E> for LevelCacheStore<E, R>