1use core::fmt;
14
15#[cfg(feature = "serde")]
16use serde::{Deserialize, Serialize};
17
18#[derive(Debug, Clone, PartialEq, Eq, Hash)]
20#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
21pub enum UnaryOperator {
22 Plus,
23 Minus,
24 Not,
25 PGBitwiseNot,
27 PGSquareRoot,
29 PGCubeRoot,
31 PGPostfixFactorial,
33 PGPrefixFactorial,
35 PGAbs,
37}
38
39impl fmt::Display for UnaryOperator {
40 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41 f.write_str(match self {
42 UnaryOperator::Plus => "+",
43 UnaryOperator::Minus => "-",
44 UnaryOperator::Not => "NOT",
45 UnaryOperator::PGBitwiseNot => "~",
46 UnaryOperator::PGSquareRoot => "|/",
47 UnaryOperator::PGCubeRoot => "||/",
48 UnaryOperator::PGPostfixFactorial => "!",
49 UnaryOperator::PGPrefixFactorial => "!!",
50 UnaryOperator::PGAbs => "@",
51 })
52 }
53}
54
55#[derive(Debug, Clone, PartialEq, Eq, Hash)]
57#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
58pub enum BinaryOperator {
59 Plus,
60 Minus,
61 Multiply,
62 Divide,
63 Modulo,
64 StringConcat,
65 Gt,
66 Lt,
67 GtEq,
68 LtEq,
69 Spaceship,
70 Eq,
71 NotEq,
72 And,
73 Or,
74 Like,
75 NotLike,
76 ILike,
77 NotILike,
78 BitwiseOr,
79 BitwiseAnd,
80 BitwiseXor,
81 PGBitwiseXor,
82 PGBitwiseShiftLeft,
83 PGBitwiseShiftRight,
84 PGRegexMatch,
85 PGRegexIMatch,
86 PGRegexNotMatch,
87 PGRegexNotIMatch,
88}
89
90impl fmt::Display for BinaryOperator {
91 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
92 f.write_str(match self {
93 BinaryOperator::Plus => "+",
94 BinaryOperator::Minus => "-",
95 BinaryOperator::Multiply => "*",
96 BinaryOperator::Divide => "/",
97 BinaryOperator::Modulo => "%",
98 BinaryOperator::StringConcat => "||",
99 BinaryOperator::Gt => ">",
100 BinaryOperator::Lt => "<",
101 BinaryOperator::GtEq => ">=",
102 BinaryOperator::LtEq => "<=",
103 BinaryOperator::Spaceship => "<=>",
104 BinaryOperator::Eq => "=",
105 BinaryOperator::NotEq => "<>",
106 BinaryOperator::And => "AND",
107 BinaryOperator::Or => "OR",
108 BinaryOperator::Like => "LIKE",
109 BinaryOperator::NotLike => "NOT LIKE",
110 BinaryOperator::ILike => "ILIKE",
111 BinaryOperator::NotILike => "NOT ILIKE",
112 BinaryOperator::BitwiseOr => "|",
113 BinaryOperator::BitwiseAnd => "&",
114 BinaryOperator::BitwiseXor => "^",
115 BinaryOperator::PGBitwiseXor => "#",
116 BinaryOperator::PGBitwiseShiftLeft => "<<",
117 BinaryOperator::PGBitwiseShiftRight => ">>",
118 BinaryOperator::PGRegexMatch => "~",
119 BinaryOperator::PGRegexIMatch => "~*",
120 BinaryOperator::PGRegexNotMatch => "!~",
121 BinaryOperator::PGRegexNotIMatch => "!~*",
122 })
123 }
124}