pub enum AlgebraicTypeLayout {
Sum(SumTypeLayout),
Product(ProductTypeLayout),
Primitive(PrimitiveType),
VarLen(VarLenType),
}Expand description
Mostly a mirror of AlgebraicType annotated with a Layout.
Notable differences from AlgebraicType:
-
Refs are not supported. Supporting recursive types remains a TODO(future-work). Note that the previous Spacetime datastore did not support recursive types in tables. -
BuiltinTypeis separated into [PrimitveType] (atomically-sized types like integers) andVarLenType(strings, arrays, and maps). This separation allows cleaner pattern-matching, e.g. inHasLayout::layout, whereVarLenTypereturns a static ref to [VAR_LEN_REF_LAYOUT], andPrimitiveTypedispatches on its variant to return a static ref to a type-specificLayout.
Variants§
Sum(SumTypeLayout)
A sum type, annotated with its layout.
Product(ProductTypeLayout)
A product type, annotated with its layout.
Primitive(PrimitiveType)
A primitive type, annotated with its layout.
VarLen(VarLenType)
A variable length type, annotated with its layout.
Implementations§
source§impl AlgebraicTypeLayout
impl AlgebraicTypeLayout
sourcepub fn is_sum(&self) -> bool
pub fn is_sum(&self) -> bool
Returns true if this is a AlgebraicTypeLayout::Sum, otherwise false
sourcepub fn as_sum_mut(&mut self) -> Option<&mut SumTypeLayout>
pub fn as_sum_mut(&mut self) -> Option<&mut SumTypeLayout>
Optionally returns mutable references to the inner fields if this is a AlgebraicTypeLayout::Sum, otherwise None
sourcepub fn as_sum(&self) -> Option<&SumTypeLayout>
pub fn as_sum(&self) -> Option<&SumTypeLayout>
Optionally returns references to the inner fields if this is a AlgebraicTypeLayout::Sum, otherwise None
sourcepub fn into_sum(self) -> Result<SumTypeLayout, Self>
pub fn into_sum(self) -> Result<SumTypeLayout, Self>
Returns the inner fields if this is a AlgebraicTypeLayout::Sum, otherwise returns back the enum in the Err case of the result
sourcepub fn is_product(&self) -> bool
pub fn is_product(&self) -> bool
Returns true if this is a AlgebraicTypeLayout::Product, otherwise false
sourcepub fn as_product_mut(&mut self) -> Option<&mut ProductTypeLayout>
pub fn as_product_mut(&mut self) -> Option<&mut ProductTypeLayout>
Optionally returns mutable references to the inner fields if this is a AlgebraicTypeLayout::Product, otherwise None
sourcepub fn as_product(&self) -> Option<&ProductTypeLayout>
pub fn as_product(&self) -> Option<&ProductTypeLayout>
Optionally returns references to the inner fields if this is a AlgebraicTypeLayout::Product, otherwise None
sourcepub fn into_product(self) -> Result<ProductTypeLayout, Self>
pub fn into_product(self) -> Result<ProductTypeLayout, Self>
Returns the inner fields if this is a AlgebraicTypeLayout::Product, otherwise returns back the enum in the Err case of the result
sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Returns true if this is a AlgebraicTypeLayout::Primitive, otherwise false
sourcepub fn as_primitive_mut(&mut self) -> Option<&mut PrimitiveType>
pub fn as_primitive_mut(&mut self) -> Option<&mut PrimitiveType>
Optionally returns mutable references to the inner fields if this is a AlgebraicTypeLayout::Primitive, otherwise None
sourcepub fn as_primitive(&self) -> Option<&PrimitiveType>
pub fn as_primitive(&self) -> Option<&PrimitiveType>
Optionally returns references to the inner fields if this is a AlgebraicTypeLayout::Primitive, otherwise None
sourcepub fn into_primitive(self) -> Result<PrimitiveType, Self>
pub fn into_primitive(self) -> Result<PrimitiveType, Self>
Returns the inner fields if this is a AlgebraicTypeLayout::Primitive, otherwise returns back the enum in the Err case of the result
sourcepub fn is_var_len(&self) -> bool
pub fn is_var_len(&self) -> bool
Returns true if this is a AlgebraicTypeLayout::VarLen, otherwise false
sourcepub fn as_var_len_mut(&mut self) -> Option<&mut VarLenType>
pub fn as_var_len_mut(&mut self) -> Option<&mut VarLenType>
Optionally returns mutable references to the inner fields if this is a AlgebraicTypeLayout::VarLen, otherwise None
sourcepub fn as_var_len(&self) -> Option<&VarLenType>
pub fn as_var_len(&self) -> Option<&VarLenType>
Optionally returns references to the inner fields if this is a AlgebraicTypeLayout::VarLen, otherwise None
sourcepub fn into_var_len(self) -> Result<VarLenType, Self>
pub fn into_var_len(self) -> Result<VarLenType, Self>
Returns the inner fields if this is a AlgebraicTypeLayout::VarLen, otherwise returns back the enum in the Err case of the result
source§impl AlgebraicTypeLayout
impl AlgebraicTypeLayout
pub const Bool: Self = _
pub const I8: Self = _
pub const U8: Self = _
pub const I16: Self = _
pub const U16: Self = _
pub const I32: Self = _
pub const U32: Self = _
pub const I64: Self = _
pub const U64: Self = _
pub const I128: Self = _
pub const U128: Self = _
pub const F32: Self = _
pub const F64: Self = _
pub const String: Self = _
source§impl AlgebraicTypeLayout
impl AlgebraicTypeLayout
sourcepub fn algebraic_type(&self) -> AlgebraicType
pub fn algebraic_type(&self) -> AlgebraicType
Convert an AlgebraicTypeLayout back into an AlgebraicType,
removing layout information.
This operation is O(n) in the number of nodes in the argument, and may heap-allocate. It is intended for use in error paths, where performance is a secondary concern.
Trait Implementations§
source§impl Debug for AlgebraicTypeLayout
impl Debug for AlgebraicTypeLayout
source§impl From<AlgebraicType> for AlgebraicTypeLayout
impl From<AlgebraicType> for AlgebraicTypeLayout
source§fn from(ty: AlgebraicType) -> Self
fn from(ty: AlgebraicType) -> Self
source§impl HasLayout for AlgebraicTypeLayout
impl HasLayout for AlgebraicTypeLayout
source§impl PartialEq for AlgebraicTypeLayout
impl PartialEq for AlgebraicTypeLayout
source§fn eq(&self, other: &AlgebraicTypeLayout) -> bool
fn eq(&self, other: &AlgebraicTypeLayout) -> bool
self and other values to be equal, and is used
by ==.