nominal_api/conjure/objects/scout/compute/api/
refprop_property.rs1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4#[derive(
6 Debug,
7 Clone,
8 PartialEq,
9 Eq,
10 PartialOrd,
11 Ord,
12 Hash,
13 conjure_object::serde::Deserialize,
14 conjure_object::serde::Serialize,
15)]
16#[serde(crate = "conjure_object::serde")]
17pub enum RefpropProperty {
18 #[serde(rename = "TEMPERATURE")]
19 Temperature,
20 #[serde(rename = "PRESSURE")]
21 Pressure,
22 #[serde(rename = "MASS_DENSITY")]
23 MassDensity,
24 #[serde(rename = "MASS_SPECIFIC_ENTHALPY")]
25 MassSpecificEnthalpy,
26 #[serde(rename = "MASS_SPECIFIC_INTERNAL_ENERGY")]
27 MassSpecificInternalEnergy,
28 #[serde(rename = "MASS_SPECIFIC_ENTROPY")]
29 MassSpecificEntropy,
30 #[serde(rename = "VISCOSITY")]
31 Viscosity,
32 #[serde(untagged)]
34 Unknown(Unknown),
35}
36impl RefpropProperty {
37 #[inline]
39 pub fn as_str(&self) -> &str {
40 match self {
41 RefpropProperty::Temperature => "TEMPERATURE",
42 RefpropProperty::Pressure => "PRESSURE",
43 RefpropProperty::MassDensity => "MASS_DENSITY",
44 RefpropProperty::MassSpecificEnthalpy => "MASS_SPECIFIC_ENTHALPY",
45 RefpropProperty::MassSpecificInternalEnergy => {
46 "MASS_SPECIFIC_INTERNAL_ENERGY"
47 }
48 RefpropProperty::MassSpecificEntropy => "MASS_SPECIFIC_ENTROPY",
49 RefpropProperty::Viscosity => "VISCOSITY",
50 RefpropProperty::Unknown(v) => &*v,
51 }
52 }
53}
54impl fmt::Display for RefpropProperty {
55 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
56 fmt::Display::fmt(self.as_str(), fmt)
57 }
58}
59impl conjure_object::Plain for RefpropProperty {
60 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
61 conjure_object::Plain::fmt(self.as_str(), fmt)
62 }
63}
64impl str::FromStr for RefpropProperty {
65 type Err = conjure_object::plain::ParseEnumError;
66 #[inline]
67 fn from_str(
68 v: &str,
69 ) -> Result<RefpropProperty, conjure_object::plain::ParseEnumError> {
70 match v {
71 "TEMPERATURE" => Ok(RefpropProperty::Temperature),
72 "PRESSURE" => Ok(RefpropProperty::Pressure),
73 "MASS_DENSITY" => Ok(RefpropProperty::MassDensity),
74 "MASS_SPECIFIC_ENTHALPY" => Ok(RefpropProperty::MassSpecificEnthalpy),
75 "MASS_SPECIFIC_INTERNAL_ENERGY" => {
76 Ok(RefpropProperty::MassSpecificInternalEnergy)
77 }
78 "MASS_SPECIFIC_ENTROPY" => Ok(RefpropProperty::MassSpecificEntropy),
79 "VISCOSITY" => Ok(RefpropProperty::Viscosity),
80 v => v.parse().map(|v| RefpropProperty::Unknown(Unknown(v))),
81 }
82 }
83}
84impl conjure_object::FromPlain for RefpropProperty {
85 type Err = conjure_object::plain::ParseEnumError;
86 #[inline]
87 fn from_plain(
88 v: &str,
89 ) -> Result<RefpropProperty, conjure_object::plain::ParseEnumError> {
90 v.parse()
91 }
92}
93#[derive(
95 Debug,
96 Clone,
97 PartialEq,
98 Eq,
99 PartialOrd,
100 Ord,
101 Hash,
102 conjure_object::serde::Deserialize,
103 conjure_object::serde::Serialize,
104)]
105#[serde(crate = "conjure_object::serde", transparent)]
106pub struct Unknown(conjure_object::private::Variant);
107impl std::ops::Deref for Unknown {
108 type Target = str;
109 #[inline]
110 fn deref(&self) -> &str {
111 &self.0
112 }
113}
114impl fmt::Display for Unknown {
115 #[inline]
116 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
117 fmt::Display::fmt(&self.0, fmt)
118 }
119}