Skip to main content

ldap_acis/aci/
comp_op.rs

1//! Comparison operators for bind rule range comparisons.
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6/// Comparison operator for bind rules that support range comparisons (ssf, timeofday).
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9#[non_exhaustive]
10pub enum CompOp {
11    Equal,
12    NotEqual,
13    GreaterThan,
14    LessThan,
15    GreaterEqual,
16    LessEqual,
17}
18
19impl CompOp {
20    pub fn as_str(&self) -> &'static str {
21        match self {
22            Self::Equal => "=",
23            Self::NotEqual => "!=",
24            Self::GreaterThan => ">",
25            Self::LessThan => "<",
26            Self::GreaterEqual => ">=",
27            Self::LessEqual => "<=",
28        }
29    }
30}
31
32impl std::fmt::Display for CompOp {
33    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34        f.write_str(self.as_str())
35    }
36}