[][src]Struct scale_info::TypeDefVariant

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

A Enum type (consisting of variants).

Examples

A Rust enum, aka tagged union.

enum MyEnum {
    RustAllowsForClikeVariants,
    AndAlsoForTupleStructs(i32, bool),
    OrStructs {
        with: i32,
        named: bool,
        fields: [u8; 32],
    },
    ItIsntPossibleToSetADiscriminantThough,
}

A C-like enum type.

enum Days {
    Monday,
    Tuesday,
    Wednesday,
    Thursday = 42, // Also allows to manually set the discriminant!
    Friday,
    Saturday,
    Sunday,
}

An empty enum (for marker purposes)

enum JustAMarker {}

Implementations

impl TypeDefVariant[src]

pub fn new<I>(variants: I) -> Self where
    I: IntoIterator<Item = Variant>, 
[src]

Create a new TypeDefVariant with the given variants

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

pub fn variants(&self) -> &[Variant<T>]

Notable traits for &'_ mut [u8]

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

Returns the variants of a variant type

Trait Implementations

impl<T: Clone + Form> Clone for TypeDefVariant<T>[src]

impl<T: Debug + Form> Debug for TypeDefVariant<T>[src]

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

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

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

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

impl<T: Eq + Form> Eq for TypeDefVariant<T>[src]

impl<T: Form> From<TypeDefVariant<T>> for TypeDef<T>[src]

impl<T: Form> From<Vec<Variant<T>>> for TypeDefVariant<T>[src]

impl IntoCompact for TypeDefVariant[src]

type Output = TypeDefVariant<CompactForm>

The compact version of Self.

impl<T: Ord + Form> Ord for TypeDefVariant<T>[src]

impl<T: PartialEq + Form> PartialEq<TypeDefVariant<T>> for TypeDefVariant<T>[src]

impl<T: PartialOrd + Form> PartialOrd<TypeDefVariant<T>> for TypeDefVariant<T>[src]

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

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

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

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for TypeDefVariant<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.