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§
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 Associated Types§
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.
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.