oxide_sql_core/schema/
mod.rs1pub trait Table {
11 type Row;
13
14 const NAME: &'static str;
16
17 const COLUMNS: &'static [&'static str];
19
20 const PRIMARY_KEY: Option<&'static str>;
22}
23
24pub trait Column {
29 type Table: Table;
31
32 type Type;
34
35 const NAME: &'static str;
37
38 const NULLABLE: bool;
40
41 const PRIMARY_KEY: bool;
43}
44
45pub trait TypedColumn<T>: Column<Type = T> {}
49
50pub trait Selectable<T: Table> {
54 fn column_names() -> &'static [&'static str];
56}
57
58impl<T: Table, C: Column<Table = T>> Selectable<T> for C {
60 fn column_names() -> &'static [&'static str] {
61 &[C::NAME]
64 }
65}
66
67macro_rules! impl_selectable_tuple {
69 ($($idx:tt: $col:ident),+) => {
70 impl<T: Table, $($col: Column<Table = T>),+> Selectable<T> for ($($col,)+) {
71 fn column_names() -> &'static [&'static str] {
72 &[$($col::NAME),+]
73 }
74 }
75 };
76}
77
78impl_selectable_tuple!(0: C0);
79impl_selectable_tuple!(0: C0, 1: C1);
80impl_selectable_tuple!(0: C0, 1: C1, 2: C2);
81impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3);
82impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4);
83impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5);
84impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5, 6: C6);
85impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5, 6: C6, 7: C7);
86impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5, 6: C6, 7: C7, 8: C8);
87impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5, 6: C6, 7: C7, 8: C8, 9: C9);
88impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5, 6: C6, 7: C7, 8: C8, 9: C9, 10: C10);
89impl_selectable_tuple!(0: C0, 1: C1, 2: C2, 3: C3, 4: C4, 5: C5, 6: C6, 7: C7, 8: C8, 9: C9, 10: C10, 11: C11);