pub trait Packable: OnlyPrimitives + StorableType {
// Required methods
fn to_word(&self) -> U256;
fn from_word(word: U256) -> Result<Self>
where Self: Sized;
}Expand description
Trait for types that can be packed into EVM storage slots.
This trait is sealed - it can only be implemented within this crate for primitive types that fit in a single U256 word.
§Usage
Packable is used by the storage packing system to efficiently pack multiple
small values into a single 32-byte storage slot.
§Safety
Implementations must ensure:
IS_PACKABLEis true for the implementing type (enforced at compile time)- Round-trip conversions preserve data:
from_word(to_word(x)) == x
Required Methods§
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.