pub struct Lazy<T, const EXOTIC: bool = false> { /* private fields */ }Expand description
Lazy-loaded model.
Implementations§
Source§impl<T, const EXOTIC: bool> Lazy<T, EXOTIC>
impl<T, const EXOTIC: bool> Lazy<T, EXOTIC>
Sourcepub unsafe fn from_raw_unchecked(cell: Cell) -> Self
pub unsafe fn from_raw_unchecked(cell: Cell) -> Self
Wraps the cell in a typed wrapper.
§Safety
The cell is_exotic flag must be in sync with EXOTIC type param.
Sourcepub fn into_inner(self) -> Cell
pub fn into_inner(self) -> Cell
Converts into the underlying cell.
Sourcepub fn cast_into<Q>(self) -> Lazy<Q, EXOTIC>where
Q: EquivalentRepr<T>,
pub fn cast_into<Q>(self) -> Lazy<Q, EXOTIC>where
Q: EquivalentRepr<T>,
Converts into a lazy loader for an equivalent type.
Sourcepub fn cast_ref<Q>(&self) -> &Lazy<Q, EXOTIC>where
Q: EquivalentRepr<T>,
pub fn cast_ref<Q>(&self) -> &Lazy<Q, EXOTIC>where
Q: EquivalentRepr<T>,
Casts itself into a lazy loaded for an equivalent type.
Sourcepub fn serialize_repr_hash<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
pub fn serialize_repr_hash<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
Serializes only the root hash of the cell.
Methods from Deref<Target = DynCell>§
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 has_max_depth(&self) -> bool
pub fn has_max_depth(&self) -> bool
Returns true if any of cell levels has the maximum depth.
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 not ordinary.
Sourcepub fn as_slice_allow_exotic(&self) -> CellSlice<'_>
pub fn as_slice_allow_exotic(&self) -> CellSlice<'_>
Returns this cell as a cell slice.
Loads cell as is.
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 touch_recursive(&self)
pub fn touch_recursive(&self)
Recursively traverses the cells tree without tracking a uniqueness of cells. Usefull for adding small subtrees to merkle proofs.
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.
Sourcepub fn parse<'a, T: Load<'a>>(&'a self) -> Result<T, Error>
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!
Sourcepub fn parse_exotic<'a, T: LoadCell<'a>>(&'a self) -> Result<T, Error>
pub fn parse_exotic<'a, T: LoadCell<'a>>(&'a self) -> Result<T, Error>
Loads an exotic cell.
Trait Implementations§
Source§impl<'de, T, const EXOTIC: bool> Deserialize<'de> for Lazy<T, EXOTIC>where
T: Deserialize<'de> + Store,
impl<'de, T, const EXOTIC: bool> Deserialize<'de> for Lazy<T, EXOTIC>where
T: Deserialize<'de> + Store,
Source§fn deserialize<D>(deserializer: D) -> Result<Lazy<T, EXOTIC>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Lazy<T, EXOTIC>, D::Error>where
D: Deserializer<'de>,
Source§impl<T, const EXOTIC: bool> ExactSize for Lazy<T, EXOTIC>
impl<T, const EXOTIC: bool> ExactSize for Lazy<T, EXOTIC>
Source§fn exact_size(&self) -> Size
fn exact_size(&self) -> Size
Source§impl<T, const EXOTIC: bool> Store for Lazy<T, EXOTIC>
impl<T, const EXOTIC: bool> Store for Lazy<T, EXOTIC>
Source§fn store_into(
&self,
builder: &mut CellBuilder,
_: &dyn CellContext,
) -> Result<(), Error>
fn store_into( &self, builder: &mut CellBuilder, _: &dyn CellContext, ) -> Result<(), Error>
Source§impl<T: WithAbiType> WithAbiType for Lazy<T>
impl<T: WithAbiType> WithAbiType for Lazy<T>
impl<T, const EXOTIC: bool> Eq for Lazy<T, EXOTIC>
Auto Trait Implementations§
impl<T, const EXOTIC: bool> Freeze for Lazy<T, EXOTIC>
impl<T, const EXOTIC: bool = false> !RefUnwindSafe for Lazy<T, EXOTIC>
impl<T, const EXOTIC: bool> Send for Lazy<T, EXOTIC>where
T: Send,
impl<T, const EXOTIC: bool> Sync for Lazy<T, EXOTIC>where
T: Sync,
impl<T, const EXOTIC: bool> Unpin for Lazy<T, EXOTIC>where
T: Unpin,
impl<T, const EXOTIC: bool = false> !UnwindSafe for Lazy<T, EXOTIC>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self to key and returns true if they are equal.