[−][src]Struct ink_metadata::TypeSpec
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]
T: TypeInfo + 'static,
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]
T: TypeInfo + 'static,
S: IntoIterator<Item = &'static str>,
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]
T: TypeInfo + 'static,
Creates a new type specification without a display name.
impl<F> TypeSpec<F> where
F: Form,
[src]
F: Form,
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]
F::Type: Debug,
impl<'de, F: Form> Deserialize<'de> for TypeSpec<F> where
F::Type: DeserializeOwned,
F::String: DeserializeOwned,
[src]
F::Type: DeserializeOwned,
F::String: DeserializeOwned,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<F: Eq + Form> Eq for TypeSpec<F> where
F::Type: Eq,
[src]
F::Type: Eq,
impl IntoCompact for TypeSpec
[src]
type Output = TypeSpec<CompactForm>
The compact version of Self
.
fn into_compact(self, registry: &mut Registry) -> Self::Output
[src]
impl<F: PartialEq + Form> PartialEq<TypeSpec<F>> for TypeSpec<F> where
F::Type: PartialEq,
[src]
F::Type: PartialEq,
impl<F: Form> Serialize for TypeSpec<F> where
F::Type: Serialize,
F::String: Serialize,
[src]
F::Type: Serialize,
F::String: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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,
<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,
<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,
<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,
<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,
<F as Form>::String: UnwindSafe,
<F as Form>::Type: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,