Skip to main content

AbiDecoderConfig

Struct AbiDecoderConfig 

Source
pub struct AbiDecoderConfig { /* private fields */ }
Expand description

Configuration for ABI decoding.

Implementations§

Source§

impl AbiDecoderConfig

Source

pub const fn new() -> Self

Creates a decoder configuration with the default limits.

Source

pub const fn get_recursion_limit(&self) -> usize

Returns the maximum recursion depth.

Source

pub const fn get_memory_limit(&self) -> usize

Returns the maximum amount of memory that decoding may allocate.

Source

pub const fn get_validate(&self) -> bool

Returns whether decoded tokens are validated before detokenization.

Source

pub const fn get_strict(&self) -> bool

Returns whether strict ABI encoding is required.

Trailing bytes are permitted when get_validate_allow_trailing_bytes is enabled.

Source

pub const fn get_validate_allow_trailing_bytes(&self) -> bool

Returns whether strict validation permits trailing bytes.

Source

pub const fn recursion_limit(self, limit: usize) -> Self

Sets the maximum recursion depth.

Source

pub const fn memory_limit(self, limit: usize) -> Self

Sets the maximum amount of memory that decoding may allocate.

Source

pub const fn validate(self, validate: bool) -> Self

Enables or disables decoded token validation before detokenization.

When enabled, high-level ABI decode helpers call the target Solidity type’s token validator before converting the token into the returned Rust value. This rejects dirty bool bytes, invalid strings, and other token values that can be decoded from ABI words but do not satisfy the target type’s validity rules.

Source

pub const fn strict(self, strict: bool) -> Self

Requires strictly ABI-encoded input.

Strict mode implies validate. It also rejects gaps or overlaps between dynamic data areas while decoding. Trailing bytes are rejected unless validate_allow_trailing_bytes is enabled.

Source

pub const fn validate_allow_trailing_bytes(self, allow: bool) -> Self

Allows trailing bytes when strict ABI decoding is enabled.

This does not enable strict or validate. In strict mode, it skips the final check that the encoding consumes the entire input. All other strict checks, including canonical offsets, complete zero padding, and token validation, remain enabled. This matches Solidity’s acceptance of trailing bytes only; it does not relax the other checks that Solidity omits. Without strict mode, trailing bytes are already permitted.

This option permits trailing bytes even when strict(true) is also set, regardless of setter order. Disabling it leaves the other configuration flags unchanged.

use alloy_sol_types::{SolType, abi::AbiDecoderConfig, sol_data::Uint};

let mut data = Uint::<8>::abi_encode(&42);
data.extend_from_slice(&[0xaa, 0xbb]);
let config = AbiDecoderConfig::new().strict(true).validate_allow_trailing_bytes(true);
assert_eq!(Uint::<8>::abi_decode_with_config(&data, config)?, 42);
Source

pub const fn set_recursion_limit(&mut self, limit: usize)

Sets the maximum recursion depth in place.

Source

pub const fn set_memory_limit(&mut self, limit: usize)

Sets the maximum amount of memory that decoding may allocate in place.

Source

pub const fn set_validate(&mut self, validate: bool)

Enables or disables decoded token validation before detokenization.

Source

pub const fn set_strict(&mut self, strict: bool)

Requires or allows non-strict ABI encoding in place.

Source

pub const fn set_validate_allow_trailing_bytes(&mut self, allow: bool)

Trait Implementations§

Source§

impl Clone for AbiDecoderConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AbiDecoderConfig

Source§

impl Debug for AbiDecoderConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AbiDecoderConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes