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
An index that can be built in a const.
§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>WHERE condition of a partial index, as SQL
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
Creates a non-unique index with no columns; set them with
columns.
Sourcepub const fn columns(self, columns: &'static [IndexColumnDef]) -> Self
pub const fn columns(self, columns: &'static [IndexColumnDef]) -> Self
Sets the key parts.
Sourcepub const fn where_clause(self, clause: &'static str) -> Self
pub const fn where_clause(self, clause: &'static str) -> Self
Sets the WHERE condition, making it a partial index.
Sourcepub const fn auto_origin(self) -> Self
pub const fn auto_origin(self) -> Self
Marks the index as created by SQLite for a UNIQUE constraint.
Sourcepub fn into_index(self) -> Index
pub fn into_index(self) -> Index
Converts to the runtime Index.
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 UnsafeUnpin 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