rubo4e/generated/v202607/
befestigungsart.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 Befestigungsart {
12 #[cfg_attr(feature = "serde", serde(rename = "STECKTECHNIK"))]
13 #[cfg_attr(feature = "strum", strum(serialize = "STECKTECHNIK"))]
14 Stecktechnik,
15 #[cfg_attr(feature = "serde", serde(rename = "DREIPUNKT"))]
16 #[cfg_attr(feature = "strum", strum(serialize = "DREIPUNKT"))]
17 Dreipunkt,
18 #[cfg_attr(feature = "serde", serde(rename = "HUTSCHIENE"))]
19 #[cfg_attr(feature = "strum", strum(serialize = "HUTSCHIENE"))]
20 Hutschiene,
21 #[cfg_attr(feature = "serde", serde(rename = "EINSTUTZEN"))]
22 #[cfg_attr(feature = "strum", strum(serialize = "EINSTUTZEN"))]
23 Einstutzen,
24 #[cfg_attr(feature = "serde", serde(rename = "ZWEISTUTZEN"))]
25 #[cfg_attr(feature = "strum", strum(serialize = "ZWEISTUTZEN"))]
26 Zweistutzen,
27 #[cfg_attr(feature = "serde", serde(other, rename = "UNKNOWN"))]
30 #[cfg_attr(feature = "strum", strum(serialize = "UNKNOWN"))]
31 Unknown,
32}
33impl Befestigungsart {
34 pub const VARIANTS: &'static [Self] = &[
40 Self::Stecktechnik,
41 Self::Dreipunkt,
42 Self::Hutschiene,
43 Self::Einstutzen,
44 Self::Zweistutzen,
45 ];
46 pub const COUNT: usize = Self::VARIANTS.len();
49 pub fn iter_known() -> impl Iterator<Item = Self> + Clone {
63 Self::VARIANTS.iter().copied()
64 }
65 pub const fn as_wire(&self) -> &'static str {
69 match self {
70 Self::Stecktechnik => "STECKTECHNIK",
71 Self::Dreipunkt => "DREIPUNKT",
72 Self::Hutschiene => "HUTSCHIENE",
73 Self::Einstutzen => "EINSTUTZEN",
74 Self::Zweistutzen => "ZWEISTUTZEN",
75 Self::Unknown => "UNKNOWN",
76 }
77 }
78 pub fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
97 match s {
98 "STECKTECHNIK" => Ok(Self::Stecktechnik),
99 "DREIPUNKT" => Ok(Self::Dreipunkt),
100 "HUTSCHIENE" => Ok(Self::Hutschiene),
101 "EINSTUTZEN" => Ok(Self::Einstutzen),
102 "ZWEISTUTZEN" => Ok(Self::Zweistutzen),
103 other => Err(crate::error::UnknownVariant::new(other)),
104 }
105 }
106 pub const fn is_unknown(&self) -> bool {
109 matches!(self, Self::Unknown)
110 }
111 pub const fn is_known(&self) -> bool {
113 !self.is_unknown()
114 }
115}
116impl std::fmt::Display for Befestigungsart {
117 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
118 f.write_str(self.as_wire())
119 }
120}
121impl AsRef<str> for Befestigungsart {
122 fn as_ref(&self) -> &str {
123 self.as_wire()
124 }
125}
126#[cfg(feature = "versioned")]
127impl crate::bo4e_enum_sealed::Sealed for Befestigungsart {}
128#[cfg(feature = "versioned")]
129impl crate::Bo4eEnum for Befestigungsart {
130 const VARIANTS: &'static [Self] = Self::VARIANTS;
131 const COUNT: usize = Self::COUNT;
132 fn as_wire(&self) -> &'static str {
133 Self::as_wire(self)
134 }
135 fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
136 Self::from_wire(s)
137 }
138 fn is_unknown(&self) -> bool {
139 Self::is_unknown(self)
140 }
141}
142#[cfg(feature = "versioned")]
143impl crate::Bo4eStrict for Befestigungsart {
144 fn collect_unknown_enums(&self, path: &str, out: &mut Vec<String>) {
145 if self.is_unknown() {
146 out.push(path.to_owned());
147 }
148 }
149}
150#[cfg(feature = "sqlx")]
151impl sqlx::Type<sqlx::Postgres> for Befestigungsart {
152 fn type_info() -> sqlx::postgres::PgTypeInfo {
153 <String as sqlx::Type<sqlx::Postgres>>::type_info()
154 }
155}
156#[cfg(feature = "sqlx")]
159impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Befestigungsart {
160 fn encode_by_ref(
161 &self,
162 buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
163 ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> {
164 let s: &str = self.as_wire();
165 <&str as sqlx::Encode<'q, sqlx::Postgres>>::encode_by_ref(&s, buf)
166 }
167}
168#[cfg(feature = "sqlx")]
175impl<'r> sqlx::Decode<'r, sqlx::Postgres> for Befestigungsart {
176 fn decode(
177 value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>,
178 ) -> Result<Self, sqlx::error::BoxDynError> {
179 let s = <&str as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
180 Ok(Self::from_wire(s).unwrap_or(Self::Unknown))
181 }
182}
183#[cfg(feature = "sqlx")]
187impl sqlx::postgres::PgHasArrayType for Befestigungsart {
188 fn array_type_info() -> sqlx::postgres::PgTypeInfo {
189 <String as sqlx::postgres::PgHasArrayType>::array_type_info()
190 }
191}
192#[cfg(test)]
193impl proptest::arbitrary::Arbitrary for Befestigungsart {
194 type Parameters = ();
195 type Strategy = proptest::strategy::BoxedStrategy<Self>;
196 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
197 use proptest::prelude::*;
198 proptest::sample::select(Self::VARIANTS.to_vec()).boxed()
199 }
200}