gatelogue_types/node/
bus.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 BusMode {
7 #[strum(serialize = "warp")]
8 Warp,
9 #[strum(serialize = "traincarts")]
10 TrainCarts,
11}
12_from_sql_for_enum!(BusMode);
13
14node_type!(BusCompany);
15impl BusCompany {
16 _get_column!("BusCompany", name, String);
17 _get_column!("BusCompany", link, Option<String>);
18 _get_derived_vec!(lines, BusLine, "../sql/bus/company_lines.sql");
19 _get_derived_vec!(stops, BusStop, "../sql/bus/company_stops.sql");
20 _get_derived_vec!(berths, BusBerth, "../sql/bus/company_berths.sql");
21}
22
23node_type!(BusLine);
24impl BusLine {
25 _get_column!("BusLine", code, String);
26 _get_column!("BusLine", company, BusCompany);
27 _get_column!("BusLine", name, Option<String>);
28 _get_column!("BusLine", colour, Option<String>);
29 _get_column!("BusLine", mode, Option<BusMode>);
30 _get_column!("BusLine", local, Option<bool>);
31
32 _get_derived_vec!(berths, BusBerth, "../sql/bus/line_berths.sql");
33 _get_derived_vec!(stops, BusStop, "../sql/bus/company_stops.sql");
34}
35
36node_type!(located BusStop);
37impl BusStop {
38 _get_set!("BusStopCodes", codes, "code", String);
39 _get_column!("BusStop", company, BusCompany);
40 _get_column!("BusStop", name, Option<String>);
41
42 _get_derived_vec!(berths, BusBerth, "../sql/bus/stop_berths.sql");
43 _get_derived_vec!(
44 connections_from_here,
45 BusConnection,
46 "../sql/bus/stop_connections_from_here.sql"
47 );
48 _get_derived_vec!(
49 connections_to_here,
50 BusConnection,
51 "../sql/bus/stop_connections_to_here.sql"
52 );
53 _get_derived_vec!(lines, BusLine, "../sql/bus/stop_lines.sql");
54}
55
56node_type!(BusBerth);
57impl BusBerth {
58 _get_column!("BusBerth", code, Option<String>);
59 _get_column!("BusBerth", stop, BusStop);
60
61 _get_derived_vec!(
62 connections_from_here,
63 BusConnection,
64 "../sql/bus/berth_connections_from_here.sql"
65 );
66 _get_derived_vec!(
67 connections_to_here,
68 BusConnection,
69 "../sql/bus/berth_connections_to_here.sql"
70 );
71 _get_derived_vec!(lines, BusLine, "../sql/bus/berth_lines.sql");
72}
73
74node_type!(BusConnection);
75impl BusConnection {
76 _get_column!("BusConnection", line, BusLine);
77 _get_column!("BusConnection", from, BusBerth);
78 _get_column!("BusConnection", to, BusBerth);
79 _get_column!("BusConnection", direction, Option<String>);
80 _get_column!("BusConnection", duration, Option<u32>);
81}