rubo4e/generated/v202607/
abgabe_art.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 AbgabeArt {
12 #[cfg_attr(feature = "serde", serde(rename = "KAS"))]
13 #[cfg_attr(feature = "strum", strum(serialize = "KAS"))]
14 Kas,
15 #[cfg_attr(feature = "serde", serde(rename = "SA"))]
16 #[cfg_attr(feature = "strum", strum(serialize = "SA"))]
17 Sa,
18 #[cfg_attr(feature = "serde", serde(rename = "SAS"))]
19 #[cfg_attr(feature = "strum", strum(serialize = "SAS"))]
20 Sas,
21 #[cfg_attr(feature = "serde", serde(rename = "TA"))]
22 #[cfg_attr(feature = "strum", strum(serialize = "TA"))]
23 Ta,
24 #[cfg_attr(feature = "serde", serde(rename = "TAS"))]
25 #[cfg_attr(feature = "strum", strum(serialize = "TAS"))]
26 Tas,
27 #[cfg_attr(feature = "serde", serde(rename = "TK"))]
28 #[cfg_attr(feature = "strum", strum(serialize = "TK"))]
29 Tk,
30 #[cfg_attr(feature = "serde", serde(rename = "TKS"))]
31 #[cfg_attr(feature = "strum", strum(serialize = "TKS"))]
32 Tks,
33 #[cfg_attr(feature = "serde", serde(rename = "TS"))]
34 #[cfg_attr(feature = "strum", strum(serialize = "TS"))]
35 Ts,
36 #[cfg_attr(feature = "serde", serde(rename = "TSS"))]
37 #[cfg_attr(feature = "strum", strum(serialize = "TSS"))]
38 Tss,
39 #[cfg_attr(feature = "serde", serde(other, rename = "UNKNOWN"))]
42 #[cfg_attr(feature = "strum", strum(serialize = "UNKNOWN"))]
43 Unknown,
44}
45impl AbgabeArt {
46 pub const VARIANTS: &'static [Self] = &[
52 Self::Kas,
53 Self::Sa,
54 Self::Sas,
55 Self::Ta,
56 Self::Tas,
57 Self::Tk,
58 Self::Tks,
59 Self::Ts,
60 Self::Tss,
61 ];
62 pub const COUNT: usize = Self::VARIANTS.len();
65 pub fn iter_known() -> impl Iterator<Item = Self> + Clone {
79 Self::VARIANTS.iter().copied()
80 }
81 pub const fn as_wire(&self) -> &'static str {
85 match self {
86 Self::Kas => "KAS",
87 Self::Sa => "SA",
88 Self::Sas => "SAS",
89 Self::Ta => "TA",
90 Self::Tas => "TAS",
91 Self::Tk => "TK",
92 Self::Tks => "TKS",
93 Self::Ts => "TS",
94 Self::Tss => "TSS",
95 Self::Unknown => "UNKNOWN",
96 }
97 }
98 pub fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
117 match s {
118 "KAS" => Ok(Self::Kas),
119 "SA" => Ok(Self::Sa),
120 "SAS" => Ok(Self::Sas),
121 "TA" => Ok(Self::Ta),
122 "TAS" => Ok(Self::Tas),
123 "TK" => Ok(Self::Tk),
124 "TKS" => Ok(Self::Tks),
125 "TS" => Ok(Self::Ts),
126 "TSS" => Ok(Self::Tss),
127 other => Err(crate::error::UnknownVariant::new(other)),
128 }
129 }
130 pub const fn is_unknown(&self) -> bool {
133 matches!(self, Self::Unknown)
134 }
135 pub const fn is_known(&self) -> bool {
137 !self.is_unknown()
138 }
139}
140impl std::fmt::Display for AbgabeArt {
141 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
142 f.write_str(self.as_wire())
143 }
144}
145impl AsRef<str> for AbgabeArt {
146 fn as_ref(&self) -> &str {
147 self.as_wire()
148 }
149}
150#[cfg(feature = "versioned")]
151impl crate::bo4e_enum_sealed::Sealed for AbgabeArt {}
152#[cfg(feature = "versioned")]
153impl crate::Bo4eEnum for AbgabeArt {
154 const VARIANTS: &'static [Self] = Self::VARIANTS;
155 const COUNT: usize = Self::COUNT;
156 fn as_wire(&self) -> &'static str {
157 Self::as_wire(self)
158 }
159 fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
160 Self::from_wire(s)
161 }
162 fn is_unknown(&self) -> bool {
163 Self::is_unknown(self)
164 }
165}
166#[cfg(feature = "versioned")]
167impl crate::Bo4eStrict for AbgabeArt {
168 fn collect_unknown_enums(&self, path: &str, out: &mut Vec<String>) {
169 if self.is_unknown() {
170 out.push(path.to_owned());
171 }
172 }
173}
174#[cfg(feature = "sqlx")]
175impl sqlx::Type<sqlx::Postgres> for AbgabeArt {
176 fn type_info() -> sqlx::postgres::PgTypeInfo {
177 <String as sqlx::Type<sqlx::Postgres>>::type_info()
178 }
179}
180#[cfg(feature = "sqlx")]
183impl<'q> sqlx::Encode<'q, sqlx::Postgres> for AbgabeArt {
184 fn encode_by_ref(
185 &self,
186 buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
187 ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> {
188 let s: &str = self.as_wire();
189 <&str as sqlx::Encode<'q, sqlx::Postgres>>::encode_by_ref(&s, buf)
190 }
191}
192#[cfg(feature = "sqlx")]
199impl<'r> sqlx::Decode<'r, sqlx::Postgres> for AbgabeArt {
200 fn decode(
201 value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>,
202 ) -> Result<Self, sqlx::error::BoxDynError> {
203 let s = <&str as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
204 Ok(Self::from_wire(s).unwrap_or(Self::Unknown))
205 }
206}
207#[cfg(feature = "sqlx")]
211impl sqlx::postgres::PgHasArrayType for AbgabeArt {
212 fn array_type_info() -> sqlx::postgres::PgTypeInfo {
213 <String as sqlx::postgres::PgHasArrayType>::array_type_info()
214 }
215}
216#[cfg(test)]
217impl proptest::arbitrary::Arbitrary for AbgabeArt {
218 type Parameters = ();
219 type Strategy = proptest::strategy::BoxedStrategy<Self>;
220 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
221 use proptest::prelude::*;
222 proptest::sample::select(Self::VARIANTS.to_vec()).boxed()
223 }
224}