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§
Required Associated Constants§
sourceconst BITS: usize
const BITS: usize
The number of bits in the integer: BITS
Note that this is not equal to Self::Int::BITS
.
sourceconst SKIP_BYTES: usize
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§
Required Methods§
sourcefn tokenize_int(int: Self::Int) -> WordToken
fn tokenize_int(int: Self::Int) -> WordToken
Tokenizes a signed integer.
sourcefn detokenize_int(token: WordToken) -> Self::Int
fn detokenize_int(token: WordToken) -> Self::Int
Detokenizes a signed integer.
sourcefn encode_packed_to_int(int: Self::Int, out: &mut Vec<u8>)
fn encode_packed_to_int(int: Self::Int, out: &mut Vec<u8>)
ABI-encode a signed integer in packed mode.
sourcefn tokenize_uint(uint: Self::Uint) -> WordToken
fn tokenize_uint(uint: Self::Uint) -> WordToken
Tokenizes an unsigned integer.
sourcefn detokenize_uint(token: WordToken) -> Self::Uint
fn detokenize_uint(token: WordToken) -> Self::Uint
Detokenizes an unsigned integer.
sourcefn encode_packed_to_uint(uint: Self::Uint, out: &mut Vec<u8>)
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.