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. -
Scalar types (
ty.is_scalar()) are separated intoPrimitiveType(atomically-sized types like integers). -
Variable length types are separated into
VarLenType(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 I256: Self
pub const U256: 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 Clone for AlgebraicTypeLayout
impl Clone for AlgebraicTypeLayout
Source§fn clone(&self) -> AlgebraicTypeLayout
fn clone(&self) -> AlgebraicTypeLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlgebraicTypeLayout
impl Debug for AlgebraicTypeLayout
Source§impl<'de> DeserializeSeed<'de> for &AlgebraicTypeLayout
impl<'de> DeserializeSeed<'de> for &AlgebraicTypeLayout
Source§type Output = AlgebraicValue
type Output = AlgebraicValue
Source§fn deserialize<D: Deserializer<'de>>(
self,
de: D,
) -> Result<Self::Output, D::Error>
fn deserialize<D: Deserializer<'de>>( self, de: D, ) -> Result<Self::Output, D::Error>
Deserialize::deserialize associated function,
except with some initial piece of data (the seed self) passed in.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 MemoryUsage for AlgebraicTypeLayout
impl MemoryUsage for AlgebraicTypeLayout
Source§fn heap_usage(&self) -> usize
fn heap_usage(&self) -> usize
Source§impl PartialEq for AlgebraicTypeLayout
impl PartialEq for AlgebraicTypeLayout
impl Eq for AlgebraicTypeLayout
impl StructuralPartialEq for AlgebraicTypeLayout
Auto Trait Implementations§
impl Freeze for AlgebraicTypeLayout
impl RefUnwindSafe for AlgebraicTypeLayout
impl Send for AlgebraicTypeLayout
impl Sync for AlgebraicTypeLayout
impl Unpin for AlgebraicTypeLayout
impl UnwindSafe for AlgebraicTypeLayout
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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>
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>
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