Trait SolDecode

pub trait SolDecode: Sized {
    type SolType: SolTypeDecode;

    const SOL_NAME: &'static str = <<Self::SolType as SolTypeDecode>::AlloyType as AlloySolType>::SOL_NAME;

    // Required method
    fn from_sol_type(value: Self::SolType) -> Result<Self, Error>;

    // Provided method
    fn decode(data: &[u8]) -> Result<Self, Error> { ... }
}
Expand description

Maps an arbitrary Rust/ink! type to a Solidity ABI type equivalent for Solidity ABI decoding.

§Note

Implementing this trait entails:

  • Declaring the equivalent Solidity ABI type via the SolType associated type. See the docs for sealed SolTypeDecode trait for a table of Rust/ink! primitive types mapped to their equivalent Solidity ABI type.
  • Implementing the from_sol_type method which defines how to convert from the Solidity ABI representation (i.e. Self::SolType) to this type.

§Example

use ink_primitives::{
    SolDecode,
    sol::Error,
};

// Example arbitrary type.
struct MyType {
    size: u8,
    status: bool,
}

// `SolDecode` implementation/mapping.
impl SolDecode for MyType {
    type SolType = (u8, bool);

    fn from_sol_type(value: Self::SolType) -> Result<Self, Error> {
        Ok(Self {
            size: value.0,
            status: value.1,
        })
    }
}

Provided Associated Constants§

const SOL_NAME: &'static str = <<Self::SolType as SolTypeDecode>::AlloyType as AlloySolType>::SOL_NAME

Name of equivalent Solidity ABI type.

Required Associated Types§

type SolType: SolTypeDecode

Equivalent Solidity ABI type representation.

Required Methods§

fn from_sol_type(value: Self::SolType) -> Result<Self, Error>

Converts to Self from Self::SolType.

Provided Methods§

fn decode(data: &[u8]) -> Result<Self, Error>

Solidity ABI decode into this type.

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.

Implementations on Foreign Types§

§

impl SolDecode for bool

§

impl SolDecode for i8

§

impl SolDecode for i16

§

impl SolDecode for i32

§

impl SolDecode for i64

§

impl SolDecode for i128

§

impl SolDecode for u8

§

impl SolDecode for u16

§

impl SolDecode for u32

§

impl SolDecode for u64

§

impl SolDecode for u128

§

impl SolDecode for ()

§

impl SolDecode for Box<str>

§

impl SolDecode for String

§

impl SolDecode for Weight

§

type SolType = (u64, u64)

§

fn from_sol_type(value: <Weight as SolDecode>::SolType) -> Result<Weight, Error>

§

impl<T> SolDecode for Option<T>
where T: SolDecode,

§

impl<T> SolDecode for Box<[T]>
where T: SolDecode,

§

type SolType = Box<[<T as SolDecode>::SolType]>

§

fn from_sol_type( value: <Box<[T]> as SolDecode>::SolType, ) -> Result<Box<[T]>, Error>

§

impl<T> SolDecode for Vec<T>
where T: SolDecode,

§

type SolType = Vec<<T as SolDecode>::SolType>

§

fn from_sol_type(value: <Vec<T> as SolDecode>::SolType) -> Result<Vec<T>, Error>

§

impl<T> SolDecode for PhantomData<T>

§

impl<T, const N: usize> SolDecode for [T; N]
where T: SolDecode,

§

impl<TupleElement0> SolDecode for (TupleElement0,)
where TupleElement0: SolDecode,

§

impl<TupleElement0, TupleElement1> SolDecode for (TupleElement0, TupleElement1)
where TupleElement0: SolDecode, TupleElement1: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2> SolDecode for (TupleElement0, TupleElement1, TupleElement2)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode, TupleElement6: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode, TupleElement6: SolDecode, TupleElement7: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode, TupleElement6: SolDecode, TupleElement7: SolDecode, TupleElement8: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode, TupleElement6: SolDecode, TupleElement7: SolDecode, TupleElement8: SolDecode, TupleElement9: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode, TupleElement6: SolDecode, TupleElement7: SolDecode, TupleElement8: SolDecode, TupleElement9: SolDecode, TupleElement10: SolDecode,

§

impl<TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10, TupleElement11> SolDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10, TupleElement11)
where TupleElement0: SolDecode, TupleElement1: SolDecode, TupleElement2: SolDecode, TupleElement3: SolDecode, TupleElement4: SolDecode, TupleElement5: SolDecode, TupleElement6: SolDecode, TupleElement7: SolDecode, TupleElement8: SolDecode, TupleElement9: SolDecode, TupleElement10: SolDecode, TupleElement11: SolDecode,

Implementors§

§

impl SolDecode for DynBytes

§

impl SolDecode for H160

§

impl SolDecode for H256

§

impl SolDecode for U256

§

impl SolDecode for AccountId

§

impl SolDecode for Hash

§

impl<const N: usize> SolDecode for FixedBytes<N>
where ByteCount<N>: SupportedFixedBytes,