1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use async_trait;
use BinRead;
use Serialize;
use Arc;
use RwLock;
use crate*;
use crateenum_field;
;
enum_field!
// #[repr(u32)]
// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
// pub enum WeatherState {
// Fine = 0,
// LightRain = 3,
// MediumRain = 4,
// HeavyRain = 5,
// LightSnow = 6,
// MediumSnow = 7,
// HeavySnow = 8,
// LightSandstorm = 22,
// MediumSandstorm = 41,
// HeavySandstorm = 42,
// Thunders = 86,
// BlackRain = 90,
//
// Unknown(u32),
// }
//
// impl BinRead for WeatherState {
// type Args<'a> = ();
//
// fn read_options<R: Read + Seek>(
// reader: &mut R,
// endian: binrw::Endian,
// _args: Self::Args<'_>,
// ) -> BinResult<Self> {
// let raw: u32 = u32::read_options(reader, endian, ())?;
// Ok(match raw {
// 0 => WeatherState::Fine,
// 3 => WeatherState::LightRain,
// 4 => WeatherState::MediumRain,
// 5 => WeatherState::HeavyRain,
// 6 => WeatherState::LightSnow,
// 7 => WeatherState::MediumSnow,
// 8 => WeatherState::HeavySnow,
// 22 => WeatherState::LightSandstorm,
// 41 => WeatherState::MediumSandstorm,
// 42 => WeatherState::HeavySandstorm,
// 86 => WeatherState::Thunders,
// 90 => WeatherState::BlackRain,
// other => WeatherState::Unknown(other),
// })
// }
// }
//
// impl CalculateMetadata for WeatherState {
// fn calculate<'a>(&self, ctx: &'a mut MetadataContext) -> &'a mut MetadataContext {
// let size = size_of::<u32>();
// ctx.metadata.insert(
// ctx.current_key.clone(),
// MetadataValue { size, offset: ctx.offset },
// );
// ctx.offset += size;
// ctx
// }
// }
//
// impl Serialize for WeatherState {
// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
// where
// S: Serializer,
// {
// let field_name = match self {
// Self::Fine => "FINE",
// Self::LightRain => "LIGHT_RAIN",
// Self::MediumRain => "MEDIUM_RAIN",
// Self::HeavyRain => "HEAVY_RAIN",
// Self::LightSnow => "LIGHT_SNOW",
// Self::MediumSnow => "MEDIUM_SNOW",
// Self::HeavySnow => "HEAVY_SNOW",
// Self::LightSandstorm => "LIGHT_SANDSTORM",
// Self::MediumSandstorm => "MEDIUM_SANDSTORM",
// Self::HeavySandstorm => "HEAVY_SANDSTORM",
// Self::Thunders => "THUNDERS",
// Self::BlackRain => "BLACKRAIN",
// _ => "NONE",
// };
//
// serializer.serialize_str(field_name)
// }
// }