rubo4e/generated/v202607/
ausschreibungsstatus.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 Ausschreibungsstatus {
12 #[cfg_attr(feature = "serde", serde(rename = "PHASE1"))]
13 #[cfg_attr(feature = "strum", strum(serialize = "PHASE1"))]
14 Phase1,
15 #[cfg_attr(feature = "serde", serde(rename = "PHASE2"))]
16 #[cfg_attr(feature = "strum", strum(serialize = "PHASE2"))]
17 Phase2,
18 #[cfg_attr(feature = "serde", serde(rename = "PHASE3"))]
19 #[cfg_attr(feature = "strum", strum(serialize = "PHASE3"))]
20 Phase3,
21 #[cfg_attr(feature = "serde", serde(rename = "PHASE4"))]
22 #[cfg_attr(feature = "strum", strum(serialize = "PHASE4"))]
23 Phase4,
24 #[cfg_attr(feature = "serde", serde(other, rename = "UNKNOWN"))]
27 #[cfg_attr(feature = "strum", strum(serialize = "UNKNOWN"))]
28 Unknown,
29}
30impl Ausschreibungsstatus {
31 pub const VARIANTS: &'static [Self] = &[Self::Phase1, Self::Phase2, Self::Phase3, Self::Phase4];
37 pub const COUNT: usize = Self::VARIANTS.len();
40 pub fn iter_known() -> impl Iterator<Item = Self> + Clone {
54 Self::VARIANTS.iter().copied()
55 }
56 pub const fn as_wire(&self) -> &'static str {
60 match self {
61 Self::Phase1 => "PHASE1",
62 Self::Phase2 => "PHASE2",
63 Self::Phase3 => "PHASE3",
64 Self::Phase4 => "PHASE4",
65 Self::Unknown => "UNKNOWN",
66 }
67 }
68 pub fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
87 match s {
88 "PHASE1" => Ok(Self::Phase1),
89 "PHASE2" => Ok(Self::Phase2),
90 "PHASE3" => Ok(Self::Phase3),
91 "PHASE4" => Ok(Self::Phase4),
92 other => Err(crate::error::UnknownVariant::new(other)),
93 }
94 }
95 pub const fn is_unknown(&self) -> bool {
98 matches!(self, Self::Unknown)
99 }
100 pub const fn is_known(&self) -> bool {
102 !self.is_unknown()
103 }
104}
105impl std::fmt::Display for Ausschreibungsstatus {
106 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
107 f.write_str(self.as_wire())
108 }
109}
110impl AsRef<str> for Ausschreibungsstatus {
111 fn as_ref(&self) -> &str {
112 self.as_wire()
113 }
114}
115#[cfg(feature = "versioned")]
116impl crate::bo4e_enum_sealed::Sealed for Ausschreibungsstatus {}
117#[cfg(feature = "versioned")]
118impl crate::Bo4eEnum for Ausschreibungsstatus {
119 const VARIANTS: &'static [Self] = Self::VARIANTS;
120 const COUNT: usize = Self::COUNT;
121 fn as_wire(&self) -> &'static str {
122 Self::as_wire(self)
123 }
124 fn from_wire(s: &str) -> Result<Self, crate::error::UnknownVariant> {
125 Self::from_wire(s)
126 }
127 fn is_unknown(&self) -> bool {
128 Self::is_unknown(self)
129 }
130}
131#[cfg(feature = "versioned")]
132impl crate::Bo4eStrict for Ausschreibungsstatus {
133 fn collect_unknown_enums(&self, path: &str, out: &mut Vec<String>) {
134 if self.is_unknown() {
135 out.push(path.to_owned());
136 }
137 }
138}
139#[cfg(feature = "sqlx")]
140impl sqlx::Type<sqlx::Postgres> for Ausschreibungsstatus {
141 fn type_info() -> sqlx::postgres::PgTypeInfo {
142 <String as sqlx::Type<sqlx::Postgres>>::type_info()
143 }
144}
145#[cfg(feature = "sqlx")]
148impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Ausschreibungsstatus {
149 fn encode_by_ref(
150 &self,
151 buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
152 ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> {
153 let s: &str = self.as_wire();
154 <&str as sqlx::Encode<'q, sqlx::Postgres>>::encode_by_ref(&s, buf)
155 }
156}
157#[cfg(feature = "sqlx")]
164impl<'r> sqlx::Decode<'r, sqlx::Postgres> for Ausschreibungsstatus {
165 fn decode(
166 value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>,
167 ) -> Result<Self, sqlx::error::BoxDynError> {
168 let s = <&str as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
169 Ok(Self::from_wire(s).unwrap_or(Self::Unknown))
170 }
171}
172#[cfg(feature = "sqlx")]
176impl sqlx::postgres::PgHasArrayType for Ausschreibungsstatus {
177 fn array_type_info() -> sqlx::postgres::PgTypeInfo {
178 <String as sqlx::postgres::PgHasArrayType>::array_type_info()
179 }
180}
181#[cfg(test)]
182impl proptest::arbitrary::Arbitrary for Ausschreibungsstatus {
183 type Parameters = ();
184 type Strategy = proptest::strategy::BoxedStrategy<Self>;
185 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
186 use proptest::prelude::*;
187 proptest::sample::select(Self::VARIANTS.to_vec()).boxed()
188 }
189}