Struct merkletree::store::LevelCacheStore
source · pub struct LevelCacheStore<E: Element, R: Read + Send + Sync> { /* private fields */ }
Expand description
The LevelCacheStore is used to reduce the on-disk footprint even further to the minimum at the cost of build time performance. Each LevelCacheStore is created with a StoreConfig object which contains the number of binary tree levels above the base that are ‘cached’. This implementation has hard requirements about the on disk file size based on that number of levels, so on-disk files are tied, structurally to the configuration they were built with and can only be accessed with the same number of levels.
Implementations§
source§impl<E: Element, R: Read + Send + Sync> LevelCacheStore<E, R>
impl<E: Element, R: Read + Send + Sync> LevelCacheStore<E, R>
sourcepub fn new_from_disk_with_reader(
store_range: usize,
branches: usize,
config: &StoreConfig,
reader: ExternalReader<R>,
) -> Result<Self>
pub fn new_from_disk_with_reader( store_range: usize, branches: usize, config: &StoreConfig, reader: ExternalReader<R>, ) -> Result<Self>
Used for opening v2 compacted DiskStores.
pub fn set_external_reader(&mut self, reader: ExternalReader<R>) -> Result<()>
source§impl<E: Element, R: Read + Send + Sync> LevelCacheStore<E, R>
impl<E: Element, R: Read + Send + Sync> LevelCacheStore<E, R>
pub fn set_len(&mut self, len: usize)
pub fn front_truncate(&mut self, config: &StoreConfig, len: usize) -> Result<()>
pub fn store_size(&self) -> usize
pub fn is_consistent_v1( store_range: usize, branches: usize, config: &StoreConfig, ) -> Result<bool>
pub fn is_consistent( store_range: usize, branches: usize, config: &StoreConfig, ) -> Result<bool>
pub fn store_read_range(&self, start: usize, end: usize) -> Result<Vec<u8>>
pub fn store_read_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>
pub fn store_copy_from_slice( &mut self, start: usize, slice: &[u8], ) -> Result<()>
Trait Implementations§
source§impl<E: Element, R: Read + Send + Sync> Store<E> for LevelCacheStore<E, R>
impl<E: Element, R: Read + Send + Sync> Store<E> for LevelCacheStore<E, R>
source§fn 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>
source§fn new_from_disk(
store_range: usize,
branches: usize,
config: &StoreConfig,
) -> Result<Self>
fn new_from_disk( store_range: 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 read_at(&self, index: usize) -> Result<E>
fn read_into(&self, index: usize, buf: &mut [u8]) -> Result<()>
fn read_range_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>
fn read_range(&self, r: Range<usize>) -> Result<Vec<E>>
fn len(&self) -> usize
fn loaded_from_disk(&self) -> bool
fn compact( &mut self, _branches: usize, _config: StoreConfig, _store_version: u32, ) -> Result<bool>
fn delete(config: StoreConfig) -> Result<()>
fn is_empty(&self) -> bool
fn push(&mut self, el: E) -> Result<()>
fn sync(&self) -> Result<()>
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>
fn reinit(&mut self) -> Result<()>
fn last(&self) -> Result<E>
fn build_small_tree<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, ) -> Result<E>
Auto Trait Implementations§
impl<E, R> Freeze for LevelCacheStore<E, R>where
R: Freeze,
impl<E, R> RefUnwindSafe for LevelCacheStore<E, R>where
E: RefUnwindSafe,
R: RefUnwindSafe,
impl<E, R> Send for LevelCacheStore<E, R>
impl<E, R> Sync for LevelCacheStore<E, R>
impl<E, R> Unpin for LevelCacheStore<E, R>
impl<E, R> UnwindSafe for LevelCacheStore<E, R>where
E: UnwindSafe,
R: UnwindSafe,
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more