rubo4e/generated/v202607/
waermenutzung.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3#[cfg_attr(
4 feature = "strum",
5 derive(strum::EnumString, strum::EnumIter, strum::IntoStaticStr)
6)]
7#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
8#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
9#[non_exhaustive]
11pub enum Waermenutzung {
12 #[cfg_attr(feature = "serde", serde(rename = "SPEICHERHEIZUNG"))]
13 #[cfg_attr(feature = "strum", strum(serialize = "SPEICHERHEIZUNG"))]
14 Speicherheizung,
15 #[cfg_attr(feature = "serde", serde(rename = "WAERMEPUMPE"))]
16 #[cfg_attr(feature = "strum", strum(serialize = "WAERMEPUMPE"))]
17 Waermepumpe,
18 #[cfg_attr(feature = "serde", serde(rename = "DIREKTHEIZUNG"))]
19 #[cfg_attr(feature = "strum", strum(serialize = "DIREKTHEIZUNG"))]
20 Direktheizung,
21 #[cfg_attr(feature = "serde", serde(other, rename = "UNKNOWN"))]
24 #[cfg_attr(feature = "strum", strum(serialize = "UNKNOWN"))]
25 Unknown,
26}
27impl Waermenutzung {
28 pub const VARIANTS: &'static [Self] = &[
34 Self::Speicherheizung,
35 Self::Waermepumpe,
36 Self::Direktheizung,
37 ];
38 pub const COUNT: usize = Self::VARIANTS.len();
41 pub fn iter_known() -> impl Iterator<Item = Self> + Clone {
55 Self::VARIANTS.iter().copied()
56 }
57 pub const fn as_wire(&self) -> &'static str {
61 match self {
62 Self::Speicherheizung => "SPEICHERHEIZUNG",
63 Self::Waermepumpe => "WAERMEPUMPE",
64 Self::Direktheizung => "DIREKTHEIZUNG",
65 Self::Unknown => "UNKNOWN",
66 }
67 }
68 pub fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
87 match s {
88 "SPEICHERHEIZUNG" => Ok(Self::Speicherheizung),
89 "WAERMEPUMPE" => Ok(Self::Waermepumpe),
90 "DIREKTHEIZUNG" => Ok(Self::Direktheizung),
91 other => Err(crate::error::UnknownVariant::new(other)),
92 }
93 }
94 pub const fn is_unknown(&self) -> bool {
97 matches!(self, Self::Unknown)
98 }
99 pub const fn is_known(&self) -> bool {
101 !self.is_unknown()
102 }
103}
104impl std::fmt::Display for Waermenutzung {
105 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
106 f.write_str(self.as_wire())
107 }
108}
109impl AsRef<str> for Waermenutzung {
110 fn as_ref(&self) -> &str {
111 self.as_wire()
112 }
113}
114#[cfg(feature = "versioned")]
115impl crate::bo4e_enum_sealed::Sealed for Waermenutzung {}
116#[cfg(feature = "versioned")]
117impl crate::Bo4eEnum for Waermenutzung {
118 const VARIANTS: &'static [Self] = Self::VARIANTS;
119 const COUNT: usize = Self::COUNT;
120 fn as_wire(&self) -> &'static str {
121 Self::as_wire(self)
122 }
123 fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
124 Self::from_wire(s)
125 }
126 fn is_unknown(&self) -> bool {
127 Self::is_unknown(self)
128 }
129}
130#[cfg(feature = "versioned")]
131impl crate::Bo4eStrict for Waermenutzung {
132 fn collect_unknown_enums(&self, path: &str, out: &mut Vec<String>) {
133 if self.is_unknown() {
134 out.push(path.to_owned());
135 }
136 }
137}
138#[cfg(feature = "sqlx")]
139impl sqlx::Type<sqlx::Postgres> for Waermenutzung {
140 fn type_info() -> sqlx::postgres::PgTypeInfo {
141 <String as sqlx::Type<sqlx::Postgres>>::type_info()
142 }
143}
144#[cfg(feature = "sqlx")]
147impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Waermenutzung {
148 fn encode_by_ref(
149 &self,
150 buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
151 ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> {
152 let s: &str = self.as_wire();
153 <&str as sqlx::Encode<'q, sqlx::Postgres>>::encode_by_ref(&s, buf)
154 }
155}
156#[cfg(feature = "sqlx")]
163impl<'r> sqlx::Decode<'r, sqlx::Postgres> for Waermenutzung {
164 fn decode(
165 value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>,
166 ) -> Result<Self, sqlx::error::BoxDynError> {
167 let s = <&str as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
168 Ok(Self::from_wire(s).unwrap_or(Self::Unknown))
169 }
170}
171#[cfg(feature = "sqlx")]
175impl sqlx::postgres::PgHasArrayType for Waermenutzung {
176 fn array_type_info() -> sqlx::postgres::PgTypeInfo {
177 <String as sqlx::postgres::PgHasArrayType>::array_type_info()
178 }
179}
180#[cfg(test)]
181impl proptest::arbitrary::Arbitrary for Waermenutzung {
182 type Parameters = ();
183 type Strategy = proptest::strategy::BoxedStrategy<Self>;
184 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
185 use proptest::prelude::*;
186 proptest::sample::select(Self::VARIANTS.to_vec()).boxed()
187 }
188}