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§
sourcefn new_with_config(
size: usize,
branches: usize,
config: StoreConfig,
) -> Result<Self>
fn new_with_config( size: usize, branches: usize, config: StoreConfig, ) -> Result<Self>
Creates a new store which can store up to size
elements.
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>
sourcefn new_from_disk(
size: usize,
branches: usize,
config: &StoreConfig,
) -> Result<Self>
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
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>
Object Safety§
This trait is not object safe.