Expand description

The General Transit Feed Specification (GTFS) is a commonly used model to represent public transit data.

This crates brings serde structures of this model and helpers to read GTFS files.

To get started, see Gtfs.

What is GTFS

A Gtfs feed is a collection of CSV files (often bundled as a zip file). Each file represents a collection of one type (stops, lines, etc.) that have relationships through unique identifiers.

This crate reads a feed, deserializes the objects into Rust structs and verifies the relationships.

Design decisions

Two representations

The RawGtfs representation holds the objects as close as possible to their CSV representation. This allows to check invalid references.

Gtfs re-organizes a bit the data. For instance all the StopTime are included within their corresponding Trip and cannot be accessed directly. If an object references a non existing Id it will be an error.

Use of Enum

Many 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.


We try to stick as closely as possible to the reference. Optional fields are std::option, while missing mandatory elements will result in an error. If a default value is defined, we will use it.

There 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.


We 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).


pub use error::Error;


Module for the error management


General informations about the agency running the network. See https://gtfs.org/reference/static/#agencytxt

A calender describes on which days the vehicle runs. See https://gtfs.org/reference/static/#calendartxt

Defines a specific date that can be added or removed from a Calendar. See https://gtfs.org/reference/static/#calendar_datestxt

Timetables can be defined by the frequency of their vehicles. See <https://gtfs.org/reference/static/#frequenciestxt>

Data structure with all the GTFS objects

Allows to parameterize how the parsing library behaves

Pathway going from a stop to another.

A Frequency before being merged into the corresponding Trip

Data structure that map the GTFS csv with little intelligence

A graph representation to describe subway or train, with nodes (the locations) and edges (the pathways).

A StopTime where the relations with Trip and Stop have not been tested

Transfer information between stops before merged into Stop

A Trip where the relationships with other objects have not been checked

A route is a commercial line (there can be various stop sequences for a same line). See https://gtfs.org/reference/static/#routestxt

A single geographical point decribing the shape of a Trip. See https://gtfs.org/reference/static/#shapestxt

A physical stop, station or area. See https://gtfs.org/reference/static/#stopstxt

The moment where a vehicle, running on Trip stops at a Stop. See https://gtfs.org/reference/static/#stopstxt

Transfer information between stops

A Trip is a vehicle that follows a sequence of StopTime on certain days. See https://gtfs.org/reference/static/#tripstxt


Generic enum to define if a service (like wheelchair boarding) is available

Is the [Trip] accessible with a bike. See https://gtfs.org/reference/static/#tripstxt bikes_allowed

Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path

Defines the direction of a [Trip], only for display, not for routing. See https://gtfs.org/reference/static/#tripstxt direction_id

Defines if the [Frequency] is exact (the vehicle runs exactly every n minutes) or not

Defines if a [CalendarDate] is added or deleted from a [Calendar]

Describes the kind of [Stop]. See https://gtfs.org/reference/static/#stopstxt location_type

All the objects type from the GTFS specification that this library reads

Indicates in which direction the pathway can be used

Type of pathway between [from_stop] and [to_stop]

Defines where a [FareAttribute] can be paid

Describes if and how a traveller can board or alight the vehicle. See https://gtfs.org/reference/static/#stop_timestxt pickup_type and dropoff_type

Describes the kind of [Route]. See https://gtfs.org/reference/static/#routestxt route_type

Describes if the stop time is exact or not. See https://gtfs.org/reference/static/#stop_timestxt timepoint

Defines the type of a [StopTransfer]

Defines how many transfers can be done with on [FareAttribute]


Objects that have an identifier implement this trait

Trait to introspect what is the object’s type (stop, route…)