1use std::ops::BitOr;
2
3use crate::schema::{NumericOptions, TextOptions};
4use crate::DateOptions;
5
6#[derive(Clone)]
7pub struct StoredFlag;
8pub const STORED: SchemaFlagList<StoredFlag, ()> = SchemaFlagList {
18 head: StoredFlag,
19 tail: (),
20};
21
22#[derive(Clone)]
23pub struct IndexedFlag;
24pub const INDEXED: SchemaFlagList<IndexedFlag, ()> = SchemaFlagList {
30 head: IndexedFlag,
31 tail: (),
32};
33
34#[derive(Clone)]
35pub struct FastFlag;
36pub const FAST: SchemaFlagList<FastFlag, ()> = SchemaFlagList {
43 head: FastFlag,
44 tail: (),
45};
46
47impl<Head, OldHead, OldTail> BitOr<SchemaFlagList<Head, ()>> for SchemaFlagList<OldHead, OldTail>
48where
49 Head: Clone,
50 OldHead: Clone,
51 OldTail: Clone,
52{
53 type Output = SchemaFlagList<Head, SchemaFlagList<OldHead, OldTail>>;
54
55 fn bitor(self, head: SchemaFlagList<Head, ()>) -> Self::Output {
56 SchemaFlagList {
57 head: head.head,
58 tail: self,
59 }
60 }
61}
62
63impl<T: Clone + Into<NumericOptions>> BitOr<NumericOptions> for SchemaFlagList<T, ()> {
64 type Output = NumericOptions;
65
66 fn bitor(self, rhs: NumericOptions) -> Self::Output {
67 self.head.into() | rhs
68 }
69}
70
71impl<T: Clone + Into<DateOptions>> BitOr<DateOptions> for SchemaFlagList<T, ()> {
72 type Output = DateOptions;
73
74 fn bitor(self, rhs: DateOptions) -> Self::Output {
75 self.head.into() | rhs
76 }
77}
78
79impl<T: Clone + Into<TextOptions>> BitOr<TextOptions> for SchemaFlagList<T, ()> {
80 type Output = TextOptions;
81
82 fn bitor(self, rhs: TextOptions) -> Self::Output {
83 self.head.into() | rhs
84 }
85}
86
87#[derive(Clone)]
88pub struct SchemaFlagList<Head: Clone, Tail: Clone> {
89 pub head: Head,
90 pub tail: Tail,
91}