Struct spacetimedb_lib::relation::Header
source · pub struct Header {
pub table_name: String,
pub fields: Vec<Column>,
pub constraints: Vec<(ColList, Constraints)>,
}Fields§
§table_name: String§fields: Vec<Column>§constraints: Vec<(ColList, Constraints)>Implementations§
source§impl Header
impl Header
pub fn new( table_name: String, fields: Vec<Column>, constraints: Vec<(ColList, Constraints)> ) -> Header
sourcepub fn clone_for_error(&self) -> Header
pub fn clone_for_error(&self) -> Header
Equivalent to what Clone::clone would do.
Header intentionally does not implement Clone,
as we can’t afford to clone it in normal execution paths.
However, we don’t care about performance in error paths,
and we need to embed owned Headers in error objects to report useful messages.
pub fn from_product_type(table_name: String, fields: ProductType) -> Header
pub fn to_product_type(&self) -> ProductType
pub fn for_mem_table(fields: ProductType) -> Header
pub fn as_without_table_name(&self) -> HeaderOnlyField<'_>
pub fn ty(&self) -> ProductType
pub fn find_by_name(&self, field_name: &str) -> Option<&Column>
pub fn column_pos<'a>(&'a self, col: &'a FieldName) -> Option<ColId>
pub fn column_pos_or_err<'a>( &'a self, col: &'a FieldName ) -> Result<ColId, RelationError>
sourcepub fn find_pos_by_name(&self, name: &str) -> Option<ColId>
pub fn find_pos_by_name(&self, name: &str) -> Option<ColId>
Finds the position of a field with name.
pub fn column<'a>(&'a self, col: &'a FieldName) -> Option<&'a Column>
pub fn has_constraint(&self, field: &FieldName, constraint: Constraints) -> bool
sourcepub fn project(
&self,
cols: &[impl Into<FieldExpr> + Clone]
) -> Result<Header, RelationError>
pub fn project( &self, cols: &[impl Into<FieldExpr> + Clone] ) -> Result<Header, RelationError>
Project the FieldExpr & the Constraints that referenced them
Trait Implementations§
source§impl From<&TableSchema> for Header
impl From<&TableSchema> for Header
source§fn from(value: &TableSchema) -> Header
fn from(value: &TableSchema) -> Header
Converts to this type from the input type.
source§impl From<AlgebraicType> for Header
impl From<AlgebraicType> for Header
source§fn from(value: AlgebraicType) -> Header
fn from(value: AlgebraicType) -> Header
Converts to this type from the input type.
source§impl From<Header> for ProductType
impl From<Header> for ProductType
source§fn from(value: Header) -> ProductType
fn from(value: Header) -> ProductType
Converts to this type from the input type.
source§impl From<ProductType> for Header
impl From<ProductType> for Header
source§fn from(value: ProductType) -> Header
fn from(value: ProductType) -> Header
Converts to this type from the input type.
source§impl PartialEq for Header
impl PartialEq for Header
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
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<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