gtfs_structures/lib.rs
1/*! The [General Transit Feed Specification](https://gtfs.org/) (GTFS) is a commonly used model to represent public transit data.
2
3This crates brings [serde](https://serde.rs) structures of this model and helpers to read GTFS files.
4
5To get started, see [Gtfs].
6
7## What is GTFS
8
9A Gtfs feed is a collection of CSV files (often bundled as a zip file).
10Each file represents a collection of one type (stops, lines, etc.) that have relationships through unique identifiers.
11
12This crate reads a feed, deserializes the objects into Rust structs and verifies the relationships.
13
14## Design decisions
15
16### Two representations
17
18The [RawGtfs] representation holds the objects as close as possible to their CSV representation. This allows to check invalid references.
19
20[Gtfs] re-organizes a bit the data. For instance all the [StopTime] are included within their corresponding [Trip] and cannot be accessed directly.
21If an object references a non existing Id it will be an error.
22
23### Use of Enum
24
25Many values are integers that are actually enumerations of certain values. We always use Rust enums, like [LocationType] to represent them, and not the integer value.
26
27### Reference
28
29We try to stick as closely as possible to the reference. Optional fields are [std::option], while missing mandatory elements will result in an error.
30If a default value is defined, we will use it.
31
32There are two references <https://gtfs.org/reference/static> and <https://developers.google.com/transit/gtfs/reference>. They are mostly the same, even if google’s specification has some extensions.
33
34### Renaming
35
36We kept some names even if they can be confusing (a [Calendar] will be referenced by `service_id`), but we strip the object type (`route_short_name` is [Route::short_name]).
37
38*/
39#![warn(missing_docs)]
40
41#[macro_use]
42extern crate derivative;
43#[macro_use]
44extern crate serde_derive;
45
46mod enums;
47pub mod error;
48mod gtfs;
49mod gtfs_reader;
50pub(crate) mod objects;
51mod raw_gtfs;
52mod serde_helpers;
53
54#[cfg(test)]
55mod tests;
56
57pub use error::Error;
58pub use gtfs::Gtfs;
59pub use gtfs_reader::GtfsReader;
60pub use objects::*;
61pub use raw_gtfs::RawGtfs;