[][src]Struct scale_info::Variant

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

A struct enum variant with either named (struct) or unnamed (tuple struct) fields.

Example

enum Operation {
    Zero,
//  ^^^^ this is a unit struct enum variant
    Add(i32, i32),
//  ^^^^^^^^^^^^^ this is a tuple-struct enum variant
    Minus { source: i32 }
//  ^^^^^^^^^^^^^^^^^^^^^ this is a struct enum variant
}

Implementations

impl Variant[src]

pub fn with_fields<F>(name: &'static str, fields: FieldsBuilder<F>) -> Self[src]

Creates a new variant with the given fields.

pub fn with_discriminant(name: &'static str, discriminant: u64) -> Self[src]

Creates a new variant with the given discriminant.

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

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

Returns the name of the variant

pub fn fields(&self) -> &[Field<T>]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
[src]

Returns the fields of the struct variant.

pub fn discriminant(&self) -> Option<u64>[src]

Returns the discriminant of the variant.

Trait Implementations

impl<T: Clone + Form> Clone for Variant<T> where
    T::String: Clone
[src]

impl<T: Debug + Form> Debug for Variant<T> where
    T::String: Debug
[src]

impl<T: Form> Decode for Variant<T> where
    T::String: Decode,
    T::String: Decode,
    Vec<Field<T>>: Decode,
    Vec<Field<T>>: Decode
[src]

impl<T: Form> Encode for Variant<T> where
    T::String: Encode,
    T::String: Encode,
    Vec<Field<T>>: Encode,
    Vec<Field<T>>: Encode
[src]

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

impl<T: Eq + Form> Eq for Variant<T> where
    T::String: Eq
[src]

impl IntoPortable for Variant[src]

type Output = Variant<PortableForm>

The portable version of Self.

impl<T: Ord + Form> Ord for Variant<T> where
    T::String: Ord
[src]

impl<T: PartialEq + Form> PartialEq<Variant<T>> for Variant<T> where
    T::String: PartialEq
[src]

impl<T: PartialOrd + Form> PartialOrd<Variant<T>> for Variant<T> where
    T::String: PartialOrd
[src]

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

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

Auto Trait Implementations

impl<T> RefUnwindSafe for Variant<T> where
    <T as Form>::String: RefUnwindSafe,
    <T as Form>::Type: RefUnwindSafe
[src]

impl<T> Send for Variant<T> where
    <T as Form>::String: Send,
    <T as Form>::Type: Send
[src]

impl<T> Sync for Variant<T> where
    <T as Form>::String: Sync,
    <T as Form>::Type: Sync
[src]

impl<T> Unpin for Variant<T> where
    <T as Form>::String: Unpin,
    <T as Form>::Type: Unpin
[src]

impl<T> UnwindSafe for Variant<T> where
    <T as Form>::String: UnwindSafe,
    <T as Form>::Type: UnwindSafe
[src]

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> DecodeAll for T where
    T: Decode
[src]

impl<T> DecodeLimit for T where
    T: Decode
[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, Global>> 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.