#[doc(alias = "OPERATOR_KIND")]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum OperatorKind {
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
Matches,
Not,
And,
Or,
Xor,
Implies,
ForAll,
Exists,
Plus,
Minus,
Multiply,
Divide,
Modulo,
Exponent,
Other(String),
}
impl OperatorKind {
#[must_use]
pub fn as_str(&self) -> &str {
match self {
Self::Eq => "eq",
Self::Ne => "ne",
Self::Lt => "lt",
Self::Le => "le",
Self::Gt => "gt",
Self::Ge => "ge",
Self::Matches => "matches",
Self::Not => "not",
Self::And => "and",
Self::Or => "or",
Self::Xor => "xor",
Self::Implies => "implies",
Self::ForAll => "for_all",
Self::Exists => "exists",
Self::Plus => "plus",
Self::Minus => "minus",
Self::Multiply => "multiply",
Self::Divide => "divide",
Self::Modulo => "modulo",
Self::Exponent => "exponent",
Self::Other(__s) => __s.as_str(),
}
}
#[must_use]
pub fn from_wire(__s: &str) -> Self {
match __s {
"eq" => Self::Eq,
"ne" => Self::Ne,
"lt" => Self::Lt,
"le" => Self::Le,
"gt" => Self::Gt,
"ge" => Self::Ge,
"matches" => Self::Matches,
"not" => Self::Not,
"and" => Self::And,
"or" => Self::Or,
"xor" => Self::Xor,
"implies" => Self::Implies,
"for_all" => Self::ForAll,
"exists" => Self::Exists,
"plus" => Self::Plus,
"minus" => Self::Minus,
"multiply" => Self::Multiply,
"divide" => Self::Divide,
"modulo" => Self::Modulo,
"exponent" => Self::Exponent,
_ => Self::Other(__s.to_owned()),
}
}
}
impl ::core::convert::TryFrom<&str> for OperatorKind {
type Error = UnknownOperatorKind;
fn try_from(__s: &str) -> ::core::result::Result<Self, Self::Error> {
match __s {
"eq" => ::core::result::Result::Ok(Self::Eq),
"ne" => ::core::result::Result::Ok(Self::Ne),
"lt" => ::core::result::Result::Ok(Self::Lt),
"le" => ::core::result::Result::Ok(Self::Le),
"gt" => ::core::result::Result::Ok(Self::Gt),
"ge" => ::core::result::Result::Ok(Self::Ge),
"matches" => ::core::result::Result::Ok(Self::Matches),
"not" => ::core::result::Result::Ok(Self::Not),
"and" => ::core::result::Result::Ok(Self::And),
"or" => ::core::result::Result::Ok(Self::Or),
"xor" => ::core::result::Result::Ok(Self::Xor),
"implies" => ::core::result::Result::Ok(Self::Implies),
"for_all" => ::core::result::Result::Ok(Self::ForAll),
"exists" => ::core::result::Result::Ok(Self::Exists),
"plus" => ::core::result::Result::Ok(Self::Plus),
"minus" => ::core::result::Result::Ok(Self::Minus),
"multiply" => ::core::result::Result::Ok(Self::Multiply),
"divide" => ::core::result::Result::Ok(Self::Divide),
"modulo" => ::core::result::Result::Ok(Self::Modulo),
"exponent" => ::core::result::Result::Ok(Self::Exponent),
_ => ::core::result::Result::Err(UnknownOperatorKind(__s.to_owned())),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnknownOperatorKind(pub String);
impl ::core::fmt::Display for UnknownOperatorKind {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
::core::write!(f, "unknown OPERATOR_KIND value: {:?}", self.0)
}
}
impl ::std::error::Error for UnknownOperatorKind {}