#![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 Priority {
#[serde(rename = "P0")]
P0,
#[serde(rename = "P1")]
P1,
#[serde(rename = "P2")]
P2,
#[serde(rename = "P3")]
P3,
#[serde(rename = "P4")]
P4,
#[serde(untagged)]
Unknown(Unknown),
}
impl Priority {
#[inline]
pub fn as_str(&self) -> &str {
match self {
Priority::P0 => "P0",
Priority::P1 => "P1",
Priority::P2 => "P2",
Priority::P3 => "P3",
Priority::P4 => "P4",
Priority::Unknown(v) => &*v,
}
}
}
impl fmt::Display for Priority {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self.as_str(), fmt)
}
}
impl conjure_object::Plain for Priority {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
conjure_object::Plain::fmt(self.as_str(), fmt)
}
}
impl str::FromStr for Priority {
type Err = conjure_object::plain::ParseEnumError;
#[inline]
fn from_str(v: &str) -> Result<Priority, conjure_object::plain::ParseEnumError> {
match v {
"P0" => Ok(Priority::P0),
"P1" => Ok(Priority::P1),
"P2" => Ok(Priority::P2),
"P3" => Ok(Priority::P3),
"P4" => Ok(Priority::P4),
v => v.parse().map(|v| Priority::Unknown(Unknown(v))),
}
}
}
impl conjure_object::FromPlain for Priority {
type Err = conjure_object::plain::ParseEnumError;
#[inline]
fn from_plain(v: &str) -> Result<Priority, conjure_object::plain::ParseEnumError> {
v.parse()
}
}
#[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)
}
}