use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum AirwayLocation {
Conus,
Alaska,
Hawaii,
}
impl AirwayLocation {
pub fn code(self) -> &'static str {
match self {
Self::Conus => "C",
Self::Alaska => "A",
Self::Hawaii => "H",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AirwayPoint {
pub ident: String,
pub icao_region: Option<String>,
pub gap_to_next: bool,
}
impl AirwayPoint {
pub fn new(ident: impl Into<String>) -> Self {
Self {
ident: ident.into(),
icao_region: None,
gap_to_next: false,
}
}
#[must_use]
pub fn with_icao_region(mut self, icao_region: Option<String>) -> Self {
self.icao_region = icao_region;
self
}
#[must_use]
pub fn with_gap_to_next(mut self, gap_to_next: bool) -> Self {
self.gap_to_next = gap_to_next;
self
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Airway {
pub ident: String,
pub location: AirwayLocation,
pub points: Vec<AirwayPoint>,
}
impl Airway {
pub fn new(
ident: impl Into<String>,
location: AirwayLocation,
points: Vec<AirwayPoint>,
) -> Self {
Self {
ident: ident.into(),
location,
points,
}
}
}