pub struct CellBuilder { /* private fields */ }
Expand description
Builder for constructing cells with densely packed data.
Implementations§
Source§impl CellBuilder
impl CellBuilder
Sourcepub fn build_from<T>(data: T) -> Result<Cell, Error>where
T: Store,
pub fn build_from<T>(data: T) -> Result<Cell, Error>where
T: Store,
Builds a new cell from the specified data using the default cell context.
Sourcepub fn build_from_ext<T>(
data: T,
context: &mut dyn CellContext,
) -> Result<Cell, Error>where
T: Store,
pub fn build_from_ext<T>(
data: T,
context: &mut dyn CellContext,
) -> Result<Cell, Error>where
T: Store,
Builds a new cell from the specified data using the provided cell context.
Sourcepub fn from_raw_data(value: &[u8], bits: u16) -> Result<Self, Error>
pub fn from_raw_data(value: &[u8], bits: u16) -> Result<Self, Error>
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).
Sourcepub fn as_data_slice(&self) -> CellSlice<'_>
pub fn as_data_slice(&self) -> CellSlice<'_>
Returns a slice which contains only builder data bits and no references.
NOTE: intermediate cell hash is undefined.
Sourcepub fn as_full_slice(&self) -> CellSlice<'_>
pub fn as_full_slice(&self) -> CellSlice<'_>
Returns a slice which contains builder data and references.
NOTE: intermediate cell hash is undefined.
Sourcepub const fn spare_capacity(&self) -> Size
pub const fn spare_capacity(&self) -> Size
Returns the remaining capacity in bits and references.
Sourcepub const fn spare_capacity_bits(&self) -> u16
pub const fn spare_capacity_bits(&self) -> u16
Returns remaining data capacity in bits.
Sourcepub const fn spare_capacity_refs(&self) -> u8
pub const fn spare_capacity_refs(&self) -> u8
Returns remaining references capacity.
Sourcepub const fn has_capacity(&self, bits: u16, refs: u8) -> bool
pub const fn has_capacity(&self, bits: u16, refs: u8) -> bool
Returns true if there is enough remaining capacity to fit bits
and refs
.
Sourcepub fn set_exotic(&mut self, is_exotic: bool)
pub fn set_exotic(&mut self, is_exotic: bool)
Marks this cell as exotic.
Sourcepub fn rewind(&mut self, bits: u16) -> Result<(), Error>
pub fn rewind(&mut self, bits: u16) -> Result<(), Error>
Removes the specified amount of bits from the end of the data.
Sourcepub fn store_zeros(&mut self, bits: u16) -> Result<(), Error>
pub fn store_zeros(&mut self, bits: u16) -> Result<(), Error>
Tries to store the specified number of zero bits in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_ones(&mut self, bits: u16) -> Result<(), Error>
pub fn store_ones(&mut self, bits: u16) -> Result<(), Error>
Tries to store the specified number of set bits in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_bit_zero(&mut self) -> Result<(), Error>
pub fn store_bit_zero(&mut self) -> Result<(), Error>
Tries to store one zero bit in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_bit_one(&mut self) -> Result<(), Error>
pub fn store_bit_one(&mut self) -> Result<(), Error>
Tries to store one non-zero bit in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_bit(&mut self, value: bool) -> Result<(), Error>
pub fn store_bit(&mut self, value: bool) -> Result<(), Error>
Tries to store one bit in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_u8(&mut self, value: u8) -> Result<(), Error>
pub fn store_u8(&mut self, value: u8) -> Result<(), Error>
Tries to store u8
in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_u16(&mut self, value: u16) -> Result<(), Error>
pub fn store_u16(&mut self, value: u16) -> Result<(), Error>
Tries to store u16
in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_u32(&mut self, value: u32) -> Result<(), Error>
pub fn store_u32(&mut self, value: u32) -> Result<(), Error>
Tries to store u32
in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_u64(&mut self, value: u64) -> Result<(), Error>
pub fn store_u64(&mut self, value: u64) -> Result<(), Error>
Tries to store u64
in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_u128(&mut self, value: u128) -> Result<(), Error>
pub fn store_u128(&mut self, value: u128) -> Result<(), Error>
Tries to store u128
in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_u256<T>(&mut self, value: &T) -> Result<(), Error>
pub fn store_u256<T>(&mut self, value: &T) -> Result<(), Error>
Tries to store 32 bytes in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_small_uint(&mut self, value: u8, bits: u16) -> Result<(), Error>
pub fn store_small_uint(&mut self, value: u8, bits: u16) -> Result<(), Error>
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).
Sourcepub fn store_uint(&mut self, value: u64, bits: u16) -> Result<(), Error>
pub fn store_uint(&mut self, value: u64, bits: u16) -> Result<(), Error>
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).
Sourcepub fn store_raw(&mut self, value: &[u8], bits: u16) -> Result<(), Error>
pub fn store_raw(&mut self, value: &[u8], bits: u16) -> Result<(), Error>
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).
Sourcepub fn store_cell_data<T>(&mut self, value: T) -> Result<(), Error>
pub fn store_cell_data<T>(&mut self, value: T) -> Result<(), Error>
Tries to store all data bits of the specified cell in the current cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn store_slice_data<'a, T>(&mut self, value: T) -> Result<(), Error>
pub fn store_slice_data<'a, T>(&mut self, value: T) -> Result<(), Error>
Tries to store the remaining slice data in the cell,
returning false
if there is not enough remaining capacity.
Source§impl CellBuilder
impl CellBuilder
Sourcepub fn references(&self) -> &[Cell]
pub fn references(&self) -> &[Cell]
Returns a slice of the child cells stored in the builder.
Sourcepub fn store_reference(&mut self, cell: Cell) -> Result<(), Error>
pub fn store_reference(&mut self, cell: Cell) -> Result<(), Error>
Tries to store a child in the cell,
returning false
if there is not enough remaining capacity.
Sourcepub fn set_references(&mut self, refs: CellRefsBuilder)
pub fn set_references(&mut self, refs: CellRefsBuilder)
Sets children of the cell.
Sourcepub fn store_builder(&mut self, builder: &Self) -> Result<(), Error>
pub fn store_builder(&mut self, builder: &Self) -> Result<(), Error>
Tries to append a builder (its data and references),
returning false
if there is not enough remaining capacity.
Sourcepub fn store_slice<'a, T>(&mut self, value: T) -> Result<(), Error>
pub fn store_slice<'a, T>(&mut self, value: T) -> Result<(), Error>
Tries to append a cell slice (its data and references),
returning false
if there is not enough remaining capacity.
Sourcepub fn build_ext(self, context: &mut dyn CellContext) -> Result<Cell, Error>
pub fn build_ext(self, context: &mut dyn CellContext) -> Result<Cell, Error>
Tries to build a new cell using the specified cell context.
Sourcepub fn build(self) -> Result<Cell, Error>
pub fn build(self) -> Result<Cell, Error>
Tries to build a new cell using the default cell context.
See empty_context
Sourcepub fn display_data(&self) -> impl Display + Binary + '_
pub fn display_data(&self) -> impl Display + Binary + '_
Returns an object which will display data as a bitstring with a termination bit.
Trait Implementations§
Source§impl Clone for CellBuilder
impl Clone for CellBuilder
Source§impl Debug for CellBuilder
impl Debug for CellBuilder
Source§impl Default for CellBuilder
impl Default for CellBuilder
Source§impl Ord for CellBuilder
impl Ord for CellBuilder
Source§impl PartialEq for CellBuilder
impl PartialEq for CellBuilder
Source§impl PartialOrd for CellBuilder
impl PartialOrd for CellBuilder
impl Eq for CellBuilder
Auto Trait Implementations§
impl Freeze for CellBuilder
impl !RefUnwindSafe for CellBuilder
impl Send for CellBuilder
impl Sync for CellBuilder
impl Unpin for CellBuilder
impl !UnwindSafe for CellBuilder
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.