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
A type name.
Solidity reference: https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.typeName
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
impl Type
pub fn custom(ident: Ident) -> Self
pub fn peek(lookahead: &Lookahead1<'_>) -> bool
sourcepub fn parse_ident(ident: Ident) -> Result<Self>
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.
sourcepub fn parse_payable(self, input: ParseStream<'_>) -> Result<Self>
pub fn parse_payable(self, input: ParseStream<'_>) -> Result<Self>
Parses the payable
keyword from the input stream if this type is an
address.
sourcepub const fn is_one_word(&self) -> bool
pub const fn is_one_word(&self) -> bool
Returns whether this type is ABI-encoded as a single EVM word (32 bytes).
sourcepub fn is_abi_dynamic(&self) -> bool
pub fn is_abi_dynamic(&self) -> bool
Returns whether this type is dynamic according to ABI rules.
pub const fn is_array(&self) -> bool
pub const fn is_tuple(&self) -> bool
pub const fn is_custom(&self) -> bool
sourcepub fn has_custom(&self) -> bool
pub fn has_custom(&self) -> bool
Recurses into this type and returns whether it contains a custom type.