Trait AbiEncodeWith

Source
pub trait AbiEncodeWith<Abi> {
    // Required methods
    fn encode_with(&self) -> Vec<u8> ;
    fn encode_to_slice(&self, buffer: &mut [u8]) -> usize;
    fn encode_to_vec(&self, buffer: &mut Vec<u8>);
    fn encode_topic<H>(&self, hasher: H) -> [u8; 32]
       where H: Fn(&[u8], &mut [u8; 32]);
}
Expand description

Trait for ABI-specific encoding with support for both slice and vector buffers.

Required Methods§

Source

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

Encodes the data into a new vector.

Source

fn encode_to_slice(&self, buffer: &mut [u8]) -> usize

Encodes the data into a fixed-size buffer, returning the number of bytes written.

Source

fn encode_to_vec(&self, buffer: &mut Vec<u8>)

Encodes the data into a dynamically resizing vector.

Source

fn encode_topic<H>(&self, hasher: H) -> [u8; 32]
where H: Fn(&[u8], &mut [u8; 32]),

Encodes the value as a topic (i.e. an indexed event parameter).

§Note

The provided hashing function depends on the ABI i.e.

  • BLAKE2b for ink! ABI
  • Keccak-256 for Solidity ABI

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§

Source§

impl<T> AbiEncodeWith<Sol> for T
where T: for<'a> SolEncode<'a>,

Source§

impl<T: Encode> AbiEncodeWith<Ink> for T