use crate::road::{RoadId, Side};
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Switch {
pub road: RoadId,
pub od_id: String,
pub name: String,
pub position: SwitchPosition,
pub main: TrackPoint,
pub side: TrackPoint,
pub partner: Option<Partner>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Partner {
pub id: String,
#[cfg_attr(feature = "serde", serde(default))]
pub name: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum SwitchPosition {
Dynamic,
Straight,
Turn,
Unknown,
}
impl SwitchPosition {
pub fn as_str(self) -> &'static str {
match self {
Self::Dynamic => "dynamic",
Self::Straight => "straight",
Self::Turn => "turn",
Self::Unknown => "unknown",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TrackPoint {
pub road: RoadId,
pub s: f64,
pub forward: bool,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Station {
pub od_id: String,
pub name: String,
pub kind: String,
pub platforms: Vec<Platform>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Platform {
pub od_id: String,
pub name: String,
pub segments: Vec<PlatformSegment>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PlatformSegment {
pub road: RoadId,
pub s_start: f64,
pub s_end: f64,
pub side: Side,
}