pub struct EnumVariant {
pub name: String,
pub tag: u8,
pub fields: Vec<Field>,
pub is_tuple: bool,
}Expand description
One variant in a canonical #enum description.
Fields§
§name: StringVariant name as declared in source.
tag: u8Stable ABI tag. Tags are assigned in declaration order and must fit in one byte for the current variant-record layout.
fields: Vec<Field>Payload fields. Empty means a unit variant.
is_tuple: booltrue when the payload came from a tuple variant, e.g.
Rgb(Int, Int, Int). Field names are then synthetic decimal
indices ("0", "1", …), and host JSON projection emits an
array payload.
Implementations§
Source§impl EnumVariant
impl EnumVariant
Sourcepub fn payload_schema(&self, enum_name: &str) -> Option<Schema>
pub fn payload_schema(&self, enum_name: &str) -> Option<Schema>
Build the record schema used for this variant’s payload. Tuple
variants deliberately use a normal record schema with numeric field
names, because Value::variant_dict stores tuple payloads as a dict;
JSON projection recognizes those numeric keys and emits an array.
Trait Implementations§
Source§impl Clone for EnumVariant
impl Clone for EnumVariant
Source§fn clone(&self) -> EnumVariant
fn clone(&self) -> EnumVariant
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnumVariant
impl Debug for EnumVariant
Source§impl<'de> Deserialize<'de> for EnumVariant
impl<'de> Deserialize<'de> for EnumVariant
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for EnumVariant
Source§impl PartialEq for EnumVariant
impl PartialEq for EnumVariant
Source§fn eq(&self, other: &EnumVariant) -> bool
fn eq(&self, other: &EnumVariant) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for EnumVariant
impl Serialize for EnumVariant
impl StructuralPartialEq for EnumVariant
Auto Trait Implementations§
impl Freeze for EnumVariant
impl RefUnwindSafe for EnumVariant
impl Send for EnumVariant
impl Sync for EnumVariant
impl Unpin for EnumVariant
impl UnsafeUnpin for EnumVariant
impl UnwindSafe for EnumVariant
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more