pub struct CellBuilder<C: CellFamily> { /* private fields */ }
Expand description

Builder for constructing cells with densely packed data.

Implementations§

source§

impl<C: CellFamily> CellBuilder<C>

source

pub fn new() -> Self

Creates an empty cell builder.

source

pub fn from_raw_data(value: &[u8], bits: u16) -> Option<Self>

Tries to create a cell builder with the specified data.

NOTE: if bits is greater than bytes * 8, pads the value with zeros (as high bits).

source

pub fn raw_data(&self) -> &[u8; 128]

Returns an underlying cell data.

source

pub fn bit_len(&self) -> u16

Returns the data size of this cell in bits.

source

pub fn spare_bits_capacity(&self) -> u16

Returns remaining data capacity in bits.

source

pub fn spare_refs_capacity(&self) -> u8

Returns remaining references capacity.

source

pub fn has_capacity(&self, bits: u16, refs: u8) -> bool

Returns true if there is enough remaining capacity to fit bits and refs.

source

pub fn with_level_mask(self, level_mask: LevelMask) -> Self

Explicitly sets the level mask.

source

pub fn set_level_mask(&mut self, level_mask: LevelMask)

Explicitly sets the level mask.

source

pub fn set_exotic(&mut self, is_exotic: bool)

Marks this cell as exotic.

source

pub fn store_zeros(&mut self, bits: u16) -> bool

Tries to store the specified number of zero bits in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_bit_zero(&mut self) -> bool

Tries to store one zero bit in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_bit_one(&mut self) -> bool

Tries to store one non-zero bit in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_bit(&mut self, value: bool) -> bool

Tries to store one bit in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_u8(&mut self, value: u8) -> bool

Tries to store u8 in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_u16(&mut self, value: u16) -> bool

Tries to store u16 in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_u32(&mut self, value: u32) -> bool

Tries to store u32 in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_u64(&mut self, value: u64) -> bool

Tries to store u64 in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_u128(&mut self, value: u128) -> bool

Tries to store u128 in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_u256(&mut self, value: &[u8; 32]) -> bool

Tries to store 32 bytes in the cell, returning false if there is not enough remaining capacity.

source

pub fn store_small_uint(&mut self, value: u8, bits: u16) -> bool

Tries to store u8 in the cell (but only the specified number of bits), returning false if there is not enough remaining capacity.

NOTE: if bits is greater than 8, pads the value with zeros (as high bits).

source

pub fn store_uint(&mut self, value: u64, bits: u16) -> bool

Tries to store u64 in the cell (but only the specified number of bits), returning false if there is not enough remaining capacity.

NOTE: if bits is greater than 64, pads the value with zeros (as high bits).

source

pub fn store_raw(&mut self, value: &[u8], bits: u16) -> bool

Tries to store bytes in the cell (but only the specified number of bits), returning false if there is not enough remaining capacity.

NOTE: if bits is greater than bytes * 8, pads the value with zeros (as high bits).

source

pub fn store_cell_data<'a, T, C1: CellFamily>(&mut self, value: T) -> boolwhere T: Borrow<dyn Cell<C1> + 'a>,

Tries to store all data bits of the specified cell in the current cell, returning false if there is not enough remaining capacity.

source

pub fn store_slice_data<'a, T, C1>(&mut self, value: T) -> boolwhere T: Borrow<CellSlice<'a, C1>>, C1: CellFamily + 'a,

Tries to store the remaining slice data in the cell, returning false if there is not enough remaining capacity.

source

pub fn prepend_raw(&mut self, value: &[u8], bits: u16) -> bool

Tries to prepend bytes to the cell data (but only the specified number of bits), returning false if there is not enough capacity.

NOTE: if bits is greater than bytes * 8, pads the value with zeros (as high bits).

source§

impl<C: CellFamily> CellBuilder<C>

source

pub fn compute_level(&self) -> u8

Computes the cell level from the level mask.

source

pub fn compute_level_mask(&self) -> LevelMask

Computes the cell level mask from children.

source

pub fn references(&self) -> &[CellContainer<C>]

Returns a slice of the child cells stored in the builder.

source

pub fn store_reference(&mut self, cell: CellContainer<C>) -> bool

Tries to store a child in the cell, returning false if there is not enough remaining capacity.

source

pub fn set_references(&mut self, refs: CellRefsBuilder<C>)

Sets children of the cell.

source

pub fn store_builder(&mut self, builder: &Self) -> bool

Tries to append a builder (its data and references), returning false if there is not enough remaining capacity.

source

pub fn store_slice<'a, T>(&mut self, value: T) -> boolwhere T: Borrow<CellSlice<'a, C>>, C: 'a,

Tries to append a cell slice (its data and references), returning false if there is not enough remaining capacity.

source

pub fn build_ext( self, finalizer: &mut dyn Finalizer<C> ) -> Option<CellContainer<C>>

Tries to build a new cell using the specified finalizer.

source§

impl<C> CellBuilder<C>where for<'c> C: DefaultFinalizer + 'c,

source

pub fn build(self) -> Option<CellContainer<C>>

Tries to build a new cell using the default finalizer.

See default_finalizer

Trait Implementations§

source§

impl<C: CellFamily> Clone for CellBuilder<C>where CellContainer<C>: Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C: CellFamily> Default for CellBuilder<C>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for CellBuilder<C>where <C as CellFamily>::Container: RefUnwindSafe,

§

impl<C> Send for CellBuilder<C>where <C as CellFamily>::Container: Send,

§

impl<C> Sync for CellBuilder<C>where <C as CellFamily>::Container: Sync,

§

impl<C> Unpin for CellBuilder<C>where <C as CellFamily>::Container: Unpin,

§

impl<C> UnwindSafe for CellBuilder<C>where <C as CellFamily>::Container: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.