Skip to main content

CellImpl

Trait CellImpl 

Source
pub trait CellImpl {
Show 13 methods // Required methods fn untrack(self: CellInner<Self>) -> Cell; fn descriptor(&self) -> CellDescriptor; fn data(&self) -> &[u8] ; fn bit_len(&self) -> u16; fn reference(&self, index: u8) -> Option<&DynCell>; fn reference_cloned(&self, index: u8) -> Option<Cell>; fn virtualize(&self) -> &DynCell; fn hash(&self, level: u8) -> &HashBytes; fn depth(&self, level: u8) -> u16; fn take_first_child(&mut self) -> Option<Cell>; fn replace_first_child(&mut self, parent: Cell) -> Result<Cell, Cell>; fn take_next_child(&mut self) -> Option<Cell>; fn stats(&self) -> CellTreeStats;
}
Expand description

Represents the interface of a well-formed cell.

Since all basic operations are implements via dynamic dispatch, all high-level helper methods are implemented for dyn Cell.

Required Methods§

Source

fn untrack(self: CellInner<Self>) -> Cell

Unwraps the root cell from the usage tracking.

Source

fn descriptor(&self) -> CellDescriptor

Returns cell descriptor.

§See also

Cell descriptor contains some tightly packed info about the cell. If you want convenient methods to access it use: cell_type, level_mask, reference_count, is_exotic

Source

fn data(&self) -> &[u8]

Returns the raw data of this cell.

Source

fn bit_len(&self) -> u16

Returns the data size of this cell in bits.

Source

fn reference(&self, index: u8) -> Option<&DynCell>

Returns a reference to the Nth child cell.

Source

fn reference_cloned(&self, index: u8) -> Option<Cell>

Returns the Nth child cell.

Source

fn virtualize(&self) -> &DynCell

Returns this cell as a virtualized cell, so that all hashes and depths will have an offset.

Source

fn hash(&self, level: u8) -> &HashBytes

Returns cell hash for the specified level.

Cell representation hash is the hash at the maximum level (LevelMask::MAX_LEVEL). Use repr_hash as a simple alias for this.

Source

fn depth(&self, level: u8) -> u16

Returns cell depth for the specified level.

Source

fn take_first_child(&mut self) -> Option<Cell>

Consumes the first child during the deep drop.

Source

fn replace_first_child(&mut self, parent: Cell) -> Result<Cell, Cell>

Replaces the first child with the provided parent during the deep drop.

Returns Ok(child) if child was successfully replaced, Err(parent) otherwise.

Source

fn take_next_child(&mut self) -> Option<Cell>

Consumes the next child (except first) during the deep drop.

Source

fn stats(&self) -> CellTreeStats

Returns the sum of all bits and cells of all elements in the cell tree (including this cell).

NOTE: identical cells are counted each time they occur in the tree.

Implementations§

Source§

impl dyn CellImpl + Sync + Send

Source

pub fn cell_type(&self) -> CellType

Computes cell type from descriptor bytes.

Source

pub fn level(&self) -> u8

Computes the cell level from the level mask.

Source

pub fn level_mask(&self) -> LevelMask

Computes the level mask from the descriptor bytes.

Source

pub fn reference_count(&self) -> u8

Computes the number of child cells from descriptor bytes.

Source

pub fn get_reference_as_slice(&self, index: u8) -> Result<CellSlice<'_>, Error>

Tries to load the specified child cell as slice. Returns an error if the loaded cell is absent or is pruned.

Source

pub fn is_exotic(&self) -> bool

Returns whether the cell is not Ordinary.

Source

pub fn repr_hash(&self) -> &HashBytes

Returns a representation hash of the cell.

Source

pub fn repr_depth(&self) -> u16

Returns a representation depth of the cell.

Source

pub fn is_empty(&self) -> bool

Returns true if the cell is empty (no bits, no refs).

Source

pub fn references(&self) -> RefsIter<'_>

Creates an iterator through child nodes.

Source

pub fn as_slice(&self) -> Result<CellSlice<'_>, Error>

Returns this cell as a cell slice. Returns an error if the cell is pruned.

Source

pub unsafe fn as_slice_unchecked(&self) -> CellSlice<'_>

Returns this cell as a cell slice.

§Safety

The following must be true:

  • cell is not pruned
Source

pub fn compute_unique_stats(&self, 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 debug_root(&self) -> DebugCell<'_>

Returns an object that implements Debug for printing only the root cell of the cell tree.

Source

pub fn display_root(&self) -> DisplayCellRoot<'_>

Returns an object that implements Display for printing only the root cell of the cell tree.

Source

pub fn display_tree(&self) -> DisplayCellTree<'_>

Returns an object that implements Display for printing all cells in the cell tree.

Source

pub fn display_data(&self) -> impl Display + Binary + '_

Returns an object which will display cell data as a bitstring with a termination bit.

Source

pub fn parse<'a, T: Load<'a>>(&'a self) -> Result<T, Error>

Converts this cell into a slice and tries to load the specified type from it.

NOTE: parsing Cell will load the first reference!

Trait Implementations§

Source§

impl AsMut<dyn CellImpl + Sync + Send> for DynCell

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<dyn CellImpl + Sync + Send> for Cell

Source§

fn as_ref(&self) -> &DynCell

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn CellImpl + Sync + Send> for DynCell

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> AsRef<dyn CellImpl + Sync + Send> for Lazy<T>

Source§

fn as_ref(&self) -> &DynCell

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<dyn CellImpl + Sync + Send> for Cell

Source§

fn borrow(&self) -> &DynCell

Immutably borrows from an owned value. Read more
Source§

impl TryAsMut<dyn CellImpl + Sync + Send> for Cell

Source§

fn try_as_mut(&mut self) -> Option<&mut DynCell>

Tries to convert this type into a mutable reference of the (usually inferred) input type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CellImpl for StaticCell

Source§

impl<T, const L: u8> CellImpl for VirtualCellWrapper<T, L>
where T: CellImpl + 'static + Send + Sync,