Struct alloy_json_abi::Param

source ·
pub struct Param {
    pub components: Vec<Param>,
    pub internal_type: Option<InternalType>,
    /* private fields */
}
Expand description

JSON specification of a parameter.

Parameters are the inputs and outputs of Functions, and the fields of Errors.

Fields§

§components: Vec<Param>

If the paramaeter is a compound type (a struct or tuple), a list of the parameter’s components, in order. Empty otherwise

§internal_type: Option<InternalType>

The internal type of the parameter. This type represents the type that the author of the Solidity contract specified. E.g. for a contract, this will be contract MyContract while the type field will be address.

Implementations§

source§

impl Param

source

pub fn parse(input: &str) -> Result<Self>

Parse a parameter from a Solidity parameter string.

§Examples
assert_eq!(
    Param::parse("uint256[] foo"),
    Ok(Param {
        name: "foo".into(),
        ty: "uint256[]".into(),
        components: vec![],
        internal_type: None,
    })
);
source

pub fn new( name: &str, ty: &str, components: Vec<Self>, internal_type: Option<InternalType>, ) -> Result<Self>

Validate and create new instance of Param.

source

pub const fn internal_type(&self) -> Option<&InternalType>

The internal type of the parameter.

source

pub fn is_udt(&self) -> bool

True if the parameter is a UDT (user-defined type).

A UDT will have

  • an internal type that does not match its canonical type
  • no space in its internal type (as it does not have a keyword body)

Any Other specifier will definitely be a UDT if it contains a contract.

source

pub const fn is_struct(&self) -> bool

True if the parameter is a struct.

source

pub const fn is_enum(&self) -> bool

True if the parameter is an enum.

source

pub const fn is_contract(&self) -> bool

True if the parameter is a contract.

source

pub fn udt_specifier(&self) -> Option<TypeSpecifier<'_>>

The UDT specifier is a TypeSpecifier containing the UDT name and any array sizes. It is computed from the internal_type. If this param is not a UDT, this function will return None.

source

pub fn struct_specifier(&self) -> Option<TypeSpecifier<'_>>

The struct specifier is a TypeSpecifier containing the struct name and any array sizes. It is computed from the internal_type If this param is not a struct, this function will return None.

source

pub fn enum_specifier(&self) -> Option<TypeSpecifier<'_>>

The enum specifier is a TypeSpecifier containing the enum name and any array sizes. It is computed from the internal_type. If this param is not a enum, this function will return None.

source

pub fn contract_specifier(&self) -> Option<TypeSpecifier<'_>>

The struct specifier is a TypeSpecifier containing the contract name and any array sizes. It is computed from the internal_type If this param is not a struct, this function will return None.

source

pub fn is_simple_type(&self) -> bool

True if the type is simple

source

pub fn is_complex_type(&self) -> bool

True if the type is complex (tuple or struct)

source

pub fn selector_type_raw(&self, s: &mut String)

Formats the canonical type of this parameter into the given string.

This is used to encode the preimage of a function or error selector.

source

pub fn full_selector_type_raw(&self, s: &mut String)

Formats the canonical type of this parameter into the given string including then names of the params.

source

pub fn selector_type(&self) -> Cow<'_, str>

Returns the canonical type of this parameter.

This is used to encode the preimage of a function or error selector.

Trait Implementations§

source§

impl Clone for Param

source§

fn clone(&self) -> Param

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 Param

source§

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

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

impl Default for Param

source§

fn default() -> Param

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

impl<'de> Deserialize<'de> for Param

source§

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

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

impl Display for Param

source§

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

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

impl FromStr for Param

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Param

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Param

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Param

source§

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

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

impl Eq for Param

source§

impl StructuralPartialEq for Param

Auto Trait Implementations§

§

impl Freeze for Param

§

impl RefUnwindSafe for Param

§

impl Send for Param

§

impl Sync for Param

§

impl Unpin for Param

§

impl UnwindSafe for Param

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> 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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,