pub struct TypeSpecifier<'a> {
pub span: &'a str,
pub stem: TypeStem<'a>,
pub sizes: Vec<Option<NonZeroUsize>>,
}Expand description
Represents a type-name. Consists of an identifier and optional array sizes.
A type specifier has a stem, which is TypeStem representing either a
RootType or a TupleSpecifier, and a list of array sizes. The array
sizes are in innermost-to-outermost order. An empty array size vec indicates
that the specified type is not an array
Type specifier examples:
uint256uint256[2]uint256[2][](uint256,uint256)(uint256,uint256)[2]MyStructMyStruct[2]
https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.typeName
§Compatibility with JSON ABI
This type supports the internalType semantics for JSON-ABI compatibility.
Examples of valid JSON ABI internal types:
contract MyContractstruct MyStructenum MyEnumstruct MyContract.MyStruct\[333\]enum MyContract.MyEnum[][][][][][]MyValueType
§Examples
let spec = TypeSpecifier::parse("uint256[2][]")?;
assert_eq!(spec.span(), "uint256[2][]");
assert_eq!(spec.stem.span(), "uint256");
// The sizes are in innermost-to-outermost order.
assert_eq!(spec.sizes.as_slice(), &[NonZeroUsize::new(2), None]);Fields§
§span: &'a strThe full span of the specifier.
stem: TypeStem<'a>The type stem, which is either a root type or a tuple type.
sizes: Vec<Option<NonZeroUsize>>Array sizes, in innermost-to-outermost order. If the size is None,
then the array is dynamic. If the size is Some, then the array is
fixed-size. If the vec is empty, then the type is not an array.
Implementations§
Source§impl<'a> TypeSpecifier<'a>
impl<'a> TypeSpecifier<'a>
Sourcepub fn parse_eip712(s: &'a str) -> Result<Self>
Available on crate feature eip712 only.
pub fn parse_eip712(s: &'a str) -> Result<Self>
eip712 only.Parse a type specifier from a string with support for : in identifiers.
Extends the standard type parsing.
Sourcepub fn try_basic_solidity(&self) -> Result<()>
pub fn try_basic_solidity(&self) -> Result<()>
Returns true if the type is a basic Solidity type.
Trait Implementations§
Source§impl AsRef<str> for TypeSpecifier<'_>
impl AsRef<str> for TypeSpecifier<'_>
Source§impl<'a> Clone for TypeSpecifier<'a>
impl<'a> Clone for TypeSpecifier<'a>
Source§fn clone(&self) -> TypeSpecifier<'a>
fn clone(&self) -> TypeSpecifier<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for TypeSpecifier<'a>
impl<'a> Debug for TypeSpecifier<'a>
Source§impl<'a> PartialEq for TypeSpecifier<'a>
impl<'a> PartialEq for TypeSpecifier<'a>
Source§impl<'a> TryFrom<&'a str> for TypeSpecifier<'a>
impl<'a> TryFrom<&'a str> for TypeSpecifier<'a>
impl<'a> Eq for TypeSpecifier<'a>
impl<'a> StructuralPartialEq for TypeSpecifier<'a>
Auto Trait Implementations§
impl<'a> Freeze for TypeSpecifier<'a>
impl<'a> RefUnwindSafe for TypeSpecifier<'a>
impl<'a> Send for TypeSpecifier<'a>
impl<'a> Sync for TypeSpecifier<'a>
impl<'a> Unpin for TypeSpecifier<'a>
impl<'a> UnwindSafe for TypeSpecifier<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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: 40 bytes