pub struct EnumVariantSchema {
pub discriminant: u32,
pub name: String,
pub payload: Box<DynamicSchema>,
}Expand description
One variant of a DynamicSchema::Enum description.
discriminant is the varint u32 postcard writes for this
variant (postcard uses the Rust enum’s declaration order, so the
first variant has discriminant 0, the second 1, and so on —
#[serde(other)] / explicit discriminants change this). name
is the Rust variant identifier carried through to the decoded
Dynamic::Enum so a Migrate::migrate
impl can distinguish variants by name. payload is the variant’s
inner shape, Boxed because DynamicSchema is self-referential.
Fields§
§discriminant: u32Postcard’s varint u32 discriminant for this variant.
name: StringThe Rust variant identifier, carried into
Dynamic::Enum verbatim.
payload: Box<DynamicSchema>Wire shape of the variant’s payload. Use
DynamicSchema::Null for unit variants;
DynamicSchema::Map for tuple and struct variants
(synthetic numeric names for tuple variants); the inner
type’s schema for newtype variants.
Implementations§
Source§impl EnumVariantSchema
impl EnumVariantSchema
Sourcepub fn new<S: Into<String>>(
discriminant: u32,
name: S,
payload: DynamicSchema,
) -> Self
pub fn new<S: Into<String>>( discriminant: u32, name: S, payload: DynamicSchema, ) -> Self
Convenience constructor: lift a (discriminant, name, payload)
triple into an EnumVariantSchema. The Box around the
payload is added internally.
Trait Implementations§
Source§impl Clone for EnumVariantSchema
impl Clone for EnumVariantSchema
Source§fn clone(&self) -> EnumVariantSchema
fn clone(&self) -> EnumVariantSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EnumVariantSchema
impl Debug for EnumVariantSchema
Source§impl PartialEq for EnumVariantSchema
impl PartialEq for EnumVariantSchema
Source§fn eq(&self, other: &EnumVariantSchema) -> bool
fn eq(&self, other: &EnumVariantSchema) -> bool
self and other values to be equal, and is used by ==.