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§
Sourcefn descriptor(&self) -> CellDescriptor
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
Sourcefn reference_cloned(&self, index: u8) -> Option<Cell>
fn reference_cloned(&self, index: u8) -> Option<Cell>
Returns the Nth child cell.
Sourcefn virtualize(&self) -> &DynCell
fn virtualize(&self) -> &DynCell
Returns this cell as a virtualized cell, so that all hashes and depths will have an offset.
Sourcefn hash(&self, level: u8) -> &HashBytes
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.
Sourcefn take_first_child(&mut self) -> Option<Cell>
fn take_first_child(&mut self) -> Option<Cell>
Consumes the first child during the deep drop.
Sourcefn replace_first_child(&mut self, parent: Cell) -> Result<Cell, Cell>
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.
Sourcefn take_next_child(&mut self) -> Option<Cell>
fn take_next_child(&mut self) -> Option<Cell>
Consumes the next child (except first) during the deep drop.
Sourcefn stats(&self) -> CellTreeStats
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 + Send + Sync
impl dyn CellImpl + Send + Sync
Sourcepub fn level_mask(&self) -> LevelMask
pub fn level_mask(&self) -> LevelMask
Computes the level mask from the descriptor bytes.
Sourcepub fn reference_count(&self) -> u8
pub fn reference_count(&self) -> u8
Computes the number of child cells from descriptor bytes.
Sourcepub fn get_reference_as_slice(&self, index: u8) -> Result<CellSlice<'_>, Error>
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.
Sourcepub fn repr_depth(&self) -> u16
pub fn repr_depth(&self) -> u16
Returns a representation depth of the cell.
Sourcepub fn references(&self) -> RefsIter<'_> ⓘ
pub fn references(&self) -> RefsIter<'_> ⓘ
Creates an iterator through child nodes.
Sourcepub fn as_slice(&self) -> Result<CellSlice<'_>, Error>
pub fn as_slice(&self) -> Result<CellSlice<'_>, Error>
Returns this cell as a cell slice. Returns an error if the cell is pruned.
Sourcepub unsafe fn as_slice_unchecked(&self) -> CellSlice<'_>
pub unsafe fn as_slice_unchecked(&self) -> CellSlice<'_>
Sourcepub fn compute_unique_stats(&self, limit: usize) -> Option<CellTreeStats>
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.
Sourcepub fn debug_root(&self) -> DebugCell<'_>
pub fn debug_root(&self) -> DebugCell<'_>
Returns an object that implements Debug
for printing only
the root cell of the cell tree.
Sourcepub fn display_root(&self) -> DisplayCellRoot<'_>
pub fn display_root(&self) -> DisplayCellRoot<'_>
Returns an object that implements Display
for printing only
the root cell of the cell tree.
Sourcepub fn display_tree(&self) -> DisplayCellTree<'_>
pub fn display_tree(&self) -> DisplayCellTree<'_>
Returns an object that implements Display
for printing all
cells in the cell tree.
Sourcepub fn display_data(&self) -> impl Display + Binary + '_
pub fn display_data(&self) -> impl Display + Binary + '_
Returns an object which will display cell data as a bitstring with a termination bit.