alloy_sol_types

Trait SolCall

Source
pub trait SolCall: Sized {
    type Parameters<'a>: SolType<Token<'a> = Self::Token<'a>>;
    type Token<'a>: TokenSeq<'a>;
    type Return;
    type ReturnTuple<'a>: SolType<Token<'a> = Self::ReturnToken<'a>>;
    type ReturnToken<'a>: TokenSeq<'a>;

    const SIGNATURE: &'static str;
    const SELECTOR: [u8; 4];

    // Required methods
    fn new(tuple: <Self::Parameters<'_> as SolType>::RustType) -> Self;
    fn tokenize(&self) -> Self::Token<'_>;
    fn abi_decode_returns(data: &[u8], validate: bool) -> Result<Self::Return>;

    // Provided methods
    fn abi_encoded_size(&self) -> usize { ... }
    fn abi_decode_raw(data: &[u8], validate: bool) -> Result<Self> { ... }
    fn abi_decode(data: &[u8], validate: bool) -> Result<Self> { ... }
    fn abi_encode_raw(&self, out: &mut Vec<u8>) { ... }
    fn abi_encode(&self) -> Vec<u8>  { ... }
    fn abi_encode_returns<'a, E>(e: &'a E) -> Vec<u8> 
       where E: SolTypeValue<Self::ReturnTuple<'a>> { ... }
}
Expand description

A Solidity function call.

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

Required Associated Constants§

Source

const SIGNATURE: &'static str

The function’s ABI signature.

Source

const SELECTOR: [u8; 4]

The function selector: keccak256(SIGNATURE)[0..4]

Required Associated Types§

Source

type Parameters<'a>: SolType<Token<'a> = Self::Token<'a>>

The underlying tuple type which represents this type’s arguments.

If this type has no arguments, this will be the unit type ().

Source

type Token<'a>: TokenSeq<'a>

The arguments’ corresponding TokenSeq type.

Source

type Return

The function’s return struct.

Source

type ReturnTuple<'a>: SolType<Token<'a> = Self::ReturnToken<'a>>

The underlying tuple type which represents this type’s return values.

If this type has no return values, this will be the unit type ().

Source

type ReturnToken<'a>: TokenSeq<'a>

The returns’ corresponding TokenSeq type.

Required Methods§

Source

fn new(tuple: <Self::Parameters<'_> as SolType>::RustType) -> Self

Convert from the tuple type used for ABI encoding and decoding.

Source

fn tokenize(&self) -> Self::Token<'_>

Tokenize the call’s arguments.

Source

fn abi_decode_returns(data: &[u8], validate: bool) -> Result<Self::Return>

ABI decode this call’s return values from the given slice.

Provided Methods§

Source

fn abi_encoded_size(&self) -> usize

The size of the encoded data in bytes, without its selector.

Source

fn abi_decode_raw(data: &[u8], validate: bool) -> Result<Self>

ABI decode this call’s arguments from the given slice, without its selector.

Source

fn abi_decode(data: &[u8], validate: bool) -> Result<Self>

ABI decode this call’s arguments from the given slice, with the selector.

Source

fn abi_encode_raw(&self, out: &mut Vec<u8>)

ABI encode the call to the given buffer without its selector.

Source

fn abi_encode(&self) -> Vec<u8>

ABI encode the call to the given buffer with its selector.

Source

fn abi_encode_returns<'a, E>(e: &'a E) -> Vec<u8>
where E: SolTypeValue<Self::ReturnTuple<'a>>,

ABI encode the call’s return values.

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.

Implementors§