bo4e_core/enums/
price_status.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
10#[cfg_attr(feature = "json-schema", schemars(rename = "Preisstatus"))]
11#[non_exhaustive]
12pub enum PriceStatus {
13 #[serde(rename = "VORLAEUFIG")]
15 Preliminary,
16
17 #[serde(rename = "ENDGUELTIG")]
19 Final,
20}
21
22impl PriceStatus {
23 pub fn german_name(&self) -> &'static str {
25 match self {
26 Self::Preliminary => "Vorläufig",
27 Self::Final => "Endgültig",
28 }
29 }
30}
31
32#[cfg(test)]
33mod tests {
34 use super::*;
35
36 #[test]
37 fn test_serialize() {
38 assert_eq!(
39 serde_json::to_string(&PriceStatus::Preliminary).unwrap(),
40 r#""VORLAEUFIG""#
41 );
42 assert_eq!(
43 serde_json::to_string(&PriceStatus::Final).unwrap(),
44 r#""ENDGUELTIG""#
45 );
46 }
47
48 #[test]
49 fn test_roundtrip() {
50 for status in [PriceStatus::Preliminary, PriceStatus::Final] {
51 let json = serde_json::to_string(&status).unwrap();
52 let parsed: PriceStatus = serde_json::from_str(&json).unwrap();
53 assert_eq!(status, parsed);
54 }
55 }
56}