#[allow(missing_docs)] #[non_exhaustive]
#[derive(
::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
)]
pub enum Metric {
#[allow(missing_docs)] AmortizedCost,
#[allow(missing_docs)] BlendedCost,
#[allow(missing_docs)] Hours,
#[allow(missing_docs)] NetAmortizedCost,
#[allow(missing_docs)] NetUnblendedCost,
#[allow(missing_docs)] NormalizedUsageAmount,
#[allow(missing_docs)] UnblendedCost,
#[allow(missing_docs)] UsageQuantity,
#[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
}
impl ::std::convert::From<&str> for Metric {
fn from(s: &str) -> Self {
match s {
"AmortizedCost" => Metric::AmortizedCost,
"BlendedCost" => Metric::BlendedCost,
"Hours" => Metric::Hours,
"NetAmortizedCost" => Metric::NetAmortizedCost,
"NetUnblendedCost" => Metric::NetUnblendedCost,
"NormalizedUsageAmount" => Metric::NormalizedUsageAmount,
"UnblendedCost" => Metric::UnblendedCost,
"UsageQuantity" => Metric::UsageQuantity,
other => Metric::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
}
}
}
impl ::std::str::FromStr for Metric {
type Err = ::std::convert::Infallible;
fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
::std::result::Result::Ok(Metric::from(s))
}
}
impl Metric {
pub fn as_str(&self) -> &str {
match self {
Metric::AmortizedCost => "AmortizedCost",
Metric::BlendedCost => "BlendedCost",
Metric::Hours => "Hours",
Metric::NetAmortizedCost => "NetAmortizedCost",
Metric::NetUnblendedCost => "NetUnblendedCost",
Metric::NormalizedUsageAmount => "NormalizedUsageAmount",
Metric::UnblendedCost => "UnblendedCost",
Metric::UsageQuantity => "UsageQuantity",
Metric::Unknown(value) => value.as_str(),
}
}
pub const fn values() -> &'static [&'static str] {
&[
"AmortizedCost",
"BlendedCost",
"Hours",
"NetAmortizedCost",
"NetUnblendedCost",
"NormalizedUsageAmount",
"UnblendedCost",
"UsageQuantity",
]
}
}
impl ::std::convert::AsRef<str> for Metric {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl Metric {
pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
match Self::from(value) {
#[allow(deprecated)]
Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
known => Ok(known),
}
}
}
impl ::std::fmt::Display for Metric {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match self {
Metric::AmortizedCost => write!(f, "AmortizedCost"),
Metric::BlendedCost => write!(f, "BlendedCost"),
Metric::Hours => write!(f, "Hours"),
Metric::NetAmortizedCost => write!(f, "NetAmortizedCost"),
Metric::NetUnblendedCost => write!(f, "NetUnblendedCost"),
Metric::NormalizedUsageAmount => write!(f, "NormalizedUsageAmount"),
Metric::UnblendedCost => write!(f, "UnblendedCost"),
Metric::UsageQuantity => write!(f, "UsageQuantity"),
Metric::Unknown(value) => write!(f, "{value}"),
}
}
}