Trait SolDecode

Source
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::{
    sol::Error,
    SolDecode,
};

// 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§

Source

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

Name of equivalent Solidity ABI type.

Required Associated Types§

Source

type SolType: SolTypeDecode

Equivalent Solidity ABI type representation.

Required Methods§

Source

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

Converts to Self from Self::SolType.

Provided Methods§

Source

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§

Source§

impl SolDecode for bool

Source§

impl SolDecode for i8

Source§

type SolType = i8

Source§

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

Source§

impl SolDecode for i16

Source§

type SolType = i16

Source§

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

Source§

impl SolDecode for i32

Source§

type SolType = i32

Source§

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

Source§

impl SolDecode for i64

Source§

type SolType = i64

Source§

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

Source§

impl SolDecode for i128

Source§

impl SolDecode for u8

Source§

type SolType = u8

Source§

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

Source§

impl SolDecode for u16

Source§

type SolType = u16

Source§

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

Source§

impl SolDecode for u32

Source§

type SolType = u32

Source§

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

Source§

impl SolDecode for u64

Source§

type SolType = u64

Source§

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

Source§

impl SolDecode for u128

Source§

impl SolDecode for ()

Source§

type SolType = ()

Source§

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

Source§

impl SolDecode for Box<str>

Source§

type SolType = Box<str>

Source§

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

Source§

impl SolDecode for String

Source§

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

Source§

impl<T> SolDecode for PhantomData<T>

Source§

type SolType = ()

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type SolType = [<T as SolDecode>::SolType; N]

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType,)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType, <TupleElement6 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType, <TupleElement6 as SolDecode>::SolType, <TupleElement7 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType, <TupleElement6 as SolDecode>::SolType, <TupleElement7 as SolDecode>::SolType, <TupleElement8 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType, <TupleElement6 as SolDecode>::SolType, <TupleElement7 as SolDecode>::SolType, <TupleElement8 as SolDecode>::SolType, <TupleElement9 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType, <TupleElement6 as SolDecode>::SolType, <TupleElement7 as SolDecode>::SolType, <TupleElement8 as SolDecode>::SolType, <TupleElement9 as SolDecode>::SolType, <TupleElement10 as SolDecode>::SolType)

Source§

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

Source§

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

Source§

type SolType = (<TupleElement0 as SolDecode>::SolType, <TupleElement1 as SolDecode>::SolType, <TupleElement2 as SolDecode>::SolType, <TupleElement3 as SolDecode>::SolType, <TupleElement4 as SolDecode>::SolType, <TupleElement5 as SolDecode>::SolType, <TupleElement6 as SolDecode>::SolType, <TupleElement7 as SolDecode>::SolType, <TupleElement8 as SolDecode>::SolType, <TupleElement9 as SolDecode>::SolType, <TupleElement10 as SolDecode>::SolType, <TupleElement11 as SolDecode>::SolType)

Source§

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

Implementors§