alloy_sol_types

Trait SolEnum

Source
pub trait SolEnum:
    Sized
    + Copy
    + Into<u8>
    + TryFrom<u8, Error = Error> {
    const COUNT: usize;

    // Provided methods
    fn tokenize(self) -> WordToken { ... }
    fn abi_decode(data: &[u8], validate: bool) -> Result<Self> { ... }
    fn abi_encode_raw(self, out: &mut Vec<u8>) { ... }
    fn abi_encode(self) -> Vec<u8>  { ... }
}
Expand description

A Solidity enum. This is always a wrapper around a u8.

§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 COUNT: usize

The number of variants in the enum.

This is generally between 1 and 256 inclusive.

Provided Methods§

Source

fn tokenize(self) -> WordToken

Tokenize the enum.

Source

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

ABI decode the enum from the given buffer.

Source

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

ABI encode the enum into the given buffer.

Source

fn abi_encode(self) -> Vec<u8>

ABI encode the enum.

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§