Trait alloy_sol_types::sol_data::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 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 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 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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl SupportedInt for IntBitCount<8>

§

type Int = i8

§

type Uint = u8

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§

impl SupportedInt for IntBitCount<16>

§

type Int = i16

§

type Uint = u16

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§

impl SupportedInt for IntBitCount<24>

§

type Int = Signed<24, 1>

§

type Uint = Uint<24, 1>

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§

impl SupportedInt for IntBitCount<32>

§

type Int = i32

§

type Uint = u32

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§

impl SupportedInt for IntBitCount<40>

§

type Int = Signed<40, 1>

§

type Uint = Uint<40, 1>

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§

impl SupportedInt for IntBitCount<48>

§

type Int = Signed<48, 1>

§

type Uint = Uint<48, 1>

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§

impl SupportedInt for IntBitCount<56>

§

type Int = Signed<56, 1>

§

type Uint = Uint<56, 1>

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§

impl SupportedInt for IntBitCount<64>

§

type Int = i64

§

type Uint = u64

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§

impl SupportedInt for IntBitCount<72>

§

type Int = Signed<72, 2>

§

type Uint = Uint<72, 2>

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§

impl SupportedInt for IntBitCount<80>

§

type Int = Signed<80, 2>

§

type Uint = Uint<80, 2>

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§

impl SupportedInt for IntBitCount<88>

§

type Int = Signed<88, 2>

§

type Uint = Uint<88, 2>

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§

impl SupportedInt for IntBitCount<96>

§

type Int = Signed<96, 2>

§

type Uint = Uint<96, 2>

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§

impl SupportedInt for IntBitCount<104>

§

type Int = Signed<104, 2>

§

type Uint = Uint<104, 2>

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§

impl SupportedInt for IntBitCount<112>

§

type Int = Signed<112, 2>

§

type Uint = Uint<112, 2>

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§

impl SupportedInt for IntBitCount<120>

§

type Int = Signed<120, 2>

§

type Uint = Uint<120, 2>

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§

impl SupportedInt for IntBitCount<128>

§

type Int = i128

§

type Uint = u128

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§

impl SupportedInt for IntBitCount<136>

§

type Int = Signed<136, 3>

§

type Uint = Uint<136, 3>

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§

impl SupportedInt for IntBitCount<144>

§

type Int = Signed<144, 3>

§

type Uint = Uint<144, 3>

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§

impl SupportedInt for IntBitCount<152>

§

type Int = Signed<152, 3>

§

type Uint = Uint<152, 3>

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§

impl SupportedInt for IntBitCount<160>

§

type Int = Signed<160, 3>

§

type Uint = Uint<160, 3>

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§

impl SupportedInt for IntBitCount<168>

§

type Int = Signed<168, 3>

§

type Uint = Uint<168, 3>

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§

impl SupportedInt for IntBitCount<176>

§

type Int = Signed<176, 3>

§

type Uint = Uint<176, 3>

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§

impl SupportedInt for IntBitCount<184>

§

type Int = Signed<184, 3>

§

type Uint = Uint<184, 3>

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§

impl SupportedInt for IntBitCount<192>

§

type Int = Signed<192, 3>

§

type Uint = Uint<192, 3>

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§

impl SupportedInt for IntBitCount<200>

§

type Int = Signed<200, 4>

§

type Uint = Uint<200, 4>

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§

impl SupportedInt for IntBitCount<208>

§

type Int = Signed<208, 4>

§

type Uint = Uint<208, 4>

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§

impl SupportedInt for IntBitCount<216>

§

type Int = Signed<216, 4>

§

type Uint = Uint<216, 4>

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§

impl SupportedInt for IntBitCount<224>

§

type Int = Signed<224, 4>

§

type Uint = Uint<224, 4>

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§

impl SupportedInt for IntBitCount<232>

§

type Int = Signed<232, 4>

§

type Uint = Uint<232, 4>

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§

impl SupportedInt for IntBitCount<240>

§

type Int = Signed<240, 4>

§

type Uint = Uint<240, 4>

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§

impl SupportedInt for IntBitCount<248>

§

type Int = Signed<248, 4>

§

type Uint = Uint<248, 4>

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§

impl SupportedInt for IntBitCount<256>

§

type Int = Signed<256, 4>

§

type Uint = Uint<256, 4>

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