Skip to main content

FromWord

Trait FromWord 

Source
pub trait FromWord: OnlyPrimitives {
    // Required methods
    fn to_word(&self) -> U256;
    fn from_word(word: U256) -> Result<Self>
       where Self: Sized;
}
Expand description

Trait for primitive types that fit into a single EVM storage slot.

Implementations must produce right-aligned U256 values (data in low bytes) to match EVM storage slot layout expectations.

§Warning

Round-trip conversions must preserve data: from_word(to_word(x)) == x

Required Methods§

Source

fn to_word(&self) -> U256

Encode this type to a single U256 word.

Source

fn from_word(word: U256) -> Result<Self>
where Self: Sized,

Decode this type from a single U256 word.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromWord for Address

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<1usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<2usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<3usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<4usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<5usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<6usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<7usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<8usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<9usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<10usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<11usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<12usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<13usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<14usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<15usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<16usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<17usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<18usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<19usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<20usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<21usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<22usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<23usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<24usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<25usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<26usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<27usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<28usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<29usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<30usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<31usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for FixedBytes<32usize>

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I8

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I16

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I32

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I64

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I96

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I128

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for I256

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U8

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U16

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U32

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U64

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U96

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U128

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for U256

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for bool

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for i8

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for i16

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for i32

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for i64

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for i128

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for u8

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for u16

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for u32

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for u64

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Source§

impl FromWord for u128

Source§

fn to_word(&self) -> U256

Source§

fn from_word(word: U256) -> Result<Self>

Implementors§