#![doc = include_str!("../README.md")]
#![no_std]
use rasn::prelude::*;
pub type ValueName = String;
pub type Value = String;
pub type DateTime = rasn::types::GeneralizedTime;
pub type AnyUri = StringWithNoCrlFht;
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct Alert {
pub identifier: IdentifierString,
pub sender: String,
pub sent: DateTime,
pub status: AlertStatus,
pub msg_type: AlertMessageType,
pub source: Option<String>,
pub scope: AlertScope,
pub restriction: Option<String>,
pub addresses: Option<String>,
pub code_list: SequenceOf<String>,
pub note: Option<String>,
pub references: Option<String>,
pub incidents: Option<String>,
pub info_list: SequenceOf<AlertInformation>,
}
#[derive(AsnType, Clone, Copy, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum AlertStatus {
Actual,
Draft,
Exercise,
System,
Test,
}
#[derive(AsnType, Clone, Copy, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum AlertMessageType {
Ack,
Alert,
Cancel,
Error,
Update,
}
#[derive(AsnType, Clone, Copy, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum AlertScope {
Private,
Public,
Restricted,
}
fn default_alert_language() -> Language {
Language("en-US".try_into().unwrap())
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct AlertEventCode {
pub value_name: ValueName,
pub value: Value,
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct AlertParameter {
value_name: ValueName,
value: Value,
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct AlertInformation {
#[rasn(default = "default_alert_language")]
language: Language,
#[rasn(size("1.."))]
category_list: SequenceOf<InformationCategory>,
event: String,
#[rasn(size("0.."))]
response_type_list: SequenceOf<InformationResponseType>,
urgency: HowUrgent,
severity: HowSevere,
certainty: HowCertain,
audience: Option<String>,
#[rasn(size("0.."))]
event_code_list: SequenceOf<AlertEventCode>,
effective: Option<DateTime>,
onset: Option<DateTime>,
expires: Option<DateTime>,
sender_name: Option<String>,
#[rasn(size("1..160"), extensible)]
headline: Option<String>,
description: Option<String>,
instruction: Option<String>,
web: Option<AnyUri>,
contact: Option<String>,
#[rasn(size("0.."))]
parameter_list: SequenceOf<AlertParameter>,
#[rasn(size("0.."))]
resource_list: SequenceOf<ResourceFile>,
#[rasn(size("0.."))]
area_list: SequenceOf<Area>,
}
#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum InformationCategory {
Cbrne,
Env,
Fire,
Geo,
Health,
Infra,
Met,
Other,
Rescue,
Safety,
Security,
Transport,
}
#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum InformationResponseType {
Assess,
Evacuate,
Execute,
Monitor,
None,
Prepare,
Shelter,
}
#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum HowUrgent {
Expected,
Future,
Immediate,
Past,
Unknown,
}
#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum HowSevere {
Extreme,
Minor,
Moderate,
Severe,
Unknown,
}
#[derive(AsnType, Copy, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(enumerated)]
pub enum HowCertain {
Likely,
Observed,
Possible,
Unknown,
Unlikely,
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct ResourceFile {
resource_desc: String,
mime_type: Option<String>,
size: Option<Integer>,
uri: Option<AnyUri>,
deref_uri: Option<String>,
digest: Option<String>,
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct Area {
area_desc: String,
polygon_list: SequenceOf<String>,
circle_list: SequenceOf<String>,
#[rasn(size("0.."))]
geocode_list: SequenceOf<Geocode>,
altitude: Option<String>,
ceiling: Option<String>,
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(automatic_tags)]
pub struct Geocode {
value_name: ValueName,
value: Value,
}
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(from(
"\u{0009}",
"\u{000A}",
"\u{000D}",
"\u{0020}..\u{D7FF}",
"\u{E000}..\u{FFFD}",
"\u{10000}..\u{10FFFD}"
))]
#[rasn(delegate)]
pub struct String(Utf8String);
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(size(1))]
#[rasn(delegate)]
pub struct StringChar(String);
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(from("\u{0020}", "\u{002C}"))]
#[rasn(delegate)]
pub struct SpaceAndComma(Utf8String);
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(delegate)]
pub struct IdentifierString(StringChar);
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(from("a..z", "A..Z", "-", "0..9"))]
#[rasn(delegate)]
pub struct Language(VisibleString);
#[derive(AsnType, Clone, Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[rasn(from("\u{20}..\u{D7FF}", "\u{E000}..\u{FFFD}", "\u{10000}..\u{100000}"))]
#[rasn(delegate)]
pub struct StringWithNoCrlFht(Utf8String);