drizzle_core/traits/
index.rs1use core::any::Any;
2
3use crate::{SQLParam, SQLSchemaType, SQLTable, SQLTableInfo, ToSQL};
4
5pub trait SQLIndexInfo: Any + Send + Sync {
6 fn table(&self) -> &dyn SQLTableInfo;
7 fn name(&self) -> &'static str;
9
10 fn is_unique(&self) -> bool {
12 false
13 }
14}
15
16pub trait AsIndexInfo: Sized + SQLIndexInfo {
17 fn as_index(&self) -> &dyn SQLIndexInfo {
18 self
19 }
20}
21
22impl core::fmt::Debug for dyn SQLIndexInfo {
23 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
24 f.debug_struct("SQLIndexInfo")
25 .field("name", &self.name())
26 .field("is_unique", &self.is_unique())
27 .field("table", &self.table())
28 .finish()
29 }
30}
31pub trait SQLIndex<'a, Type: SQLSchemaType, Value: SQLParam + 'a>:
34 SQLIndexInfo + ToSQL<'a, Value>
35{
36 type Table: SQLTable<'a, Type, Value>;
38}