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 Xor,
75 Like,
76 NotLike,
77 ILike,
78 NotILike,
79 BitwiseOr,
80 BitwiseAnd,
81 BitwiseXor,
82 PGBitwiseXor,
83 PGBitwiseShiftLeft,
84 PGBitwiseShiftRight,
85 PGRegexMatch,
86 PGRegexIMatch,
87 PGRegexNotMatch,
88 PGRegexNotIMatch,
89}
90
91impl fmt::Display for BinaryOperator {
92 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
93 f.write_str(match self {
94 BinaryOperator::Plus => "+",
95 BinaryOperator::Minus => "-",
96 BinaryOperator::Multiply => "*",
97 BinaryOperator::Divide => "/",
98 BinaryOperator::Modulo => "%",
99 BinaryOperator::StringConcat => "||",
100 BinaryOperator::Gt => ">",
101 BinaryOperator::Lt => "<",
102 BinaryOperator::GtEq => ">=",
103 BinaryOperator::LtEq => "<=",
104 BinaryOperator::Spaceship => "<=>",
105 BinaryOperator::Eq => "=",
106 BinaryOperator::NotEq => "<>",
107 BinaryOperator::And => "AND",
108 BinaryOperator::Or => "OR",
109 BinaryOperator::Xor => "XOR",
110 BinaryOperator::Like => "LIKE",
111 BinaryOperator::NotLike => "NOT LIKE",
112 BinaryOperator::ILike => "ILIKE",
113 BinaryOperator::NotILike => "NOT ILIKE",
114 BinaryOperator::BitwiseOr => "|",
115 BinaryOperator::BitwiseAnd => "&",
116 BinaryOperator::BitwiseXor => "^",
117 BinaryOperator::PGBitwiseXor => "#",
118 BinaryOperator::PGBitwiseShiftLeft => "<<",
119 BinaryOperator::PGBitwiseShiftRight => ">>",
120 BinaryOperator::PGRegexMatch => "~",
121 BinaryOperator::PGRegexIMatch => "~*",
122 BinaryOperator::PGRegexNotMatch => "!~",
123 BinaryOperator::PGRegexNotIMatch => "!~*",
124 })
125 }
126}