[][src]Struct ink_metadata::TypeSpec

pub struct TypeSpec<F: Form = MetaForm> { /* fields omitted */ }

A type specification.

This contains the actual type as well as an optional compile-time known displayed representation of the type. This is useful for cases where the type is used through a type alias in order to provide information about the alias name.

Examples

Consider the following Rust function:

fn is_sorted(input: &[i32], pred: Predicate) -> bool;

In this above example input would have no displayable name, pred's display name is Predicate and the display name of the return type is simply bool. Note that Predicate could simply be a type alias to fn(i32, i32) -> Ordering.

Implementations

impl TypeSpec[src]

pub fn with_name_str<T>(display_name: &'static str) -> Self where
    T: TypeInfo + 'static, 
[src]

Creates a new type specification with a display name.

The name is any valid Rust identifier or path.

Examples

Valid display names are foo, foo::bar, foo::bar::Baz, etc.

Panics

Panics if the given display name is invalid.

pub fn with_name_segs<T, S>(segments: S) -> Self where
    T: TypeInfo + 'static,
    S: IntoIterator<Item = &'static str>, 
[src]

Creates a new type specification with a display name represented by the given path segments.

The display name segments all must be valid Rust identifiers.

Examples

Valid display names are foo, foo::bar, foo::bar::Baz, etc.

Panics

Panics if the given display name is invalid.

pub fn new<T>() -> Self where
    T: TypeInfo + 'static, 
[src]

Creates a new type specification without a display name.

impl<F> TypeSpec<F> where
    F: Form
[src]

pub fn ty(&self) -> &F::Type[src]

Returns the actual type.

pub fn display_name(&self) -> &DisplayName<F>[src]

Returns the compile-time known displayed representation of the type.

Trait Implementations

impl<F: Debug + Form> Debug for TypeSpec<F> where
    F::Type: Debug
[src]

impl<'de, F: Form> Deserialize<'de> for TypeSpec<F> where
    F::Type: DeserializeOwned,
    F::String: DeserializeOwned
[src]

impl<F: Eq + Form> Eq for TypeSpec<F> where
    F::Type: Eq
[src]

impl IntoCompact for TypeSpec[src]

type Output = TypeSpec<CompactForm>

The compact version of Self.

impl<F: PartialEq + Form> PartialEq<TypeSpec<F>> for TypeSpec<F> where
    F::Type: PartialEq
[src]

impl<F: Form> Serialize for TypeSpec<F> where
    F::Type: Serialize,
    F::String: Serialize
[src]

impl<F: Form> StructuralEq for TypeSpec<F>[src]

impl<F: Form> StructuralPartialEq for TypeSpec<F>[src]

Auto Trait Implementations

impl<F> RefUnwindSafe for TypeSpec<F> where
    <F as Form>::String: RefUnwindSafe,
    <F as Form>::Type: RefUnwindSafe

impl<F> Send for TypeSpec<F> where
    <F as Form>::String: Send,
    <F as Form>::Type: Send

impl<F> Sync for TypeSpec<F> where
    <F as Form>::String: Sync,
    <F as Form>::Type: Sync

impl<F> Unpin for TypeSpec<F> where
    <F as Form>::String: Unpin,
    <F as Form>::Type: Unpin

impl<F> UnwindSafe for TypeSpec<F> where
    <F as Form>::String: UnwindSafe,
    <F as Form>::Type: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.