1#![doc = include_str!("../README.md")]
2#![no_std]
3
4use rasn::prelude::*;
5
6pub type ValueName = String;
7pub type Value = String;
8pub type DateTime = rasn::types::GeneralizedTime;
9pub type AnyUri = StringWithNoCrlFht;
10
11#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
13#[rasn(automatic_tags)]
14pub struct Alert {
15 pub identifier: IdentifierString,
19
20 pub sender: String,
27 pub sent: DateTime,
28 pub status: AlertStatus,
29 pub msg_type: AlertMessageType,
30
31 pub source: Option<String>,
34 pub scope: AlertScope,
35
36 pub restriction: Option<String>,
39 pub addresses: Option<String>,
41 pub code_list: SequenceOf<String>,
43 pub note: Option<String>,
45 pub references: Option<String>,
47 pub incidents: Option<String>,
49 pub info_list: SequenceOf<AlertInformation>,
50}
51
52#[derive(AsnType, Clone, Copy, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
53#[rasn(enumerated)]
54pub enum AlertStatus {
55 Actual,
56 Draft,
57 Exercise,
58 System,
59 Test,
60}
61
62#[derive(AsnType, Clone, Copy, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
63#[rasn(enumerated)]
64pub enum AlertMessageType {
65 Ack,
66 Alert,
67 Cancel,
68 Error,
69 Update,
70}
71
72#[derive(AsnType, Clone, Copy, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
73#[rasn(enumerated)]
74pub enum AlertScope {
75 Private,
76 Public,
77 Restricted,
78}
79
80fn default_alert_language() -> Language {
81 Language("en-US".try_into().unwrap())
82}
83
84#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
85#[rasn(automatic_tags)]
86pub struct AlertEventCode {
87 pub value_name: ValueName,
88 pub value: Value,
89}
90
91#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
92#[rasn(automatic_tags)]
93pub struct AlertParameter {
94 value_name: ValueName,
95 value: Value,
96}
97
98#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
99#[rasn(automatic_tags)]
100pub struct AlertInformation {
101 #[rasn(default = "default_alert_language")]
103 language: Language,
104 #[rasn(size("1.."))]
105 category_list: SequenceOf<InformationCategory>,
106
107 event: String,
109 #[rasn(size("0.."))]
110 response_type_list: SequenceOf<InformationResponseType>,
111 urgency: HowUrgent,
112 severity: HowSevere,
113 certainty: HowCertain,
114
115 audience: Option<String>,
118
119 #[rasn(size("0.."))]
120 event_code_list: SequenceOf<AlertEventCode>,
121 effective: Option<DateTime>,
122 onset: Option<DateTime>,
123 expires: Option<DateTime>,
124
125 sender_name: Option<String>,
128
129 #[rasn(size("1..160"), extensible)]
131 headline: Option<String>,
132
133 description: Option<String>,
135 instruction: Option<String>,
137 web: Option<AnyUri>,
138 contact: Option<String>,
140 #[rasn(size("0.."))]
141 parameter_list: SequenceOf<AlertParameter>,
142 #[rasn(size("0.."))]
143 resource_list: SequenceOf<ResourceFile>,
144 #[rasn(size("0.."))]
145 area_list: SequenceOf<Area>,
146}
147
148#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
150#[rasn(enumerated)]
151pub enum InformationCategory {
152 Cbrne,
155 Env,
157 Fire,
159 Geo,
161 Health,
163 Infra,
165 Met,
167 Other,
169 Rescue,
171 Safety,
173 Security,
175 Transport,
177}
178
179#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
180#[rasn(enumerated)]
181pub enum InformationResponseType {
182 Assess,
183 Evacuate,
184 Execute,
185 Monitor,
186 None,
187 Prepare,
188 Shelter,
189}
190
191#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
192#[rasn(enumerated)]
193pub enum HowUrgent {
194 Expected,
195 Future,
196 Immediate,
197 Past,
198 Unknown,
199}
200
201#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
202#[rasn(enumerated)]
203pub enum HowSevere {
204 Extreme,
205 Minor,
206 Moderate,
207 Severe,
208 Unknown,
209}
210
211#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
212#[rasn(enumerated)]
213pub enum HowCertain {
214 Likely,
215 Observed,
216 Possible,
217 Unknown,
218 Unlikely,
219}
220
221#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
222#[rasn(automatic_tags)]
223pub struct ResourceFile {
224 resource_desc: String,
225 mime_type: Option<String>,
226 size: Option<Integer>,
227 uri: Option<AnyUri>,
228 deref_uri: Option<String>,
229 digest: Option<String>,
230}
231
232#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
233#[rasn(automatic_tags)]
234pub struct Area {
235 area_desc: String,
236 polygon_list: SequenceOf<String>,
237 circle_list: SequenceOf<String>,
238 #[rasn(size("0.."))]
239 geocode_list: SequenceOf<Geocode>,
240 altitude: Option<String>,
241 ceiling: Option<String>,
242}
243
244#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
245#[rasn(automatic_tags)]
246pub struct Geocode {
247 value_name: ValueName,
248 value: Value,
249}
250
251#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
252#[rasn(from(
253 "\u{0009}",
254 "\u{000A}",
255 "\u{000D}",
256 "\u{0020}..\u{D7FF}",
257 "\u{E000}..\u{FFFD}",
258 "\u{10000}..\u{10FFFD}"
259))]
260#[rasn(delegate)]
261pub struct String(Utf8String);
262
263#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
264#[rasn(size(1))]
265#[rasn(delegate)]
266pub struct StringChar(String);
267
268#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
269#[rasn(from("\u{0020}", "\u{002C}"))]
270#[rasn(delegate)]
271pub struct SpaceAndComma(Utf8String);
272
273#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
274#[rasn(delegate)]
275pub struct IdentifierString(StringChar);
276
277#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
278#[rasn(from("a..z", "A..Z", "-", "0..9"))]
279#[rasn(delegate)]
280pub struct Language(VisibleString);
281
282#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
283#[rasn(from("\u{20}..\u{D7FF}", "\u{E000}..\u{FFFD}", "\u{10000}..\u{100000}"))]
284#[rasn(delegate)]
285pub struct StringWithNoCrlFht(Utf8String);