pub struct PrimaryKeyDef {
pub table: &'static str,
pub name: &'static str,
pub columns: &'static [Cow<'static, str>],
pub name_explicit: bool,
}Expand description
Const-friendly primary key definition
Used for composite primary keys (single-column PKs are defined on the column itself).
§Examples
use drizzle_types::sqlite::ddl::PrimaryKeyDef;
use std::borrow::Cow;
const COLS: &[Cow<'static, str>] = &[Cow::Borrowed("user_id"), Cow::Borrowed("role_id")];
const PK: PrimaryKeyDef = PrimaryKeyDef::new("user_roles", "pk_user_roles")
.columns(COLS);Fields§
§table: &'static strParent table name
name: &'static strConstraint name
columns: &'static [Cow<'static, str>]Columns in the primary key
name_explicit: boolWhether the constraint name was explicitly specified
Implementations§
Source§impl PrimaryKeyDef
impl PrimaryKeyDef
Sourcepub const fn new(table: &'static str, name: &'static str) -> Self
pub const fn new(table: &'static str, name: &'static str) -> Self
Create a new primary key definition
Sourcepub const fn columns(self, cols: &'static [Cow<'static, str>]) -> Self
pub const fn columns(self, cols: &'static [Cow<'static, str>]) -> Self
Set the columns in the primary key
Sourcepub const fn explicit_name(self) -> Self
pub const fn explicit_name(self) -> Self
Mark the name as explicitly specified
Sourcepub const fn into_primary_key(self) -> PrimaryKey
pub const fn into_primary_key(self) -> PrimaryKey
Convert to runtime PrimaryKey type
Trait Implementations§
Source§impl Clone for PrimaryKeyDef
impl Clone for PrimaryKeyDef
Source§fn clone(&self) -> PrimaryKeyDef
fn clone(&self) -> PrimaryKeyDef
Returns a duplicate 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 PrimaryKeyDef
impl Debug for PrimaryKeyDef
Source§impl Default for PrimaryKeyDef
impl Default for PrimaryKeyDef
Source§impl From<PrimaryKeyDef> for PrimaryKey
impl From<PrimaryKeyDef> for PrimaryKey
Source§fn from(def: PrimaryKeyDef) -> Self
fn from(def: PrimaryKeyDef) -> Self
Converts to this type from the input type.
Source§impl Hash for PrimaryKeyDef
impl Hash for PrimaryKeyDef
Source§impl PartialEq for PrimaryKeyDef
impl PartialEq for PrimaryKeyDef
impl Copy for PrimaryKeyDef
impl Eq for PrimaryKeyDef
impl StructuralPartialEq for PrimaryKeyDef
Auto Trait Implementations§
impl Freeze for PrimaryKeyDef
impl RefUnwindSafe for PrimaryKeyDef
impl Send for PrimaryKeyDef
impl Sync for PrimaryKeyDef
impl Unpin for PrimaryKeyDef
impl UnwindSafe for PrimaryKeyDef
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