Struct spacetimedb_sats::sum_type_variant::SumTypeVariant
source · pub struct SumTypeVariant {
pub name: Option<String>,
pub algebraic_type: AlgebraicType,
}
Expand description
A variant of a sum type.
NOTE: Each element has an implicit element tag based on its order. Uniquely identifies an element similarly to protobuf tags.
Fields§
§name: Option<String>
The name of the variant, if any.
algebraic_type: AlgebraicType
The type of the variant.
Unlike a language like Rust,
where we can have enum _ { V1 { foo: A, bar: B, .. }, .. }
,
the product within the variant V1
, i.e., { foo: A, bar: B, .. }
is separated out in SATS into a separate product type.
So we would express this as { V1({ foo: A, bar: B, .. }), .. }
.
Implementations§
source§impl SumTypeVariant
impl SumTypeVariant
sourcepub const fn new(algebraic_type: AlgebraicType, name: Option<String>) -> Self
pub const fn new(algebraic_type: AlgebraicType, name: Option<String>) -> Self
Returns a sum type variant with an optional name
and algebraic_type
.
sourcepub fn new_named(algebraic_type: AlgebraicType, name: impl AsRef<str>) -> Self
pub fn new_named(algebraic_type: AlgebraicType, name: impl AsRef<str>) -> Self
Returns a sum type variant with name
and algebraic_type
.
Trait Implementations§
source§impl Clone for SumTypeVariant
impl Clone for SumTypeVariant
source§fn clone(&self) -> SumTypeVariant
fn clone(&self) -> SumTypeVariant
Returns a copy of the value. Read more
1.0.0 · 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 SumTypeVariant
impl Debug for SumTypeVariant
source§impl<'de> Deserialize<'de> for SumTypeVariant
impl<'de> Deserialize<'de> for SumTypeVariant
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given
deserializer
.source§impl From<AlgebraicType> for SumTypeVariant
impl From<AlgebraicType> for SumTypeVariant
source§fn from(algebraic_type: AlgebraicType) -> Self
fn from(algebraic_type: AlgebraicType) -> Self
Converts to this type from the input type.
source§impl Hash for SumTypeVariant
impl Hash for SumTypeVariant
source§impl MetaType for SumTypeVariant
impl MetaType for SumTypeVariant
source§fn meta_type() -> AlgebraicType
fn meta_type() -> AlgebraicType
Returns the type structure of this type as an
AlgebraicType
.source§impl Ord for SumTypeVariant
impl Ord for SumTypeVariant
source§fn cmp(&self, other: &SumTypeVariant) -> Ordering
fn cmp(&self, other: &SumTypeVariant) -> Ordering
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 PartialEq for SumTypeVariant
impl PartialEq for SumTypeVariant
source§fn eq(&self, other: &SumTypeVariant) -> bool
fn eq(&self, other: &SumTypeVariant) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for SumTypeVariant
impl PartialOrd for SumTypeVariant
source§fn partial_cmp(&self, other: &SumTypeVariant) -> Option<Ordering>
fn partial_cmp(&self, other: &SumTypeVariant) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for SumTypeVariant
impl Serialize for SumTypeVariant
impl Eq for SumTypeVariant
impl StructuralPartialEq for SumTypeVariant
Auto Trait Implementations§
impl RefUnwindSafe for SumTypeVariant
impl Send for SumTypeVariant
impl Sync for SumTypeVariant
impl Unpin for SumTypeVariant
impl UnwindSafe for SumTypeVariant
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Satn for T
impl<T> Satn for T
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the SATN data format into the formatter
f
.source§fn fmt_psql(&self, f: &mut Formatter<'_>) -> Result
fn fmt_psql(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the postgres SATN data format into the formatter
f
.source§fn to_satn(&self) -> String
fn to_satn(&self) -> String
Formats the value using the SATN data format into the returned
String
.source§fn to_satn_pretty(&self) -> String
fn to_satn_pretty(&self) -> String
Pretty prints the value using the SATN data format into the returned
String
.