pub trait CellImpl {
    // Required methods
    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) -> &CellHash;
    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>;
}
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 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) -> &CellHash

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.

Implementations§

source§

impl dyn CellImpl + Sync + Send + 'static

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) -> &CellHash

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) -> CellSlice<'_>

Returns this cell as a cell slice.

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 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 AsRef<dyn CellImpl + Sync + Send + 'static> for Cell

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 + 'static> for Cell

source§

fn borrow(&self) -> &DynCell

Immutably borrows from an owned value. Read more
source§

impl PartialEq<dyn CellImpl + Sync + Send + 'static> for DynCell

source§

fn eq(&self, other: &DynCell) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryAsMut<dyn CellImpl + Sync + Send + 'static> 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§