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: &dyn CellContext,
) -> Result<Cell, Error>where
T: Store,
pub fn build_from_ext<T>(
data: T,
context: &dyn CellContext,
) -> Result<Cell, Error>where
T: Store,
Builds a new cell from the specified data using the provided cell context.
Sourcepub fn build_library<T: AsRef<[u8; 32]>>(hash: &T) -> Cell
pub fn build_library<T: AsRef<[u8; 32]>>(hash: &T) -> Cell
Builds a new library cell referencing the specified library.
Uses the default cell context.
Sourcepub fn build_library_ext<T: AsRef<[u8; 32]>>(
hash: &T,
context: &dyn CellContext,
) -> Cell
pub fn build_library_ext<T: AsRef<[u8; 32]>>( hash: &T, context: &dyn CellContext, ) -> Cell
Builds a new library cell referencing the specified library.
Uses the specified 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 from_parts(
is_exotic: bool,
data: CellDataBuilder,
refs: CellRefsBuilder,
) -> Self
pub fn from_parts( is_exotic: bool, data: CellDataBuilder, refs: CellRefsBuilder, ) -> Self
Creates a cell builder from its inner parts.
Sourcepub fn into_parts(self) -> (bool, CellDataBuilder, CellRefsBuilder)
pub fn into_parts(self) -> (bool, CellDataBuilder, CellRefsBuilder)
Splits cell builder into its inner parts.
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_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 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.
Methods from Deref<Target = CellDataBuilder>§
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 display_data(&self) -> DisplayCellBuilderData<'_>
pub fn display_data(&self) -> DisplayCellBuilderData<'_>
Returns an object which will display data as a bitstring with a termination bit.
Sourcepub fn as_bitstring(&self) -> Bitstring<'_>
pub fn as_bitstring(&self) -> Bitstring<'_>
Returns cell data as a Bitstring
.
Sourcepub fn spare_capacity_bits(&self) -> u16
pub fn spare_capacity_bits(&self) -> u16
Returns remaining data capacity in bits.
Sourcepub fn has_capacity_bits(&self, bits: u16) -> bool
pub fn has_capacity_bits(&self, bits: u16) -> bool
Returns true if there is enough remaining capacity to fit bits
.
Sourcepub fn clear_bits(&mut self)
pub fn clear_bits(&mut self)
Clears all data bits and sets the size in bits to 0.
Sourcepub fn rewind_bits(&mut self, bits: u16) -> Result<(), Error>
pub fn rewind_bits(&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_bigint(
&mut self,
x: &BigInt,
bits: u16,
signed: bool,
) -> Result<(), Error>
pub fn store_bigint( &mut self, x: &BigInt, bits: u16, signed: bool, ) -> Result<(), Error>
Stores bits
-width [BigInt
] to the builder.
Sourcepub fn store_bigint_truncate(
&mut self,
x: &BigInt,
bits: u16,
signed: bool,
) -> Result<(), Error>
pub fn store_bigint_truncate( &mut self, x: &BigInt, bits: u16, signed: bool, ) -> Result<(), Error>
Stores bits
-width [BigInt
] to the builder.
x
bit size is ignored and only low bits
of it are written.
Sourcepub fn store_biguint(
&mut self,
x: &BigUint,
bits: u16,
signed: bool,
) -> Result<(), Error>
pub fn store_biguint( &mut self, x: &BigUint, bits: u16, signed: bool, ) -> Result<(), Error>
Stores bits
-width [BigUint
] to the builder.
Sourcepub fn store_biguint_truncate(
&mut self,
x: &BigUint,
bits: u16,
) -> Result<(), Error>
pub fn store_biguint_truncate( &mut self, x: &BigUint, bits: u16, ) -> Result<(), Error>
Stores bits
-width [BigUint
] to the builder.
x
bit size is ignored and only low bits
of it are written.
Sourcepub fn store_var_bigint(
&mut self,
x: &BigInt,
len_bits: u16,
signed: bool,
) -> Result<(), Error>
pub fn store_var_bigint( &mut self, x: &BigInt, len_bits: u16, signed: bool, ) -> Result<(), Error>
Loads variable length [BigInt
] to the builder.
Sourcepub fn store_var_biguint(
&mut self,
x: &BigUint,
len_bits: u16,
) -> Result<(), Error>
pub fn store_var_biguint( &mut self, x: &BigUint, len_bits: u16, ) -> Result<(), Error>
Loads variable length [BigInt
] to the builder.
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.
Trait Implementations§
Source§impl AsMut<CellDataBuilder> for CellBuilder
impl AsMut<CellDataBuilder> for CellBuilder
Source§fn as_mut(&mut self) -> &mut CellDataBuilder
fn as_mut(&mut self) -> &mut CellDataBuilder
Source§impl AsRef<CellDataBuilder> for CellBuilder
impl AsRef<CellDataBuilder> for CellBuilder
Source§fn as_ref(&self) -> &CellDataBuilder
fn as_ref(&self) -> &CellDataBuilder
Source§impl Clone for CellBuilder
impl Clone for CellBuilder
Source§fn clone(&self) -> CellBuilder
fn clone(&self) -> CellBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CellBuilder
impl Debug for CellBuilder
Source§impl Default for CellBuilder
impl Default for CellBuilder
Source§fn default() -> CellBuilder
fn default() -> CellBuilder
Source§impl Deref for CellBuilder
impl Deref for CellBuilder
Source§impl DerefMut for CellBuilder
impl DerefMut for CellBuilder
Source§impl From<CellDataBuilder> for CellBuilder
impl From<CellDataBuilder> for CellBuilder
Source§fn from(inner: CellDataBuilder) -> Self
fn from(inner: CellDataBuilder) -> Self
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
Source§impl Store for CellBuilder
impl Store for CellBuilder
Source§fn store_into(
&self,
builder: &mut CellBuilder,
_: &dyn CellContext,
) -> Result<(), Error>
fn store_into( &self, builder: &mut CellBuilder, _: &dyn CellContext, ) -> Result<(), Error>
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.