bo4e_core/enums/
price_model.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
11#[non_exhaustive]
12pub enum PriceModel {
13 #[serde(rename = "FESTPREIS")]
15 FixedPrice,
16
17 #[serde(rename = "TRANCHE")]
19 Tranche,
20}
21
22impl PriceModel {
23 pub fn german_name(&self) -> &'static str {
25 match self {
26 Self::FixedPrice => "Festpreis",
27 Self::Tranche => "Tranche",
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(&PriceModel::FixedPrice).unwrap(),
40 r#""FESTPREIS""#
41 );
42 }
43
44 #[test]
45 fn test_roundtrip() {
46 for model in [PriceModel::FixedPrice, PriceModel::Tranche] {
47 let json = serde_json::to_string(&model).unwrap();
48 let parsed: PriceModel = serde_json::from_str(&json).unwrap();
49 assert_eq!(model, parsed);
50 }
51 }
52}