#![allow(deprecated)]
use std::fmt;
use std::str;
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
conjure_object::serde::Deserialize,
conjure_object::serde::Serialize,
conjure_object::log_safety::derive::LogSafe
)]
#[serde(crate = "conjure_object::serde")]
pub enum PhysicalConstant {
#[serde(rename = "SPEED_OF_LIGHT")]
SpeedOfLight,
#[serde(rename = "AVOGADRO")]
Avogadro,
#[serde(rename = "BOLTZMANN")]
Boltzmann,
#[serde(rename = "PLANCK")]
Planck,
#[serde(rename = "ELEMENTARY_CHARGE")]
ElementaryCharge,
#[serde(rename = "GAS_CONSTANT")]
GasConstant,
#[serde(rename = "STANDARD_GRAVITY")]
StandardGravity,
#[serde(rename = "STANDARD_ATMOSPHERE")]
StandardAtmosphere,
#[serde(rename = "ABSOLUTE_ZERO_CELSIUS")]
AbsoluteZeroCelsius,
#[serde(rename = "GRAVITATIONAL_CONSTANT")]
GravitationalConstant,
#[serde(rename = "STEFAN_BOLTZMANN")]
StefanBoltzmann,
#[serde(untagged)]
Unknown(Unknown),
}
impl PhysicalConstant {
#[inline]
pub fn as_str(&self) -> &str {
match self {
PhysicalConstant::SpeedOfLight => "SPEED_OF_LIGHT",
PhysicalConstant::Avogadro => "AVOGADRO",
PhysicalConstant::Boltzmann => "BOLTZMANN",
PhysicalConstant::Planck => "PLANCK",
PhysicalConstant::ElementaryCharge => "ELEMENTARY_CHARGE",
PhysicalConstant::GasConstant => "GAS_CONSTANT",
PhysicalConstant::StandardGravity => "STANDARD_GRAVITY",
PhysicalConstant::StandardAtmosphere => "STANDARD_ATMOSPHERE",
PhysicalConstant::AbsoluteZeroCelsius => "ABSOLUTE_ZERO_CELSIUS",
PhysicalConstant::GravitationalConstant => "GRAVITATIONAL_CONSTANT",
PhysicalConstant::StefanBoltzmann => "STEFAN_BOLTZMANN",
PhysicalConstant::Unknown(v) => &*v,
}
}
}
impl fmt::Display for PhysicalConstant {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self.as_str(), fmt)
}
}
impl conjure_object::Plain for PhysicalConstant {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
conjure_object::Plain::fmt(self.as_str(), fmt)
}
}
impl str::FromStr for PhysicalConstant {
type Err = conjure_object::plain::ParseEnumError;
#[inline]
fn from_str(
v: &str,
) -> Result<PhysicalConstant, conjure_object::plain::ParseEnumError> {
match v {
"SPEED_OF_LIGHT" => Ok(PhysicalConstant::SpeedOfLight),
"AVOGADRO" => Ok(PhysicalConstant::Avogadro),
"BOLTZMANN" => Ok(PhysicalConstant::Boltzmann),
"PLANCK" => Ok(PhysicalConstant::Planck),
"ELEMENTARY_CHARGE" => Ok(PhysicalConstant::ElementaryCharge),
"GAS_CONSTANT" => Ok(PhysicalConstant::GasConstant),
"STANDARD_GRAVITY" => Ok(PhysicalConstant::StandardGravity),
"STANDARD_ATMOSPHERE" => Ok(PhysicalConstant::StandardAtmosphere),
"ABSOLUTE_ZERO_CELSIUS" => Ok(PhysicalConstant::AbsoluteZeroCelsius),
"GRAVITATIONAL_CONSTANT" => Ok(PhysicalConstant::GravitationalConstant),
"STEFAN_BOLTZMANN" => Ok(PhysicalConstant::StefanBoltzmann),
v => v.parse().map(|v| PhysicalConstant::Unknown(Unknown(v))),
}
}
}
impl conjure_object::FromPlain for PhysicalConstant {
type Err = conjure_object::plain::ParseEnumError;
#[inline]
fn from_plain(
v: &str,
) -> Result<PhysicalConstant, conjure_object::plain::ParseEnumError> {
v.parse()
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
conjure_object::serde::Deserialize,
conjure_object::serde::Serialize,
conjure_object::log_safety::derive::LogSafe,
)]
#[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)
}
}