septastic/libseptastic/src/direction.rs
Nicholas Orlowsky 3f68335eb4
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 39s
cleanup and filter support
2026-02-21 15:26:48 -05:00

36 lines
1.1 KiB
Rust

use serde::{Deserialize, Serialize};
#[derive(
sqlx::Type, Serialize, Deserialize, PartialEq, Debug, Clone, Copy, Eq, PartialOrd, Ord,
)]
#[sqlx(type_name = "septa_direction_type", rename_all = "snake_case")]
pub enum CardinalDirection {
Northbound,
Southbound,
Eastbound,
Westbound,
Inbound,
Outbound,
Loop,
}
#[derive(::sqlx::Decode, Serialize, Deserialize, Debug, Clone)]
pub struct Direction {
pub direction: CardinalDirection,
pub direction_destination: String,
}
impl std::fmt::Display for CardinalDirection {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let output = match self {
CardinalDirection::Northbound => "Northbound",
CardinalDirection::Southbound => "Southbound",
CardinalDirection::Eastbound => "Eastbound",
CardinalDirection::Westbound => "Westbound",
CardinalDirection::Inbound => "Inbound",
CardinalDirection::Outbound => "Outbound",
CardinalDirection::Loop => "Loop",
};
std::write!(f, "{}", output)
}
}