pub enum TypeDef<T: Form = MetaForm> {
Composite(TypeDefComposite<T>),
Variant(TypeDefVariant<T>),
Sequence(TypeDefSequence<T>),
Array(TypeDefArray<T>),
Tuple(TypeDefTuple<T>),
Primitive(TypeDefPrimitive),
Compact(TypeDefCompact<T>),
BitSequence(TypeDefBitSequence<T>),
}
Expand description
The possible types a SCALE encodable Rust value could have.
§Note
In order to preserve backwards compatibility, variant indices are explicitly specified instead of depending on the default implicit ordering.
When adding a new variant, it must be added at the end with an incremented index.
When removing an existing variant, the rest of variant indices remain the same, and the removed index should not be reused.
Variants§
Composite(TypeDefComposite<T>)
A composite type (e.g. a struct or a tuple)
Variant(TypeDefVariant<T>)
A variant type (e.g. an enum)
Sequence(TypeDefSequence<T>)
A sequence type with runtime known length.
Array(TypeDefArray<T>)
An array type with compile-time known length.
Tuple(TypeDefTuple<T>)
A tuple type.
Primitive(TypeDefPrimitive)
A Rust primitive type.
Compact(TypeDefCompact<T>)
A type using the [Compact
] encoding
BitSequence(TypeDefBitSequence<T>)
A type representing a sequence of bits.
Trait Implementations§
source§impl<T: Form> Decode for TypeDef<T>where
TypeDefComposite<T>: Decode,
TypeDefVariant<T>: Decode,
TypeDefSequence<T>: Decode,
TypeDefArray<T>: Decode,
TypeDefTuple<T>: Decode,
TypeDefCompact<T>: Decode,
TypeDefBitSequence<T>: Decode,
impl<T: Form> Decode for TypeDef<T>where
TypeDefComposite<T>: Decode,
TypeDefVariant<T>: Decode,
TypeDefSequence<T>: Decode,
TypeDefArray<T>: Decode,
TypeDefTuple<T>: Decode,
TypeDefCompact<T>: Decode,
TypeDefBitSequence<T>: Decode,
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>
Attempt to deserialise the value from input.
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
source§impl<T: Form> Encode for TypeDef<T>where
TypeDefComposite<T>: Encode,
TypeDefVariant<T>: Encode,
TypeDefSequence<T>: Encode,
TypeDefArray<T>: Encode,
TypeDefTuple<T>: Encode,
TypeDefCompact<T>: Encode,
TypeDefBitSequence<T>: Encode,
impl<T: Form> Encode for TypeDef<T>where
TypeDefComposite<T>: Encode,
TypeDefVariant<T>: Encode,
TypeDefSequence<T>: Encode,
TypeDefArray<T>: Encode,
TypeDefTuple<T>: Encode,
TypeDefCompact<T>: Encode,
TypeDefBitSequence<T>: Encode,
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Convert self to a slice and append it to the destination.
source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
source§impl<F: Form> From<TypeDefArray<F>> for TypeDef<F>
impl<F: Form> From<TypeDefArray<F>> for TypeDef<F>
source§fn from(x: TypeDefArray<F>) -> Self
fn from(x: TypeDefArray<F>) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefBitSequence<F>> for TypeDef<F>
impl<F: Form> From<TypeDefBitSequence<F>> for TypeDef<F>
source§fn from(x: TypeDefBitSequence<F>) -> Self
fn from(x: TypeDefBitSequence<F>) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefCompact<F>> for TypeDef<F>
impl<F: Form> From<TypeDefCompact<F>> for TypeDef<F>
source§fn from(x: TypeDefCompact<F>) -> Self
fn from(x: TypeDefCompact<F>) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefComposite<F>> for TypeDef<F>
impl<F: Form> From<TypeDefComposite<F>> for TypeDef<F>
source§fn from(x: TypeDefComposite<F>) -> Self
fn from(x: TypeDefComposite<F>) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefPrimitive> for TypeDef<F>
impl<F: Form> From<TypeDefPrimitive> for TypeDef<F>
source§fn from(x: TypeDefPrimitive) -> Self
fn from(x: TypeDefPrimitive) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefSequence<F>> for TypeDef<F>
impl<F: Form> From<TypeDefSequence<F>> for TypeDef<F>
source§fn from(x: TypeDefSequence<F>) -> Self
fn from(x: TypeDefSequence<F>) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefTuple<F>> for TypeDef<F>
impl<F: Form> From<TypeDefTuple<F>> for TypeDef<F>
source§fn from(x: TypeDefTuple<F>) -> Self
fn from(x: TypeDefTuple<F>) -> Self
Converts to this type from the input type.
source§impl<F: Form> From<TypeDefVariant<F>> for TypeDef<F>
impl<F: Form> From<TypeDefVariant<F>> for TypeDef<F>
source§fn from(x: TypeDefVariant<F>) -> Self
fn from(x: TypeDefVariant<F>) -> Self
Converts to this type from the input type.
source§impl IntoPortable for TypeDef
impl IntoPortable for TypeDef
source§type Output = TypeDef<PortableForm>
type Output = TypeDef<PortableForm>
The portable version of
Self
.source§fn into_portable(self, registry: &mut Registry) -> Self::Output
fn into_portable(self, registry: &mut Registry) -> Self::Output
Convert
self
to the portable form by using the registry for caching.source§impl<T: Ord + Form> Ord for TypeDef<T>
impl<T: Ord + Form> Ord for TypeDef<T>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialOrd + Form> PartialOrd for TypeDef<T>
impl<T: PartialOrd + Form> PartialOrd for TypeDef<T>
impl<T: Form> EncodeLike for TypeDef<T>where
TypeDefComposite<T>: Encode,
TypeDefVariant<T>: Encode,
TypeDefSequence<T>: Encode,
TypeDefArray<T>: Encode,
TypeDefTuple<T>: Encode,
TypeDefCompact<T>: Encode,
TypeDefBitSequence<T>: Encode,
impl<T: Eq + Form> Eq for TypeDef<T>
impl<T: Form> StructuralPartialEq for TypeDef<T>
Auto Trait Implementations§
impl<T> Freeze for TypeDef<T>
impl<T> RefUnwindSafe for TypeDef<T>
impl<T> Send for TypeDef<T>
impl<T> Sync for TypeDef<T>
impl<T> Unpin for TypeDef<T>
impl<T> UnwindSafe for TypeDef<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)