#![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 PresetTimeframeDuration {
#[serde(rename = "ALL_TIME")]
AllTime,
#[serde(rename = "LAST_DAY")]
LastDay,
#[serde(rename = "LAST_WEEK")]
LastWeek,
#[serde(rename = "LAST_MONTH")]
LastMonth,
#[serde(rename = "LAST_YEAR")]
LastYear,
#[serde(untagged)]
Unknown(Unknown),
}
impl PresetTimeframeDuration {
#[inline]
pub fn as_str(&self) -> &str {
match self {
PresetTimeframeDuration::AllTime => "ALL_TIME",
PresetTimeframeDuration::LastDay => "LAST_DAY",
PresetTimeframeDuration::LastWeek => "LAST_WEEK",
PresetTimeframeDuration::LastMonth => "LAST_MONTH",
PresetTimeframeDuration::LastYear => "LAST_YEAR",
PresetTimeframeDuration::Unknown(v) => &*v,
}
}
}
impl fmt::Display for PresetTimeframeDuration {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self.as_str(), fmt)
}
}
impl conjure_object::Plain for PresetTimeframeDuration {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
conjure_object::Plain::fmt(self.as_str(), fmt)
}
}
impl str::FromStr for PresetTimeframeDuration {
type Err = conjure_object::plain::ParseEnumError;
#[inline]
fn from_str(
v: &str,
) -> Result<PresetTimeframeDuration, conjure_object::plain::ParseEnumError> {
match v {
"ALL_TIME" => Ok(PresetTimeframeDuration::AllTime),
"LAST_DAY" => Ok(PresetTimeframeDuration::LastDay),
"LAST_WEEK" => Ok(PresetTimeframeDuration::LastWeek),
"LAST_MONTH" => Ok(PresetTimeframeDuration::LastMonth),
"LAST_YEAR" => Ok(PresetTimeframeDuration::LastYear),
v => v.parse().map(|v| PresetTimeframeDuration::Unknown(Unknown(v))),
}
}
}
impl conjure_object::FromPlain for PresetTimeframeDuration {
type Err = conjure_object::plain::ParseEnumError;
#[inline]
fn from_plain(
v: &str,
) -> Result<PresetTimeframeDuration, 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)
}
}