gatelogue_types/node/
rail.rs1use strum_macros::EnumString;
2
3use crate::{_from_sql_for_enum, _get_column, _get_derived_vec, _get_set, node_type, util::ID};
4
5#[derive(Clone, Copy, PartialEq, Eq, Debug, EnumString)]
6pub enum RailMode {
7 #[strum(serialize = "warp")]
8 Warp,
9 #[strum(serialize = "cart")]
10 Cart,
11 #[strum(serialize = "traincarts")]
12 TrainCarts,
13 #[strum(serialize = "vehicles")]
14 Vehicles,
15}
16_from_sql_for_enum!(RailMode);
17
18node_type!(RailCompany);
19impl RailCompany {
20 _get_column!("RailCompany", name, String);
21 _get_column!("RailCompany", link, Option<String>);
22 _get_derived_vec!(lines, RailLine, "../sql/rail/company_lines.sql");
23 _get_derived_vec!(stations, RailStation, "../sql/rail/company_stations.sql");
24 _get_derived_vec!(platforms, RailPlatform, "../sql/rail/company_platforms.sql");
25}
26
27node_type!(RailLine);
28impl RailLine {
29 _get_column!("RailLine", code, String);
30 _get_column!("RailLine", company, RailCompany);
31 _get_column!("RailLine", name, Option<String>);
32 _get_column!("RailLine", colour, Option<String>);
33 _get_column!("RailLine", mode, Option<RailMode>);
34 _get_column!("RailLine", local, Option<bool>);
35
36 _get_derived_vec!(platforms, RailPlatform, "../sql/rail/line_platforms.sql");
37 _get_derived_vec!(stations, RailStation, "../sql/rail/company_stations.sql");
38}
39
40node_type!(located RailStation);
41impl RailStation {
42 _get_set!("RailStationCodes", codes, "code", String);
43 _get_column!("RailStation", company, RailCompany);
44 _get_column!("RailStation", name, Option<String>);
45
46 _get_derived_vec!(platforms, RailPlatform, "../sql/rail/station_platforms.sql");
47 _get_derived_vec!(
48 connections_from_here,
49 RailConnection,
50 "../sql/rail/station_connections_from_here.sql"
51 );
52 _get_derived_vec!(
53 connections_to_here,
54 RailConnection,
55 "../sql/rail/station_connections_to_here.sql"
56 );
57 _get_derived_vec!(lines, RailLine, "../sql/rail/station_lines.sql");
58}
59
60node_type!(RailPlatform);
61impl RailPlatform {
62 _get_column!("RailPlatform", code, Option<String>);
63 _get_column!("RailPlatform", station, RailStation);
64
65 _get_derived_vec!(
66 connections_from_here,
67 RailConnection,
68 "../sql/rail/platform_connections_from_here.sql"
69 );
70 _get_derived_vec!(
71 connections_to_here,
72 RailConnection,
73 "../sql/rail/platform_connections_to_here.sql"
74 );
75 _get_derived_vec!(lines, RailLine, "../sql/rail/platform_lines.sql");
76}
77
78node_type!(RailConnection);
79impl RailConnection {
80 _get_column!("RailConnection", line, RailLine);
81 _get_column!("RailConnection", from, RailPlatform);
82 _get_column!("RailConnection", to, RailPlatform);
83 _get_column!("RailConnection", direction, Option<String>);
84 _get_column!("RailConnection", duration, Option<u32>);
85}