septastic/libseptastic/src/route.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

50 lines
1.1 KiB
Rust

use std::cmp::Ordering;
use serde::{Deserialize, Serialize};
#[derive(sqlx::Type, Serialize, Deserialize, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_route_type", rename_all = "snake_case")]
pub enum RouteType {
Trolley,
SubwayElevated,
RegionalRail,
Bus,
TracklessTrolley,
}
#[derive(::sqlx::FromRow, Serialize, Deserialize, Debug, Clone)]
pub struct Route {
pub name: String,
pub short_name: String,
pub color_hex: String,
pub route_type: RouteType,
pub id: String,
pub directions: Vec<crate::direction::Direction>,
}
impl PartialEq for Route {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
impl Eq for Route {}
impl Ord for Route {
fn cmp(&self, other: &Self) -> Ordering {
self.id.cmp(&other.id)
}
}
impl PartialOrd for Route {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.id.cmp(&other.id))
}
}
#[derive(::sqlx::FromRow, Serialize, Deserialize, Debug, Clone)]
pub struct InterlinedRoute {
pub interline_id: String,
pub interline_name: String,
pub interlined_routes: Vec<String>,
}