Trait SupportedInt

Source
pub trait SupportedInt: Sealed {
    type Int: Sized + Copy + PartialOrd + Ord + Eq + Hash + Not + BitAnd + BitOr + BitXor + Add + Sub + Mul + Div + Rem + AddAssign + SubAssign + MulAssign + DivAssign + RemAssign + Debug + Display + LowerHex + UpperHex + Octal + Binary;
    type Uint: Sized + Copy + PartialOrd + Ord + Eq + Hash + Not + BitAnd + BitOr + BitXor + Add + Sub + Mul + Div + Rem + AddAssign + SubAssign + MulAssign + DivAssign + RemAssign + Debug + Display + LowerHex + UpperHex + Octal + Binary;

    const INT_NAME: &'static str;
    const UINT_NAME: &'static str;
    const BITS: usize;
    const SKIP_BYTES: usize;
    const BYTES: usize = _;
    const WORD_MSB: usize = _;

    // Required methods
    fn tokenize_int(int: Self::Int) -> WordToken;
    fn detokenize_int(token: WordToken) -> Self::Int;
    fn encode_packed_to_int(int: Self::Int, out: &mut Vec<u8>);
    fn tokenize_uint(uint: Self::Uint) -> WordToken;
    fn detokenize_uint(token: WordToken) -> Self::Uint;
    fn encode_packed_to_uint(uint: Self::Uint, out: &mut Vec<u8>);
}
Expand description

Statically guarantees that a Int or Uint bit count is marked as supported.

This trait is sealed: the list of implementors below is total.

Users do not have the ability to mark additional IntBitCount<N> values as supported. Only Int and Uint with supported byte counts are constructable.

Required Associated Constants§

Source

const INT_NAME: &'static str

The name of the Int type: int<N>

Source

const UINT_NAME: &'static str

The name of the Uint type: uint<N>

Source

const BITS: usize

The number of bits in the integer: BITS

Note that this is not equal to Self::Int::BITS.

Source

const SKIP_BYTES: usize

The difference between the representation’s and this integer’s bytes: (Self::Int::BITS - Self::BITS) / 8

E.g.: word[Self::WORD_MSB - Self::SKIP_BYTES..] == int.to_be_bytes()

Provided Associated Constants§

Source

const BYTES: usize = _

The number of bytes in the integer: BITS / 8

Source

const WORD_MSB: usize = _

The index of the most significant byte in the Word type.

E.g.: word[Self::WORD_MSB..] == int.to_be_bytes()[Self::SKIP_BYTES..]

Required Associated Types§

Source

type Int: Sized + Copy + PartialOrd + Ord + Eq + Hash + Not + BitAnd + BitOr + BitXor + Add + Sub + Mul + Div + Rem + AddAssign + SubAssign + MulAssign + DivAssign + RemAssign + Debug + Display + LowerHex + UpperHex + Octal + Binary

The signed integer Rust representation.

Source

type Uint: Sized + Copy + PartialOrd + Ord + Eq + Hash + Not + BitAnd + BitOr + BitXor + Add + Sub + Mul + Div + Rem + AddAssign + SubAssign + MulAssign + DivAssign + RemAssign + Debug + Display + LowerHex + UpperHex + Octal + Binary

The unsigned integer Rust representation.

Required Methods§

Source

fn tokenize_int(int: Self::Int) -> WordToken

Tokenizes a signed integer.

Source

fn detokenize_int(token: WordToken) -> Self::Int

Detokenizes a signed integer.

Source

fn encode_packed_to_int(int: Self::Int, out: &mut Vec<u8>)

ABI-encode a signed integer in packed mode.

Source

fn tokenize_uint(uint: Self::Uint) -> WordToken

Tokenizes an unsigned integer.

Source

fn detokenize_uint(token: WordToken) -> Self::Uint

Detokenizes an unsigned integer.

Source

fn encode_packed_to_uint(uint: Self::Uint, out: &mut Vec<u8>)

ABI-encode an unsigned integer in packed mode.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SupportedInt for IntBitCount<8>

Source§

const UINT_NAME: &'static str = "uint8"

Source§

const INT_NAME: &'static str = "int8"

Source§

const BITS: usize = 8usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = i8

Source§

type Uint = u8

Source§

impl SupportedInt for IntBitCount<16>

Source§

const UINT_NAME: &'static str = "uint16"

Source§

const INT_NAME: &'static str = "int16"

Source§

const BITS: usize = 16usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = i16

Source§

type Uint = u16

Source§

impl SupportedInt for IntBitCount<24>

Source§

const UINT_NAME: &'static str = "uint24"

Source§

const INT_NAME: &'static str = "int24"

Source§

const BITS: usize = 24usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<24, 1>

Source§

type Uint = Uint<24, 1>

Source§

impl SupportedInt for IntBitCount<32>

Source§

const UINT_NAME: &'static str = "uint32"

Source§

const INT_NAME: &'static str = "int32"

Source§

const BITS: usize = 32usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = i32

Source§

type Uint = u32

Source§

impl SupportedInt for IntBitCount<40>

Source§

const UINT_NAME: &'static str = "uint40"

Source§

const INT_NAME: &'static str = "int40"

Source§

const BITS: usize = 40usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<40, 1>

Source§

type Uint = Uint<40, 1>

Source§

impl SupportedInt for IntBitCount<48>

Source§

const UINT_NAME: &'static str = "uint48"

Source§

const INT_NAME: &'static str = "int48"

Source§

const BITS: usize = 48usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<48, 1>

Source§

type Uint = Uint<48, 1>

Source§

impl SupportedInt for IntBitCount<56>

Source§

const UINT_NAME: &'static str = "uint56"

Source§

const INT_NAME: &'static str = "int56"

Source§

const BITS: usize = 56usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<56, 1>

Source§

type Uint = Uint<56, 1>

Source§

impl SupportedInt for IntBitCount<64>

Source§

const UINT_NAME: &'static str = "uint64"

Source§

const INT_NAME: &'static str = "int64"

Source§

const BITS: usize = 64usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = i64

Source§

type Uint = u64

Source§

impl SupportedInt for IntBitCount<72>

Source§

const UINT_NAME: &'static str = "uint72"

Source§

const INT_NAME: &'static str = "int72"

Source§

const BITS: usize = 72usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<72, 2>

Source§

type Uint = Uint<72, 2>

Source§

impl SupportedInt for IntBitCount<80>

Source§

const UINT_NAME: &'static str = "uint80"

Source§

const INT_NAME: &'static str = "int80"

Source§

const BITS: usize = 80usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<80, 2>

Source§

type Uint = Uint<80, 2>

Source§

impl SupportedInt for IntBitCount<88>

Source§

const UINT_NAME: &'static str = "uint88"

Source§

const INT_NAME: &'static str = "int88"

Source§

const BITS: usize = 88usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<88, 2>

Source§

type Uint = Uint<88, 2>

Source§

impl SupportedInt for IntBitCount<96>

Source§

const UINT_NAME: &'static str = "uint96"

Source§

const INT_NAME: &'static str = "int96"

Source§

const BITS: usize = 96usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<96, 2>

Source§

type Uint = Uint<96, 2>

Source§

impl SupportedInt for IntBitCount<104>

Source§

const UINT_NAME: &'static str = "uint104"

Source§

const INT_NAME: &'static str = "int104"

Source§

const BITS: usize = 104usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<104, 2>

Source§

type Uint = Uint<104, 2>

Source§

impl SupportedInt for IntBitCount<112>

Source§

const UINT_NAME: &'static str = "uint112"

Source§

const INT_NAME: &'static str = "int112"

Source§

const BITS: usize = 112usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<112, 2>

Source§

type Uint = Uint<112, 2>

Source§

impl SupportedInt for IntBitCount<120>

Source§

const UINT_NAME: &'static str = "uint120"

Source§

const INT_NAME: &'static str = "int120"

Source§

const BITS: usize = 120usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<120, 2>

Source§

type Uint = Uint<120, 2>

Source§

impl SupportedInt for IntBitCount<128>

Source§

const UINT_NAME: &'static str = "uint128"

Source§

const INT_NAME: &'static str = "int128"

Source§

const BITS: usize = 128usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = i128

Source§

type Uint = u128

Source§

impl SupportedInt for IntBitCount<136>

Source§

const UINT_NAME: &'static str = "uint136"

Source§

const INT_NAME: &'static str = "int136"

Source§

const BITS: usize = 136usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<136, 3>

Source§

type Uint = Uint<136, 3>

Source§

impl SupportedInt for IntBitCount<144>

Source§

const UINT_NAME: &'static str = "uint144"

Source§

const INT_NAME: &'static str = "int144"

Source§

const BITS: usize = 144usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<144, 3>

Source§

type Uint = Uint<144, 3>

Source§

impl SupportedInt for IntBitCount<152>

Source§

const UINT_NAME: &'static str = "uint152"

Source§

const INT_NAME: &'static str = "int152"

Source§

const BITS: usize = 152usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<152, 3>

Source§

type Uint = Uint<152, 3>

Source§

impl SupportedInt for IntBitCount<160>

Source§

const UINT_NAME: &'static str = "uint160"

Source§

const INT_NAME: &'static str = "int160"

Source§

const BITS: usize = 160usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<160, 3>

Source§

type Uint = Uint<160, 3>

Source§

impl SupportedInt for IntBitCount<168>

Source§

const UINT_NAME: &'static str = "uint168"

Source§

const INT_NAME: &'static str = "int168"

Source§

const BITS: usize = 168usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<168, 3>

Source§

type Uint = Uint<168, 3>

Source§

impl SupportedInt for IntBitCount<176>

Source§

const UINT_NAME: &'static str = "uint176"

Source§

const INT_NAME: &'static str = "int176"

Source§

const BITS: usize = 176usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<176, 3>

Source§

type Uint = Uint<176, 3>

Source§

impl SupportedInt for IntBitCount<184>

Source§

const UINT_NAME: &'static str = "uint184"

Source§

const INT_NAME: &'static str = "int184"

Source§

const BITS: usize = 184usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<184, 3>

Source§

type Uint = Uint<184, 3>

Source§

impl SupportedInt for IntBitCount<192>

Source§

const UINT_NAME: &'static str = "uint192"

Source§

const INT_NAME: &'static str = "int192"

Source§

const BITS: usize = 192usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<192, 3>

Source§

type Uint = Uint<192, 3>

Source§

impl SupportedInt for IntBitCount<200>

Source§

const UINT_NAME: &'static str = "uint200"

Source§

const INT_NAME: &'static str = "int200"

Source§

const BITS: usize = 200usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<200, 4>

Source§

type Uint = Uint<200, 4>

Source§

impl SupportedInt for IntBitCount<208>

Source§

const UINT_NAME: &'static str = "uint208"

Source§

const INT_NAME: &'static str = "int208"

Source§

const BITS: usize = 208usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<208, 4>

Source§

type Uint = Uint<208, 4>

Source§

impl SupportedInt for IntBitCount<216>

Source§

const UINT_NAME: &'static str = "uint216"

Source§

const INT_NAME: &'static str = "int216"

Source§

const BITS: usize = 216usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<216, 4>

Source§

type Uint = Uint<216, 4>

Source§

impl SupportedInt for IntBitCount<224>

Source§

const UINT_NAME: &'static str = "uint224"

Source§

const INT_NAME: &'static str = "int224"

Source§

const BITS: usize = 224usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<224, 4>

Source§

type Uint = Uint<224, 4>

Source§

impl SupportedInt for IntBitCount<232>

Source§

const UINT_NAME: &'static str = "uint232"

Source§

const INT_NAME: &'static str = "int232"

Source§

const BITS: usize = 232usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<232, 4>

Source§

type Uint = Uint<232, 4>

Source§

impl SupportedInt for IntBitCount<240>

Source§

const UINT_NAME: &'static str = "uint240"

Source§

const INT_NAME: &'static str = "int240"

Source§

const BITS: usize = 240usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<240, 4>

Source§

type Uint = Uint<240, 4>

Source§

impl SupportedInt for IntBitCount<248>

Source§

const UINT_NAME: &'static str = "uint248"

Source§

const INT_NAME: &'static str = "int248"

Source§

const BITS: usize = 248usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<248, 4>

Source§

type Uint = Uint<248, 4>

Source§

impl SupportedInt for IntBitCount<256>

Source§

const UINT_NAME: &'static str = "uint256"

Source§

const INT_NAME: &'static str = "int256"

Source§

const BITS: usize = 256usize

Source§

const SKIP_BYTES: usize = 0usize

Source§

type Int = Signed<256, 4>

Source§

type Uint = Uint<256, 4>