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