Skip to main content

ValueExt

Trait ValueExt 

Source
pub trait ValueExt {
    // Required methods
    fn to_u64(&self) -> Result<u64>;
    fn to_big_int(&self) -> Result<BigInt>;
    fn to_str(&self) -> Result<&str>;
}
Expand description

Decoding helpers for Ethereum-encoded serde_json::Value results.

Implemented for serde_json::Value, so any RPC call result can be decoded in place: rpc.call(...).await?.to_u64()?.

Required Methods§

Source

fn to_u64(&self) -> Result<u64>

Decodes an Ethereum quantity as a u64. Accepts a hex/decimal JSON string (e.g. "0x1b4") or a JSON number.

Source

fn to_big_int(&self) -> Result<BigInt>

Decodes an Ethereum quantity as a BigInt. Accepts a hex/decimal JSON string or a JSON number.

Source

fn to_str(&self) -> Result<&str>

Returns the value as a string slice, erroring if it is not a JSON string.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ValueExt for Value

Implementors§