Struct Resolver

Source
pub struct Resolver { /* private fields */ }
Available on crate feature dyn-abi only.
Expand description

A dependency graph built from the Eip712Types object. This is used to safely resolve JSON into a crate::DynSolType by detecting cycles in the type graph and traversing the dep graph.

Implementations§

Source§

impl Resolver

Source

pub fn from_struct<S>() -> Resolver
where S: SolStruct,

Available on crate feature eip712 only.

Instantiate a new resolver from a SolStruct type.

Source

pub fn ingest_string(&mut self, s: impl AsRef<str>) -> Result<(), Error>

Available on crate feature eip712 only.

Ingest types from an EIP-712 encodeType.

Source

pub fn ingest_sol_struct<S>(&mut self)
where S: SolStruct,

Available on crate feature eip712 only.

Ingest a sol struct typedef.

Source

pub fn ingest(&mut self, type_def: TypeDef)

Available on crate feature eip712 only.

Ingest a type.

Source

pub fn ingest_types(&mut self, types: &Eip712Types)

Available on crate feature eip712 only.

Ingest a Types object into the resolver, discarding any invalid types.

Source

pub fn linearize(&self, type_name: &str) -> Result<Vec<&TypeDef>, Error>

Available on crate feature eip712 only.

This function linearizes a type into a list of typedefs of its dependencies.

Source

pub fn resolve(&self, type_name: &str) -> Result<DynSolType, Error>

Available on crate feature eip712 only.

Resolve a typename into a crate::DynSolType or return an error if the type is missing, or contains a circular dependency.

Source

pub fn encode_type(&self, name: &str) -> Result<String, Error>

Available on crate feature eip712 only.

Encode the type into an EIP-712 encodeType string

https://eips.ethereum.org/EIPS/eip-712#definition-of-encodetype

Source

pub fn type_hash(&self, name: &str) -> Result<FixedBytes<32>, Error>

Available on crate feature eip712 only.

Compute the keccak256 hash of the EIP-712 encodeType string.

Source

pub fn encode_data(&self, value: &DynSolValue) -> Result<Option<Vec<u8>>, Error>

Available on crate feature eip712 only.

Encode the data according to EIP-712 encodeData rules.

Source

pub fn eip712_data_word( &self, value: &DynSolValue, ) -> Result<FixedBytes<32>, Error>

Available on crate feature eip712 only.

Encode the data as a struct property according to EIP-712 encodeData rules. Atomic types are encoded as-is, while non-atomic types are encoded as their encodeData hash.

Source

pub fn contains_type_name(&self, name: &str) -> bool

Available on crate feature eip712 only.

Check if the resolver graph contains a type by its name.

§Warning

This checks by NAME only. It does NOT check for type

Trait Implementations§

Source§

impl Clone for Resolver

Source§

fn clone(&self) -> Resolver

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Resolver

Source§

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

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

impl Default for Resolver

Source§

fn default() -> Resolver

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

impl<'de> Deserialize<'de> for Resolver

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Resolver, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&Eip712Types> for Resolver

Source§

fn from(types: &Eip712Types) -> Resolver

Converts to this type from the input type.
Source§

impl From<&Resolver> for Eip712Types

Source§

fn from(resolver: &Resolver) -> Eip712Types

Converts to this type from the input type.
Source§

impl From<Eip712Types> for Resolver

Source§

fn from(types: Eip712Types) -> Resolver

Converts to this type from the input type.
Source§

impl PartialEq for Resolver

Source§

fn eq(&self, other: &Resolver) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Resolver

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Resolver

Source§

impl StructuralPartialEq for Resolver

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, dst: *mut u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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: 48 bytes