pub struct GtfsReader {
    pub read_stop_times: bool,
    pub unkown_enum_as_default: bool,
    pub trim_fields: bool,
}
Expand description

Allows to parameterize how the parsing library behaves

let gtfs = gtfs_structures::GtfsReader::default()
   .read_stop_times(false) // Won’t read the stop times to save time and memory
   .unkown_enum_as_default(false) // Won’t convert unknown enumerations into default (e.g. LocationType=42 considered as a stop point)
   .read("fixtures/zips/gtfs.zip")?;
assert_eq!(0, gtfs.trips.get("trip1").unwrap().stop_times.len());

You can also get a RawGtfs by doing

let gtfs = gtfs_structures::GtfsReader::default()
   .read_stop_times(false)
   .raw()
   .read("fixtures/zips/gtfs.zip")?;
assert_eq!(1, gtfs.trips?.len());
assert_eq!(0, gtfs.stop_times?.len());

Fields§

§read_stop_times: bool

crate::objects::StopTime are very large and not always needed. This allows to skip reading them

§unkown_enum_as_default: bool

If a an enumeration has un unknown value, should we use the default value

§trim_fields: bool

Avoid trimming the fields

It is quite time consumming If performance is an issue, and if your data is high quality, you can switch it off

Implementations§

Configures the reader to read or not the stop times (default: true)

This can be useful to save time and memory with large datasets when the timetable are not needed Returns Self and can be chained

If a an enumeration has un unknown value, should we use the default value (default: false)

For instance, if crate::objects::Stop has a crate::objects::LocationType with a value 42 in the GTFS when true, we will parse it as StopPoint when false, we will parse it as Unknown(42) Returns Self and can be chained

Should the fields be trimmed (default: true)

It is quite time consumming If performance is an issue, and if your data is high quality, you can set it to false

Reads from an url (if starts with "http"), or a local path (either a directory or zipped file)

To read from an url, build with read-url feature See also Gtfs::from_url and Gtfs::from_path if you don’t want the library to guess

 Reads the raw GTFS from a local zip archive or local directory

Reads the GTFS from a remote url

The library must be built with the read-url feature

Asynchronously reads the GTFS from a remote url

The library must be built with the read-url feature

Read the Gtfs as a RawGtfs.

let gtfs = gtfs_structures::GtfsReader::default()
   .read_stop_times(false)
   .raw()
   .read("fixtures/zips/gtfs.zip")?;
assert_eq!(1, gtfs.trips?.len());
assert_eq!(0, gtfs.stop_times?.len());

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more