pub trait Cell<C: CellFamily> {
    // Required methods
    fn descriptor(&self) -> CellDescriptor;
    fn data(&self) -> &[u8] ;
    fn bit_len(&self) -> u16;
    fn reference(&self, index: u8) -> Option<&dyn Cell<C>>;
    fn reference_cloned(&self, index: u8) -> Option<CellContainer<C>>;
    fn virtualize(&self) -> &dyn Cell<C>;
    fn hash(&self, level: u8) -> &CellHash;
    fn depth(&self, level: u8) -> u16;
    fn take_first_child(&mut self) -> Option<CellContainer<C>>;
    fn replace_first_child(
        &mut self,
        parent: CellContainer<C>
    ) -> Result<CellContainer<C>, CellContainer<C>>;
    fn take_next_child(&mut self) -> Option<CellContainer<C>>;
}
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<&dyn Cell<C>>

Returns a reference to the Nth child cell.

source

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

Returns the Nth child cell.

source

fn virtualize(&self) -> &dyn Cell<C>

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<CellContainer<C>>

Consumes the first child during the deep drop.

source

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

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<CellContainer<C>>

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

Implementations§

source§

impl<C: CellFamily> dyn Cell<C> + '_

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<'_, C>, 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<'_, C>

Creates an iterator through child nodes.

source

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

Returns this cell as a cell slice.

source

pub fn debug_root(&self) -> DebugCell<'_, C>

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

source

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

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

source

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

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

source

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

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<C: CellFamily> Debug for dyn Cell<C> + '_

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, C: CellFamily> Load<'a, C> for &'a dyn Cell<C>

source§

fn load_from(slice: &mut CellSlice<'a, C>) -> Option<Self>

Tries to load itself from a cell slice.
source§

impl<C1: CellFamily, C2: CellFamily> PartialEq<dyn Cell<C2>> for dyn Cell<C1> + '_

source§

fn eq(&self, other: &dyn Cell<C2>) -> 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<C: CellFamily> Serialize for dyn Cell<C> + '_

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl<C: CellFamily> Eq for dyn Cell<C> + '_

Implementors§