Enum ethers_core::abi::Token

source ·
pub enum Token {
    Address(H160),
    FixedBytes(Vec<u8>),
    Bytes(Vec<u8>),
    Int(U256),
    Uint(U256),
    Bool(bool),
    String(String),
    FixedArray(Vec<Token>),
    Array(Vec<Token>),
    Tuple(Vec<Token>),
}
Expand description

Ethereum ABI params.

Variants§

§

Address(H160)

Address.

solidity name: address Encoded to left padded [0u8; 32].

§

FixedBytes(Vec<u8>)

Vector of bytes with known size.

solidity name eg.: bytes8, bytes32, bytes64, bytes1024 Encoded to right padded [0u8; ((N + 31) / 32) * 32].

§

Bytes(Vec<u8>)

Vector of bytes of unknown size.

solidity name: bytes Encoded in two parts. Init part: offset of ’closing part`. Closing part: encoded length followed by encoded right padded bytes.

§

Int(U256)

Signed integer.

solidity name: int

§

Uint(U256)

Unsigned integer.

solidity name: uint

§

Bool(bool)

Boolean value.

solidity name: bool Encoded as left padded [0u8; 32], where last bit represents boolean value.

§

String(String)

String.

solidity name: string Encoded in the same way as bytes. Must be utf8 compliant.

§

FixedArray(Vec<Token>)

Array with known size.

solidity name eg.: int[3], bool[3], address[][8] Encoding of array is equal to encoding of consecutive elements of array.

§

Array(Vec<Token>)

Array of params with unknown size.

solidity name eg. int[], bool[], address[5][]

§

Tuple(Vec<Token>)

Tuple of params of variable types.

solidity name: tuple

Implementations§

source§

impl Token

source

pub fn type_check(&self, param_type: &ParamType) -> bool

Check whether the type of the token matches the given parameter type.

Numeric types (Int and Uint) type check if the size of the token type is of greater or equal size than the provided parameter type.

source

pub fn into_address(self) -> Option<H160>

Converts token to…

source

pub fn into_fixed_bytes(self) -> Option<Vec<u8>>

Converts token to…

source

pub fn into_bytes(self) -> Option<Vec<u8>>

Converts token to…

source

pub fn into_int(self) -> Option<U256>

Converts token to…

source

pub fn into_uint(self) -> Option<U256>

Converts token to…

source

pub fn into_bool(self) -> Option<bool>

Converts token to…

source

pub fn into_string(self) -> Option<String>

Converts token to…

source

pub fn into_fixed_array(self) -> Option<Vec<Token>>

Converts token to…

source

pub fn into_array(self) -> Option<Vec<Token>>

Converts token to…

source

pub fn into_tuple(self) -> Option<Vec<Token>>

Converts token to…

source

pub fn types_check(tokens: &[Token], param_types: &[ParamType]) -> bool

Check if all the types of the tokens match the given parameter types.

source

pub fn is_dynamic(&self) -> bool

Check if the token is a dynamic type resulting in prefixed encoding

Trait Implementations§

source§

impl Clone for Token

source§

fn clone(&self) -> Token

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Token

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Token

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<Token, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Token

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl PartialEq for Token

source§

fn eq(&self, other: &Token) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Token

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Tokenizable for Token

source§

fn from_token(token: Token) -> Result<Self, InvalidOutputType>

Converts a Token into expected type.
source§

fn into_token(self) -> Token

Converts a specified type back into token.
source§

impl StructuralPartialEq for Token

source§

impl TokenizableItem for Token

Auto Trait Implementations§

§

impl RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnwindSafe for Token

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Detokenize for T
where T: Tokenizable,

source§

fn from_tokens(tokens: Vec<Token>) -> Result<T, InvalidOutputType>

Creates a new instance from parsed ABI tokens.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> Tokenize for T
where T: Tokenizable,

source§

fn into_tokens(self) -> Vec<Token>

Converts self into a Vec<Token>.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> JsonSchemaMaybe for T