CellImpl

Trait CellImpl 

Source
pub trait CellImpl {
    // 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;
}
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.

Implementations§

Source§

impl dyn CellImpl + Send + Sync

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 has_max_depth(&self) -> bool

Returns true if any of cell levels has the maximum depth.

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 not ordinary.

Source

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

Returns this cell as a cell slice.

Loads cell as is.

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 touch_recursive(&self)

Recursively traverses the cells tree without tracking a uniqueness of cells. Usefull for adding small subtrees to merkle proofs.

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. Fails if the cell is not ordinary.

NOTE: parsing Cell will load the first reference!

Source

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

Loads an exotic cell.

Trait Implementations§

Source§

impl AsMut<dyn CellImpl + Send + Sync> 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 + Send + Sync> for Cell

Source§

fn as_ref(&self) -> &DynCell

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

impl<T, const EXOTIC: bool> AsRef<dyn CellImpl + Send + Sync> for Lazy<T, EXOTIC>

Source§

fn as_ref(&self) -> &DynCell

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

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

Source§

fn as_ref(&self) -> &Self

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

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

Source§

fn borrow(&self) -> &DynCell

Immutably borrows from an owned value. Read more
Source§

impl TryAsMut<dyn CellImpl + Send + Sync> 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.

Implementors§

Source§

impl CellImpl for StaticCell

Source§

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