Enum ethers_core::abi::Token
source · [−]pub enum Token {
Address(H160),
FixedBytes(Vec<u8, Global>),
Bytes(Vec<u8, Global>),
Int(U256),
Uint(U256),
Bool(bool),
String(String),
FixedArray(Vec<Token, Global>),
Array(Vec<Token, Global>),
Tuple(Vec<Token, Global>),
}
Expand description
Ethereum ABI params.
Variants
Address(H160)
Address.
solidity name: address Encoded to left padded [0u8; 32].
FixedBytes(Vec<u8, Global>)
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, Global>)
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)
Unisnged 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, Global>)
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, Global>)
Array of params with unknown size.
solidity name eg. int[], bool[], address[5][]
Tuple(Vec<Token, Global>)
Tuple of params of variable types.
solidity name: tuple
Implementations
sourceimpl Token
impl Token
sourcepub fn type_check(&self, param_type: &ParamType) -> bool
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.
sourcepub fn into_address(self) -> Option<H160>
pub fn into_address(self) -> Option<H160>
Converts token to…
sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Converts token to…
sourcepub fn types_check(tokens: &[Token], param_types: &[ParamType]) -> bool
pub fn types_check(tokens: &[Token], param_types: &[ParamType]) -> bool
Check if all the types of the tokens match the given parameter types.
sourcepub fn is_dynamic(&self) -> bool
pub fn is_dynamic(&self) -> bool
Check if the token is a dynamic type resulting in prefixed encoding
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Token
impl<'de> Deserialize<'de> for Token
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Token, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
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
sourceimpl Serialize for Token
impl Serialize for Token
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
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
sourceimpl Tokenizable for Token
impl Tokenizable for Token
sourcefn from_token(token: Token) -> Result<Self, InvalidOutputType>
fn from_token(token: Token) -> Result<Self, InvalidOutputType>
Converts a Token
into expected type.
sourcefn into_token(self) -> Token
fn into_token(self) -> Token
Converts a specified type back into token.
impl StructuralPartialEq for Token
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more