gistools/readers/gtfs/schedule/
route_networks.rs

1use crate::readers::csv::parse_csv_as_record;
2use alloc::{string::String, vec::Vec};
3use s2json::MValueCompatible;
4
5/// # Route Networks
6///
7/// **Conditionally Forbidden**
8/// Assigns routes (`routes.route_id`) to networks (`networks.network_id`).
9/// This file is forbidden if `network_id` exists in `routes.txt`. Otherwise, it is optional.
10#[derive(Debug, Default, Clone, PartialEq, MValueCompatible)]
11pub struct GTFSRouteNetwork {
12    /// **Required**
13    /// Identifies a network (`networks.network_id`) to which one or multiple routes belong.
14    pub network_id: String,
15    /// **Required**
16    /// Identifies a route (`routes.route_id`). One route can only belong to one network.
17    pub route_id: String,
18}
19impl GTFSRouteNetwork {
20    /// Create a new GTFSRouteNetwork
21    pub fn new(source: &str) -> Vec<GTFSRouteNetwork> {
22        let mut res = Vec::new();
23        for record in parse_csv_as_record::<GTFSRouteNetwork>(source, None, None) {
24            res.push(record);
25        }
26        res
27    }
28}