Struct spacetimedb_primitives::Constraints
source · pub struct Constraints { /* private fields */ }Expand description
Represents constraints for a database table.
Implementations§
source§impl Constraints
impl Constraints
sourcepub const fn indexed() -> Self
pub const fn indexed() -> Self
Creates a new Constraints instance with ColumnAttribute::INDEXED set.
sourcepub const fn unique() -> Self
pub const fn unique() -> Self
Creates a new Constraints instance with ColumnAttribute::UNIQUE constraint set.
sourcepub const fn identity() -> Self
pub const fn identity() -> Self
Creates a new Constraints instance with ColumnAttribute::IDENTITY set.
sourcepub const fn primary_key() -> Self
pub const fn primary_key() -> Self
Creates a new Constraints instance with ColumnAttribute::PRIMARY_KEY set.
sourcepub const fn primary_key_auto() -> Self
pub const fn primary_key_auto() -> Self
Creates a new Constraints instance with ColumnAttribute::PRIMARY_KEY_AUTO set.
sourcepub const fn primary_key_identity() -> Self
pub const fn primary_key_identity() -> Self
Creates a new Constraints instance with ColumnAttribute::PRIMARY_KEY_IDENTITY set.
sourcepub fn push(self, other: Constraints) -> Self
pub fn push(self, other: Constraints) -> Self
Adds a constraint to the existing constraints.
§Example
use spacetimedb_primitives::Constraints;
let constraints = Constraints::unset().push(Constraints::indexed());
assert!(constraints.has_indexed());sourcepub fn kind(&self) -> ConstraintKind
pub fn kind(&self) -> ConstraintKind
Returns the ConstraintKind of constraints as an enum variant.
NOTE: This represent the higher possible representation of a constraints, so for example
IDENTITY imply that is INDEXED, UNIQUE
pub fn contains(&self, other: &Self) -> bool
sourcepub const fn has_unique(&self) -> bool
pub const fn has_unique(&self) -> bool
Checks if the ‘UNIQUE’ constraint is set.
sourcepub const fn has_indexed(&self) -> bool
pub const fn has_indexed(&self) -> bool
Checks if the ‘INDEXED’ constraint is set.
sourcepub const fn has_autoinc(&self) -> bool
pub const fn has_autoinc(&self) -> bool
Checks if either ‘IDENTITY’ or ‘PRIMARY_KEY_AUTO’ constraints are set because the imply the use of auto increment sequence.
sourcepub const fn has_primary_key(&self) -> bool
pub const fn has_primary_key(&self) -> bool
Checks if the ‘PRIMARY_KEY’ constraint is set.
Trait Implementations§
source§impl Clone for Constraints
impl Clone for Constraints
source§fn clone(&self) -> Constraints
fn clone(&self) -> Constraints
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Constraints
impl Debug for Constraints
source§impl Hash for Constraints
impl Hash for Constraints
source§impl Ord for Constraints
impl Ord for Constraints
source§fn cmp(&self, other: &Constraints) -> Ordering
fn cmp(&self, other: &Constraints) -> 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 Constraints
impl PartialEq for Constraints
source§fn eq(&self, other: &Constraints) -> bool
fn eq(&self, other: &Constraints) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for Constraints
impl PartialOrd for Constraints
source§fn partial_cmp(&self, other: &Constraints) -> Option<Ordering>
fn partial_cmp(&self, other: &Constraints) -> 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 TryFrom<ColumnAttribute> for Constraints
impl TryFrom<ColumnAttribute> for Constraints
source§impl TryFrom<u8> for Constraints
impl TryFrom<u8> for Constraints
impl Copy for Constraints
impl Eq for Constraints
impl StructuralPartialEq for Constraints
Auto Trait Implementations§
impl Freeze for Constraints
impl RefUnwindSafe for Constraints
impl Send for Constraints
impl Sync for Constraints
impl Unpin for Constraints
impl UnwindSafe for Constraints
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<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>
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