#![allow(deprecated)]
use std::fmt;
use std::str;
#[derive(
    Debug,
    Clone,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    conjure_object::serde::Deserialize,
    conjure_object::serde::Serialize,
)]
#[serde(crate = "conjure_object::serde")]
pub enum UnitOperation {
    #[serde(rename = "UNIT_AS_EXPONENT")]
    UnitAsExponent,
    #[serde(rename = "NON_INTEGER_AS_EXPONENT")]
    NonIntegerAsExponent,
    #[serde(rename = "FLOOR_DIVISION")]
    FloorDivision,
    #[serde(rename = "MODULO")]
    Modulo,
    #[serde(rename = "CROSSOVER_COMPARISON")]
    CrossoverComparison,
    #[serde(rename = "MAX")]
    Max,
    #[serde(rename = "MIN")]
    Min,
    #[serde(rename = "MEAN")]
    Mean,
    #[serde(rename = "UNION")]
    Union,
    #[serde(rename = "ADDITION")]
    Addition,
    #[serde(rename = "SUBTRACTION")]
    Subtraction,
    #[serde(rename = "UNIT_CONVERSION")]
    UnitConversion,
    #[serde(rename = "COMPARISON")]
    Comparison,
    #[serde(rename = "TERNARY_OPERATOR")]
    TernaryOperator,
    /// An unknown variant.
    #[serde(untagged)]
    Unknown(Unknown),
}
impl UnitOperation {
    /// Returns the string representation of the enum.
    #[inline]
    pub fn as_str(&self) -> &str {
        match self {
            UnitOperation::UnitAsExponent => "UNIT_AS_EXPONENT",
            UnitOperation::NonIntegerAsExponent => "NON_INTEGER_AS_EXPONENT",
            UnitOperation::FloorDivision => "FLOOR_DIVISION",
            UnitOperation::Modulo => "MODULO",
            UnitOperation::CrossoverComparison => "CROSSOVER_COMPARISON",
            UnitOperation::Max => "MAX",
            UnitOperation::Min => "MIN",
            UnitOperation::Mean => "MEAN",
            UnitOperation::Union => "UNION",
            UnitOperation::Addition => "ADDITION",
            UnitOperation::Subtraction => "SUBTRACTION",
            UnitOperation::UnitConversion => "UNIT_CONVERSION",
            UnitOperation::Comparison => "COMPARISON",
            UnitOperation::TernaryOperator => "TERNARY_OPERATOR",
            UnitOperation::Unknown(v) => &*v,
        }
    }
}
impl fmt::Display for UnitOperation {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        fmt::Display::fmt(self.as_str(), fmt)
    }
}
impl conjure_object::Plain for UnitOperation {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        conjure_object::Plain::fmt(self.as_str(), fmt)
    }
}
impl str::FromStr for UnitOperation {
    type Err = conjure_object::plain::ParseEnumError;
    #[inline]
    fn from_str(
        v: &str,
    ) -> Result<UnitOperation, conjure_object::plain::ParseEnumError> {
        match v {
            "UNIT_AS_EXPONENT" => Ok(UnitOperation::UnitAsExponent),
            "NON_INTEGER_AS_EXPONENT" => Ok(UnitOperation::NonIntegerAsExponent),
            "FLOOR_DIVISION" => Ok(UnitOperation::FloorDivision),
            "MODULO" => Ok(UnitOperation::Modulo),
            "CROSSOVER_COMPARISON" => Ok(UnitOperation::CrossoverComparison),
            "MAX" => Ok(UnitOperation::Max),
            "MIN" => Ok(UnitOperation::Min),
            "MEAN" => Ok(UnitOperation::Mean),
            "UNION" => Ok(UnitOperation::Union),
            "ADDITION" => Ok(UnitOperation::Addition),
            "SUBTRACTION" => Ok(UnitOperation::Subtraction),
            "UNIT_CONVERSION" => Ok(UnitOperation::UnitConversion),
            "COMPARISON" => Ok(UnitOperation::Comparison),
            "TERNARY_OPERATOR" => Ok(UnitOperation::TernaryOperator),
            v => v.parse().map(|v| UnitOperation::Unknown(Unknown(v))),
        }
    }
}
impl conjure_object::FromPlain for UnitOperation {
    type Err = conjure_object::plain::ParseEnumError;
    #[inline]
    fn from_plain(
        v: &str,
    ) -> Result<UnitOperation, conjure_object::plain::ParseEnumError> {
        v.parse()
    }
}
///An unknown variant of the UnitOperation enum.
#[derive(
    Debug,
    Clone,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    conjure_object::serde::Deserialize,
    conjure_object::serde::Serialize,
)]
#[serde(crate = "conjure_object::serde", transparent)]
pub struct Unknown(conjure_object::private::Variant);
impl std::ops::Deref for Unknown {
    type Target = str;
    #[inline]
    fn deref(&self) -> &str {
        &self.0
    }
}
impl fmt::Display for Unknown {
    #[inline]
    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Display::fmt(&self.0, fmt)
    }
}
