Struct StorageStat

Source
pub struct StorageStat<'a> { /* private fields */ }
Expand description

A helper to track the size of the unique data in multiple cell trees.

NOTE: It uses hashes for deduplication, so you can only use it for fully computed and valid trees.

Implementations§

Source§

impl<'a> StorageStat<'a>

Source

pub fn compute_for_slice<'b: 'a>( slice: &'a CellSlice<'b>, limit: usize, ) -> Option<CellTreeStats>

Recursively computes the count of distinct cells returning the total storage used by this dag taking into account the identification of equal cells.

Root slice does not count as cell. A slice subrange of cells is used during computation.

Source

pub fn compute_for_cell( cell: &'a DynCell, limit: usize, ) -> Option<CellTreeStats>

Recursively computes the count of distinct cells returning the total storage used by this dag taking into account the identification of equal cells.

Source

pub fn with_limit(limit: usize) -> Self

Creates a new storage stat state with an explicit limit.

Source

pub fn unlimited() -> Self

Creates a new storage stat state without a limit.

Source

pub fn stats(&self) -> CellTreeStats

Returns the current tree stats.

Source

pub fn add_cell(&mut self, cell: &'a DynCell) -> bool

Merges current stats with the stats from the provided cell tree.

Returns false if the limit was reached.

Source

pub fn add_slice(&mut self, slice: &CellSlice<'a>) -> bool

Merges current stats with the stats from the provided slice.

Returns false if the limit was reached.

Auto Trait Implementations§

§

impl<'a> Freeze for StorageStat<'a>

§

impl<'a> !RefUnwindSafe for StorageStat<'a>

§

impl<'a> Send for StorageStat<'a>

§

impl<'a> Sync for StorageStat<'a>

§

impl<'a> Unpin for StorageStat<'a>

§

impl<'a> !UnwindSafe for StorageStat<'a>

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> EquivalentRepr<T> for T