Struct spacetimedb_sats::product_type::ProductType
source · pub struct ProductType {
pub elements: Vec<ProductTypeElement>,
}
Expand description
A structural product type of the factors given by elements
.
This is also known as struct
and tuple
in many languages,
but note that unlike most languages, products in SATs are structural and not nominal.
When checking whether two nominal types are the same,
their names and/or declaration sites (e.g., module / namespace) are considered.
Meanwhile, a structural type system would only check the structure of the type itself,
e.g., the names of its fields and their types in the case of a record.
The name “product” comes from category theory.
See also: https://ncatlab.org/nlab/show/product+type.
These structures are known as product types because the number of possible values in product
{ N_0: T_0, N_1: T_1, ..., N_n: T_n }
is:
Π (i ∈ 0..n). values(T_i)
so for example, values({ A: U64, B: Bool }) = values(U64) * values(Bool)
.
Fields§
§elements: Vec<ProductTypeElement>
The factors of the product type.
These factors can either be named or unnamed. When all the factors are unnamed, we can regard this as a plain tuple type.
Implementations§
source§impl ProductType
impl ProductType
source§impl ProductType
impl ProductType
sourcepub const fn new(elements: Vec<ProductTypeElement>) -> Self
pub const fn new(elements: Vec<ProductTypeElement>) -> Self
Returns a product type with the given elements
as its factors.
sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns whether this is the special case of spacetimedb_lib::Identity
.
sourcepub fn is_address(&self) -> bool
pub fn is_address(&self) -> bool
Returns whether this is the special case of spacetimedb_lib::Address
.
sourcepub fn is_special(&self) -> bool
pub fn is_special(&self) -> bool
Returns whether this is a special known type, currently Address
or Identity
.
source§impl ProductType
impl ProductType
pub fn as_value(&self) -> AlgebraicValue
pub fn from_value( value: &AlgebraicValue ) -> Result<ProductType, ValueDeserializeError>
Trait Implementations§
source§impl Clone for ProductType
impl Clone for ProductType
source§fn clone(&self) -> ProductType
fn clone(&self) -> ProductType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ProductType
impl Debug for ProductType
source§impl<'de> Deserialize<'de> for ProductType
impl<'de> Deserialize<'de> for ProductType
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
deserializer
.source§impl From<&TableSchema> for ProductType
impl From<&TableSchema> for ProductType
source§fn from(value: &TableSchema) -> Self
fn from(value: &TableSchema) -> Self
source§impl<const N: usize> From<[(&str, AlgebraicType); N]> for ProductType
impl<const N: usize> From<[(&str, AlgebraicType); N]> for ProductType
source§impl<const N: usize> From<[(Option<&str>, AlgebraicType); N]> for ProductType
impl<const N: usize> From<[(Option<&str>, AlgebraicType); N]> for ProductType
source§impl<const N: usize> From<[AlgebraicType; N]> for ProductType
impl<const N: usize> From<[AlgebraicType; N]> for ProductType
source§fn from(fields: [AlgebraicType; N]) -> Self
fn from(fields: [AlgebraicType; N]) -> Self
source§impl<const N: usize> From<[ProductTypeElement; N]> for ProductType
impl<const N: usize> From<[ProductTypeElement; N]> for ProductType
source§fn from(fields: [ProductTypeElement; N]) -> Self
fn from(fields: [ProductTypeElement; N]) -> Self
source§impl From<AlgebraicType> for ProductType
impl From<AlgebraicType> for ProductType
source§fn from(x: AlgebraicType) -> Self
fn from(x: AlgebraicType) -> Self
source§impl From<Header> for ProductType
impl From<Header> for ProductType
source§impl From<ProductType> for AlgebraicType
impl From<ProductType> for AlgebraicType
source§fn from(original: ProductType) -> AlgebraicType
fn from(original: ProductType) -> AlgebraicType
source§impl From<ProductType> for Header
impl From<ProductType> for Header
source§fn from(value: ProductType) -> Self
fn from(value: ProductType) -> Self
source§impl From<ProductType> for Vec<ColumnDef>
impl From<ProductType> for Vec<ColumnDef>
source§fn from(value: ProductType) -> Self
fn from(value: ProductType) -> Self
source§impl From<Vec<ProductTypeElement>> for ProductType
impl From<Vec<ProductTypeElement>> for ProductType
source§fn from(fields: Vec<ProductTypeElement>) -> Self
fn from(fields: Vec<ProductTypeElement>) -> Self
source§impl<'a, I: Into<AlgebraicType>> FromIterator<(&'a str, I)> for ProductType
impl<'a, I: Into<AlgebraicType>> FromIterator<(&'a str, I)> for ProductType
source§impl<'a, I: Into<AlgebraicType>> FromIterator<(Option<&'a str>, I)> for ProductType
impl<'a, I: Into<AlgebraicType>> FromIterator<(Option<&'a str>, I)> for ProductType
source§impl<I: Into<ProductTypeElement>> FromIterator<I> for ProductType
impl<I: Into<ProductTypeElement>> FromIterator<I> for ProductType
source§fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self
source§impl Hash for ProductType
impl Hash for ProductType
source§impl MetaType for ProductType
impl MetaType for ProductType
source§fn meta_type() -> AlgebraicType
fn meta_type() -> AlgebraicType
AlgebraicType
.source§impl Ord for ProductType
impl Ord for ProductType
source§fn cmp(&self, other: &ProductType) -> Ordering
fn cmp(&self, other: &ProductType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ProductType
impl PartialEq for ProductType
source§fn eq(&self, other: &ProductType) -> bool
fn eq(&self, other: &ProductType) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ProductType
impl PartialOrd for ProductType
source§fn partial_cmp(&self, other: &ProductType) -> Option<Ordering>
fn partial_cmp(&self, other: &ProductType) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for ProductType
impl Serialize for ProductType
impl Eq for ProductType
impl StructuralPartialEq for ProductType
Auto Trait Implementations§
impl RefUnwindSafe for ProductType
impl Send for ProductType
impl Sync for ProductType
impl Unpin for ProductType
impl UnwindSafe for ProductType
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
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
f
.source§fn fmt_psql(&self, f: &mut Formatter<'_>) -> Result
fn fmt_psql(&self, f: &mut Formatter<'_>) -> Result
f
.source§fn to_satn(&self) -> String
fn to_satn(&self) -> String
String
.source§fn to_satn_pretty(&self) -> String
fn to_satn_pretty(&self) -> String
String
.