Enum syn_solidity::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) -> Result<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 parse_payable(self, input: ParseStream<'_>) -> Result<Self>

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

source

pub const fn is_one_word(&self) -> bool

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

source

pub fn is_abi_dynamic(&self) -> bool

Returns whether this type is dynamic according to ABI rules.

source

pub const fn is_value_type(&self) -> bool

Returns whether this type is a value type.

These types’ variables are always passed by value.

See the Solidity docs 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

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