pub struct IndexDef {
pub table: &'static str,
pub name: &'static str,
pub columns: &'static [IndexColumnDef],
pub is_unique: bool,
pub where_clause: Option<&'static str>,
pub origin: IndexOrigin,
}Expand description
Const-friendly index definition
§Examples
use drizzle_types::sqlite::ddl::{IndexDef, IndexColumnDef};
const COLS: &[IndexColumnDef] = &[
IndexColumnDef::new("email"),
IndexColumnDef::new("created_at"),
];
const IDX: IndexDef = IndexDef::new("users", "idx_users_email")
.unique()
.columns(COLS);Fields§
§table: &'static strParent table name
name: &'static strIndex name
columns: &'static [IndexColumnDef]Index columns
is_unique: boolIs this a UNIQUE index?
where_clause: Option<&'static str>Optional WHERE clause for partial indexes
origin: IndexOriginHow the index was created
Implementations§
Source§impl IndexDef
impl IndexDef
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 index definition
Sourcepub const fn columns(self, columns: &'static [IndexColumnDef]) -> Self
pub const fn columns(self, columns: &'static [IndexColumnDef]) -> Self
Set columns
Sourcepub const fn where_clause(self, clause: &'static str) -> Self
pub const fn where_clause(self, clause: &'static str) -> Self
Set WHERE clause for partial index
Sourcepub const fn auto_origin(self) -> Self
pub const fn auto_origin(self) -> Self
Set origin to auto (for UNIQUE constraint indexes)
Sourcepub fn into_index(self) -> Index
pub fn into_index(self) -> Index
Convert to runtime Index type
Trait Implementations§
impl Copy for IndexDef
impl Eq for IndexDef
impl StructuralPartialEq for IndexDef
Auto Trait Implementations§
impl Freeze for IndexDef
impl RefUnwindSafe for IndexDef
impl Send for IndexDef
impl Sync for IndexDef
impl Unpin for IndexDef
impl UnwindSafe for IndexDef
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