pub trait SolValue: SolTypeValue<Self::SolType> {
type SolType: SolType;
Show 14 methods
// Provided methods
fn sol_name(&self) -> &'static str { ... }
fn sol_type_name(&self) -> Cow<'static, str> { ... }
fn tokenize(&self) -> <Self::SolType as SolType>::Token<'_> { ... }
fn detokenize(token: <Self::SolType as SolType>::Token<'_>) -> Self
where Self: From<<Self::SolType as SolType>::RustType> { ... }
fn abi_encoded_size(&self) -> usize { ... }
fn eip712_data_word(&self) -> Word { ... }
fn abi_encode_packed_to(&self, out: &mut Vec<u8>) { ... }
fn abi_encode_packed(&self) -> Vec<u8> ⓘ { ... }
fn abi_encode(&self) -> Vec<u8> ⓘ { ... }
fn abi_encode_sequence(&self) -> Vec<u8> ⓘ
where for<'a> <Self::SolType as SolType>::Token<'a>: TokenSeq<'a> { ... }
fn abi_encode_params(&self) -> Vec<u8> ⓘ
where for<'a> <Self::SolType as SolType>::Token<'a>: TokenSeq<'a> { ... }
fn abi_decode(data: &[u8], validate: bool) -> Result<Self>
where Self: From<<Self::SolType as SolType>::RustType> { ... }
fn abi_decode_params<'de>(data: &'de [u8], validate: bool) -> Result<Self>
where Self: From<<Self::SolType as SolType>::RustType>,
<Self::SolType as SolType>::Token<'de>: TokenSeq<'de> { ... }
fn abi_decode_sequence<'de>(data: &'de [u8], validate: bool) -> Result<Self>
where Self: From<<Self::SolType as SolType>::RustType>,
<Self::SolType as SolType>::Token<'de>: TokenSeq<'de> { ... }
}
Expand description
A Solidity value.
This is a convenience trait that re-exports the logic in SolType
with
less generic implementations so that they can be used as methods with self
receivers.
See SolType
for more information.
§Implementer’s Guide
It should not be necessary to implement this trait manually. Instead, use
the sol!
procedural macro to parse Solidity syntax into
types that implement this trait.
§Examples
use alloy_sol_types::SolValue;
let my_values = ("hello", 0xdeadbeef_u32, true, [0x42_u8; 24]);
let _ = my_values.abi_encode();
let _ = my_values.abi_encode_packed();
assert_eq!(my_values.sol_type_name(), "(string,uint32,bool,bytes24)");
Required Associated Types§
Provided Methods§
Sourcefn sol_name(&self) -> &'static str
fn sol_name(&self) -> &'static str
The name of the associated Solidity type.
See SolType::SOL_NAME
for more information.
Sourcefn sol_type_name(&self) -> Cow<'static, str>
👎Deprecated since 0.6.3: use sol_name
instead
fn sol_type_name(&self) -> Cow<'static, str>
sol_name
insteadThe name of the associated Solidity type.
See SolType::sol_type_name
for more information.
Sourcefn tokenize(&self) -> <Self::SolType as SolType>::Token<'_>
fn tokenize(&self) -> <Self::SolType as SolType>::Token<'_>
Tokenizes the given value into this type’s token.
See SolType::tokenize
for more information.
Sourcefn detokenize(token: <Self::SolType as SolType>::Token<'_>) -> Self
fn detokenize(token: <Self::SolType as SolType>::Token<'_>) -> Self
Detokenize a value from the given token.
See SolType::detokenize
for more information.
Sourcefn abi_encoded_size(&self) -> usize
fn abi_encoded_size(&self) -> usize
Calculate the ABI-encoded size of the data.
See SolType::abi_encoded_size
for more information.
Sourcefn eip712_data_word(&self) -> Word
fn eip712_data_word(&self) -> Word
Encode this data according to EIP-712 encodeData
rules, and hash it
if necessary.
See SolType::eip712_data_word
for more information.
Sourcefn abi_encode_packed_to(&self, out: &mut Vec<u8>)
fn abi_encode_packed_to(&self, out: &mut Vec<u8>)
Non-standard Packed Mode ABI encoding.
See SolType::abi_encode_packed_to
for more information.
Sourcefn abi_encode_packed(&self) -> Vec<u8> ⓘ
fn abi_encode_packed(&self) -> Vec<u8> ⓘ
Non-standard Packed Mode ABI encoding.
See SolType::abi_encode_packed
for more information.
Sourcefn abi_encode(&self) -> Vec<u8> ⓘ
fn abi_encode(&self) -> Vec<u8> ⓘ
ABI-encodes the value.
See SolType::abi_encode
for more information.
Sourcefn abi_encode_sequence(&self) -> Vec<u8> ⓘ
fn abi_encode_sequence(&self) -> Vec<u8> ⓘ
Encodes an ABI sequence.
See SolType::abi_encode_sequence
for more information.
Sourcefn abi_encode_params(&self) -> Vec<u8> ⓘ
fn abi_encode_params(&self) -> Vec<u8> ⓘ
Encodes an ABI sequence suitable for function parameters.
See SolType::abi_encode_params
for more information.
Sourcefn abi_decode(data: &[u8], validate: bool) -> Result<Self>
fn abi_decode(data: &[u8], validate: bool) -> Result<Self>
ABI-decode this type from the given data.
See SolType::abi_decode
for more information.
Sourcefn abi_decode_params<'de>(data: &'de [u8], validate: bool) -> Result<Self>
fn abi_decode_params<'de>(data: &'de [u8], validate: bool) -> Result<Self>
ABI-decode this type from the given data.
See SolType::abi_decode_params
for more information.
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.