Skip to main content

Crate motis

Crate motis 

Source
Expand description

Client for the MOTIS 2 public transport routing API.

The types follow the OpenAPI specification of MOTIS MOTIS_VERSION, vendored unchanged in openapi/openapi.yaml. They cover geocoding, connections, departures and trips.

use motis::{Client, Geocode, LocationType};

let client = Client::builder("https://motis.example.org")
    .user_agent("my-app/1.0 (contact: ops@example.org)")
    .build()?;
let stops = client
    .send(&Geocode {
        types: vec![LocationType::Stop],
        ..Geocode::new("Hauptwache")
    })
    .await?;
for stop in stops {
    println!("{} {}", stop.id, stop.name);
}

The client sends every request once. It does not retry, and it does not cache: that is up to the caller.

Structs§

Alert
A service alert (GTFS-RT).
Area
An administrative area of a Match.
Client
A client for one MOTIS server.
ClientBuilder
Configures a Client.
Geocode
Finds stops, addresses and places by name (/api/v1/geocode).
Itinerary
A connection from one place to another.
Leg
One leg of an Itinerary: a ride on one trip, or a walk.
Match
A geocoding match: a stop, an address or another place.
Place
A stop or another place of a connection, with its times.
Plan
Plans connections between two places (/api/v6/plan).
PlanResponse
The response of Plan.
ReverseGeocode
Finds stops, addresses and places near a position (/api/v1/reverse-geocode).
StopTime
A departure or arrival at a stop.
Stoptimes
Departures or arrivals at a stop (/api/v6/stoptimes).
StoptimesResponse
The response of Stoptimes.
TimeRange
A period of an Alert.
Timestamp
An instant in time represented as the number of nanoseconds since the Unix epoch.
Trip
One trip with all its stops (/api/v6/trip).
Url
A parsed URL record.

Enums§

AlertCause
The cause of an alert (GTFS-RT Cause).
AlertEffect
The effect of an alert on the service (GTFS-RT Effect).
AlertSeverityLevel
How severe an alert is.
Direction
The direction of a departure search without a page cursor.
Error
What can go wrong talking to the API.
LocationType
The kind of a geocoding match.
Mode
A means of transport, or a group of them like Mode::Transit.
PickupDropoffType
Whether passengers may board or alight. Cancellations and skipped stops show as PickupDropoffType::NotAllowed.
RealtimeMode
How routing uses realtime data.
TimestampReason
Where a time comes from.
VertexType
The kind of a place in a street routing.

Constants§

API_VERSION
The version of the API in the vendored specification (info.version), also the path prefix of the routing endpoints, like /api/v6/plan.
DEFAULT_TIMEOUT
The default time to wait for a response.
MOTIS_VERSION
The MOTIS release whose API this crate implements.
OPENAPI_SPEC
The vendored OpenAPI specification.

Traits§

Request
A request to one endpoint, sent with Client::send.