pub struct AbiDecoderConfig { /* private fields */ }Expand description
Configuration for ABI decoding.
Implementations§
Source§impl AbiDecoderConfig
impl AbiDecoderConfig
Sourcepub const fn get_recursion_limit(&self) -> usize
pub const fn get_recursion_limit(&self) -> usize
Returns the maximum recursion depth.
Sourcepub const fn get_memory_limit(&self) -> usize
pub const fn get_memory_limit(&self) -> usize
Returns the maximum amount of memory that decoding may allocate.
Sourcepub const fn get_validate(&self) -> bool
pub const fn get_validate(&self) -> bool
Returns whether decoded tokens are validated before detokenization.
Sourcepub const fn get_strict(&self) -> bool
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.
Sourcepub const fn get_validate_allow_trailing_bytes(&self) -> bool
pub const fn get_validate_allow_trailing_bytes(&self) -> bool
Returns whether strict validation permits trailing bytes.
Sourcepub const fn recursion_limit(self, limit: usize) -> Self
pub const fn recursion_limit(self, limit: usize) -> Self
Sets the maximum recursion depth.
Sourcepub const fn memory_limit(self, limit: usize) -> Self
pub const fn memory_limit(self, limit: usize) -> Self
Sets the maximum amount of memory that decoding may allocate.
Sourcepub const fn validate(self, validate: bool) -> Self
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.
Sourcepub const fn strict(self, strict: bool) -> Self
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.
Sourcepub const fn validate_allow_trailing_bytes(self, allow: bool) -> Self
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);Sourcepub const fn set_recursion_limit(&mut self, limit: usize)
pub const fn set_recursion_limit(&mut self, limit: usize)
Sets the maximum recursion depth in place.
Sourcepub const fn set_memory_limit(&mut self, limit: usize)
pub const fn set_memory_limit(&mut self, limit: usize)
Sets the maximum amount of memory that decoding may allocate in place.
Sourcepub const fn set_validate(&mut self, validate: bool)
pub const fn set_validate(&mut self, validate: bool)
Enables or disables decoded token validation before detokenization.
Sourcepub const fn set_strict(&mut self, strict: bool)
pub const fn set_strict(&mut self, strict: bool)
Requires or allows non-strict ABI encoding in place.
Sourcepub const fn set_validate_allow_trailing_bytes(&mut self, allow: bool)
pub const fn set_validate_allow_trailing_bytes(&mut self, allow: bool)
Sets validate_allow_trailing_bytes in place.
Trait Implementations§
Source§impl Clone for AbiDecoderConfig
impl Clone for AbiDecoderConfig
impl Copy for AbiDecoderConfig
Source§impl Debug for AbiDecoderConfig
impl Debug for AbiDecoderConfig
Auto Trait Implementations§
impl Freeze for AbiDecoderConfig
impl RefUnwindSafe for AbiDecoderConfig
impl Send for AbiDecoderConfig
impl Sync for AbiDecoderConfig
impl Unpin for AbiDecoderConfig
impl UnsafeUnpin for AbiDecoderConfig
impl UnwindSafe for AbiDecoderConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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