Struct spacetimedb_sats::db::def::ConstraintDef
source · pub struct ConstraintDef {
pub constraint_name: String,
pub constraints: Constraints,
pub columns: ColList,
}
Expand description
A struct representing the definition of a database constraint.
Fields§
§constraint_name: String
§constraints: Constraints
§columns: ColList
List of column positions associated with the constraint.
Implementations§
source§impl ConstraintDef
impl ConstraintDef
sourcepub fn new(
constraint_name: String,
constraints: Constraints,
columns: impl Into<ColList>
) -> Self
pub fn new( constraint_name: String, constraints: Constraints, columns: impl Into<ColList> ) -> Self
Creates a new ConstraintDef with the specified parameters.
§Arguments
constraint_name
: The name of the constraint.constraints
: The constraints.columns
: List of column positions associated with the constraint.
sourcepub fn for_column(
table: &str,
column_or_name: &str,
constraints: Constraints,
columns: impl Into<ColList>
) -> Self
pub fn for_column( table: &str, column_or_name: &str, constraints: Constraints, columns: impl Into<ColList> ) -> Self
Creates a ConstraintDef
for a specific column of a table.
This method generates a constraint name based on the table name, column name, and constraint type.
§Arguments
table
: The name of the table to which the constraint belongs.column_name
: The name of the column associated with the constraint.constraints
: The constraints.columns
: List of column positions associated with the constraint.
§Example
use spacetimedb_primitives::{Constraints, ColList};
use spacetimedb_sats::db::def::*;
let constraint_def = ConstraintDef::for_column("my_table", "test", Constraints::identity(), ColList::new(1u32.into()));
assert_eq!(constraint_def.constraint_name, "ct_my_table_test_identity");
Trait Implementations§
source§impl Clone for ConstraintDef
impl Clone for ConstraintDef
source§fn clone(&self) -> ConstraintDef
fn clone(&self) -> ConstraintDef
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 ConstraintDef
impl Debug for ConstraintDef
source§impl<'de> Deserialize<'de> for ConstraintDef
impl<'de> Deserialize<'de> for ConstraintDef
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<ConstraintSchema> for ConstraintDef
impl From<ConstraintSchema> for ConstraintDef
source§fn from(value: ConstraintSchema) -> Self
fn from(value: ConstraintSchema) -> Self
Converts to this type from the input type.
source§impl Ord for ConstraintDef
impl Ord for ConstraintDef
source§fn cmp(&self, other: &ConstraintDef) -> Ordering
fn cmp(&self, other: &ConstraintDef) -> 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 ConstraintDef
impl PartialEq for ConstraintDef
source§fn eq(&self, other: &ConstraintDef) -> bool
fn eq(&self, other: &ConstraintDef) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ConstraintDef
impl PartialOrd for ConstraintDef
source§fn partial_cmp(&self, other: &ConstraintDef) -> Option<Ordering>
fn partial_cmp(&self, other: &ConstraintDef) -> 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 ConstraintDef
impl Serialize for ConstraintDef
impl Eq for ConstraintDef
impl StructuralPartialEq for ConstraintDef
Auto Trait Implementations§
impl RefUnwindSafe for ConstraintDef
impl Send for ConstraintDef
impl Sync for ConstraintDef
impl Unpin for ConstraintDef
impl UnwindSafe for ConstraintDef
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
.