pub trait TonCellNum:
Display
+ Sized
+ Clone
+ Zero
+ PartialOrd {
// Required methods
fn tcn_write_bits(
&self,
writer: &mut CellBuilder,
bits_len: usize,
) -> TonCoreResult<()>;
fn tcn_read_bits(
reader: &mut CellParser<'_>,
bits_len: usize,
) -> TonCoreResult<Self>;
fn tcn_min_bits_len(&self) -> usize;
}Expand description
Allows generic read/write operation for any numeric type Implemented for: All primitives types (i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize) Fastnum types (I/U128, I/U256, I/U512, I/U1024) BigNum types: BigInt/BigUint
Caller (CellBuilder) provides the following guarantees:
- bits_len != 0 (CellBuilder & CellParser handle zero bits itself)
- bits_len >= tcn_min_bits_len()
Caller (CellParser) provides the following guarantees:
- bits_len != 0 (CellBuilder & CellParser handle zero bits_len itself)
Required Methods§
fn tcn_write_bits( &self, writer: &mut CellBuilder, bits_len: usize, ) -> TonCoreResult<()>
fn tcn_read_bits( reader: &mut CellParser<'_>, bits_len: usize, ) -> TonCoreResult<Self>
fn tcn_min_bits_len(&self) -> usize
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl TonCellNum for BigInt
impl TonCellNum for BigInt
fn tcn_write_bits( &self, writer: &mut CellBuilder, bits_len: usize, ) -> Result<(), TonCoreError>
fn tcn_read_bits( reader: &mut CellParser<'_>, bits_len: usize, ) -> Result<Self, TonCoreError>
fn tcn_min_bits_len(&self) -> usize
Source§impl TonCellNum for BigUint
Slow implementation uses U/I1024 to support bignum
If you use bignum, you likely don’t care about performance that much
impl TonCellNum for BigUint
Slow implementation uses U/I1024 to support bignum If you use bignum, you likely don’t care about performance that much