syn_solidity

Enum Type

Source
pub enum Type {
    Address(Span, Option<payable>),
    Bool(Span),
    String(Span),
    Bytes(Span),
    FixedBytes(Span, NonZeroU16),
    Int(Span, Option<NonZeroU16>),
    Uint(Span, Option<NonZeroU16>),
    Array(TypeArray),
    Tuple(TypeTuple),
    Function(TypeFunction),
    Mapping(TypeMapping),
    Custom(SolPath),
}
Expand description

Variants§

§

Address(Span, Option<payable>)

address $(payable)?

§

Bool(Span)

bool

§

String(Span)

string

§

Bytes(Span)

bytes

§

FixedBytes(Span, NonZeroU16)

bytes<size>

§

Int(Span, Option<NonZeroU16>)

int[size]

§

Uint(Span, Option<NonZeroU16>)

uint[size]

§

Array(TypeArray)

$ty[$($size)?]

§

Tuple(TypeTuple)

$(tuple)? ( $($types,)* )

§

Function(TypeFunction)

function($($arguments),*) $($attributes)* $(returns ($($returns),+))?

§

Mapping(TypeMapping)

mapping($key $($key_name)? => $value $($value_name)?)

§

Custom(SolPath)

A custom type.

Implementations§

Source§

impl Type

Source

pub fn custom(ident: Ident) -> Self

Source

pub fn peek(lookahead: &Lookahead1<'_>) -> bool

Source

pub fn parse_ident(ident: Ident) -> Self

Parses an identifier as an elementary type name.

Note that you will have to check for the existence of a payable keyword separately.

Source

pub fn try_parse_ident(ident: Ident) -> Result<Self>

Source

pub fn parse_payable(self, input: ParseStream<'_>) -> Self

Parses the payable keyword from the input stream if this type is an address.

Source

pub fn is_one_word( &self, custom_is_value_type: impl Fn(&SolPath) -> bool, ) -> bool

👎Deprecated: use is_value_type instead

Returns whether this type is ABI-encoded as a single EVM word (32 bytes).

This is the same as is_value_type.

Source

pub fn is_abi_dynamic(&self) -> bool

Returns whether this type is dynamic according to ABI rules.

Note that this does not account for custom types, such as UDVTs.

Source

pub fn is_value_type( &self, custom_is_value_type: impl Fn(&SolPath) -> bool, ) -> bool

Returns whether this type is a value type.

These types’ variables are always passed by value.

custom_is_value_type accounts for custom value types.

See the Solidity docs for more information.

Source

pub fn is_value_type_simple(&self) -> bool

Returns whether this type is a simple value type.

See is_value_type for more information.

Source

pub const fn is_array(&self) -> bool

Source

pub const fn is_tuple(&self) -> bool

Source

pub const fn is_custom(&self) -> bool

Source

pub fn has_custom(&self) -> bool

Recurses into this type and returns whether it contains a custom type.

Source

pub fn has_custom_simple(&self) -> bool

Same as has_custom, but Function returns false rather than recursing into its arguments and return types.

Source

pub fn peel_arrays(&self) -> &Self

Returns the inner type.

Source

pub fn abi_name(&self) -> String

Returns the Solidity ABI name for this type. This is tuple for custom types, otherwise the same as Display.

Source

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

Returns the Solidity ABI name for this type. This is tuple for custom types, otherwise the same as Display.

Source

pub fn visit(&self, f: impl FnMut(&Self))

Available on crate feature visit only.

Traverses this type while calling f.

Source

pub fn visit_mut(&mut self, f: impl FnMut(&mut Self))

Available on crate feature visit-mut only.

Traverses this type while calling f.

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

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 Type

Source§

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

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

impl Display for Type

Canonical type name formatting, used in selector preimages.

Source§

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

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

impl FromIterator<Type> for TypeTuple

Source§

fn from_iter<T: IntoIterator<Item = Type>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Type

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 Parse for Type

Source§

fn parse(input: ParseStream<'_>) -> Result<Self>

Source§

impl PartialEq for Type

Source§

fn eq(&self, other: &Self) -> 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 Spanned for Type

Source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
Source§

fn set_span(&mut self, new_span: Span)

Sets the span of this syntax tree node if it is not empty.
Source§

fn with_span(self, span: Span) -> Self
where Self: Sized,

Sets the span of this owned syntax tree node if it is not empty.
Source§

impl Eq for Type

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl !Send for Type

§

impl !Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

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

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

Source§

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

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.

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

Size for each variant:

  • Address: 32 bytes
  • Bool: 20 bytes
  • String: 20 bytes
  • Bytes: 20 bytes
  • FixedBytes: 24 bytes
  • Int: 24 bytes
  • Uint: 24 bytes
  • Array: 40 bytes
  • Tuple: 64 bytes
  • Function: 136 bytes
  • Mapping: 136 bytes
  • Custom: 40 bytes