[][src]Struct scale_info::Field

pub struct Field<T: Form = MetaForm> { /* fields omitted */ }

A field of a struct like data type.

Name is optional so it can represent both named and unnamed fields.

This can be a named field of a struct type or a struct variant.

Implementations

impl Field[src]

pub fn new(name: Option<&'static str>, ty: MetaType) -> Self[src]

Creates a new field.

Use this constructor if you want to instantiate from a given meta type.

pub fn named(name: &'static str, ty: MetaType) -> Self[src]

Creates a new named field

pub fn named_of<T: ?Sized>(name: &'static str) -> Self where
    T: TypeInfo + 'static, 
[src]

Creates a new named field.

Use this constructor if you want to instantiate from a given compile-time type.

pub fn unnamed(meta_type: MetaType) -> Self[src]

Creates a new unnamed field.

Use this constructor if you want to instantiate an unnamed field from a given meta type.

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

Creates a new unnamed field.

Use this constructor if you want to instantiate an unnamed field from a given compile-time type.

impl<T> Field<T> where
    T: Form
[src]

pub fn name(&self) -> Option<&T::String>[src]

Returns the name of the field. None for unnamed fields.

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

Returns the type of the field.

Trait Implementations

impl<T: Clone + Form> Clone for Field<T> where
    T::String: Clone,
    T::Type: Clone
[src]

impl<T: Debug + Form> Debug for Field<T> where
    T::String: Debug,
    T::Type: Debug
[src]

impl<T: Form> Decode for Field<T> where
    Option<T::String>: Decode,
    Option<T::String>: Decode,
    T::Type: Decode,
    T::Type: Decode
[src]

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

impl<T: Form> Encode for Field<T> where
    Option<T::String>: Encode,
    Option<T::String>: Encode,
    T::Type: Encode,
    T::Type: Encode
[src]

impl<T: Form> EncodeLike<Field<T>> for Field<T> where
    Option<T::String>: Encode,
    Option<T::String>: Encode,
    T::Type: Encode,
    T::Type: Encode
[src]

impl<T: Eq + Form> Eq for Field<T> where
    T::String: Eq,
    T::Type: Eq
[src]

impl IntoCompact for Field[src]

type Output = Field<CompactForm>

The compact version of Self.

impl<T: Ord + Form> Ord for Field<T> where
    T::String: Ord,
    T::Type: Ord
[src]

impl<T: PartialEq + Form> PartialEq<Field<T>> for Field<T> where
    T::String: PartialEq,
    T::Type: PartialEq
[src]

impl<T: PartialOrd + Form> PartialOrd<Field<T>> for Field<T> where
    T::String: PartialOrd,
    T::Type: PartialOrd
[src]

impl<T: Form> Serialize for Field<T> where
    T::Type: Serialize,
    T::String: Serialize
[src]

impl<T: Form> StructuralEq for Field<T>[src]

impl<T: Form> StructuralPartialEq for Field<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Field<T> where
    <T as Form>::String: RefUnwindSafe,
    <T as Form>::Type: RefUnwindSafe

impl<T> Send for Field<T> where
    <T as Form>::String: Send,
    <T as Form>::Type: Send

impl<T> Sync for Field<T> where
    <T as Form>::String: Sync,
    <T as Form>::Type: Sync

impl<T> Unpin for Field<T> where
    <T as Form>::String: Unpin,
    <T as Form>::Type: Unpin

impl<T> UnwindSafe for Field<T> where
    <T as Form>::String: UnwindSafe,
    <T 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<S> Codec for S where
    S: Encode + Decode
[src]

impl<T, X> Decode for X where
    T: Decode + Into<X>,
    X: WrapperTypeDecode<Wrapped = T>, 
[src]

impl<T> DecodeAll for T where
    T: Decode
[src]

impl<T> DecodeLimit for T where
    T: Decode
[src]

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

impl<T, X> Encode for X where
    T: Encode + ?Sized,
    X: WrapperTypeEncode<Target = T>, 
[src]

impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ mut T> for T where
    T: Encode
[src]

impl<T> EncodeLike<Arc<T>> for T where
    T: Encode
[src]

impl<T> EncodeLike<Box<T>> for T where
    T: Encode
[src]

impl<'a, T> EncodeLike<Cow<'a, T>> for T where
    T: Encode + ToOwned
[src]

impl<T> EncodeLike<Rc<T>> for T where
    T: Encode
[src]

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

impl<S> FullCodec for S where
    S: Decode + FullEncode
[src]

impl<S> FullEncode for S where
    S: Encode + EncodeLike<S>, 
[src]

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

impl<T> KeyedVec for T where
    T: Codec
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.