utopia_query/enums.rs
1//! Small enumerations shared across the library.
2
3use crate::method::backed_enum;
4
5backed_enum! {
6 /// What kind of statement a classifier found.
7 ///
8 /// PHP: `Utopia\Query\Type`.
9 pub enum Type: "Utopia\\Query\\Type" {
10 /// A statement that only reads.
11 Read = "read",
12 /// A statement that writes.
13 Write = "write",
14 /// `BEGIN` / `START TRANSACTION`.
15 TransactionBegin = "transaction_begin",
16 /// `COMMIT` / `ROLLBACK`.
17 TransactionEnd = "transaction_end",
18 /// Another transaction statement (savepoints).
19 Transaction = "transaction",
20 /// Not recognised.
21 Unknown = "unknown",
22 }
23}
24
25backed_enum! {
26 /// Which side of a cursor row a page is on.
27 ///
28 /// PHP: `Utopia\Query\CursorDirection`.
29 pub enum CursorDirection: "Utopia\\Query\\CursorDirection" {
30 /// Rows after the cursor.
31 After = "after",
32 /// Rows before the cursor.
33 Before = "before",
34 }
35}
36
37backed_enum! {
38 /// A sort direction.
39 ///
40 /// PHP: `Utopia\Query\OrderDirection`.
41 pub enum OrderDirection: "Utopia\\Query\\OrderDirection" {
42 /// `ASC`.
43 Asc = "ASC",
44 /// `DESC`.
45 Desc = "DESC",
46 /// Random order.
47 Random = "RANDOM",
48 }
49}
50
51backed_enum! {
52 /// Where `NULL`s sort.
53 ///
54 /// PHP: `Utopia\Query\NullsPosition`.
55 pub enum NullsPosition: "Utopia\\Query\\NullsPosition" {
56 /// `NULLS FIRST`.
57 First = "FIRST",
58 /// `NULLS LAST`.
59 Last = "LAST",
60 }
61}