Expand description
Client for the HAFAS ReST public transport API.
The types follow the dialect versions DIALECT_VERSIONS of the API
and read both: fields that only one of them sends are optional. They
cover location search, departure and arrival boards, trip search, journey
details and the reconstruction of a trip.
The crate is neutral towards the operator: it has no default base URL and no policy for the access key.
use hafas::{Client, LocationName};
let client = Client::builder("https://hafas.example.org/api/")
.access_id("secret")
.user_agent("my-app/1.0 (+https://example.org)")
.build()?;
let list = client.send(&LocationName::new("Hauptwache")).await?;
for stop in list.stops() {
println!("{} {}", stop.ext_id, stop.name);
}The access key is a query parameter, so every request URL contains it.
The client keeps it out of everything it returns or logs: Client::url
leaves it out, errors carry no URL, and texts of the API that echo the key
have it replaced by REDACTED.
The client sends every request once. It does not retry, and it does not cache: that is up to the caller.
Structs§
- Arrival
- An arrival of an arrival board.
- Arrival
Board - The arrivals at a stop (
arrivalBoard). - Arrival
List - The answer of
arrivalBoard. - Board
Event - What departures and arrivals have in common.
- Client
- A client for one HAFAS server.
- Client
Builder - Configures a
Client. - Coord
Location - An address, a point of interest or a coordinate.
- Departure
- A departure of a departure board.
- Departure
Board - The departures at a stop (
departureBoard). - Departure
List - The answer of
departureBoard. - Direction
- A direction a journey shows on part of its route.
- Journey
- One journey with its stops: the answer of
journeyDetail, and part of a leg (JourneyDetail). - Journey
Detail - One journey with all its stops (
journeyDetail). - Journey
Detail Ref - A reference to a journey, for
JourneyDetail. - Leg
- A leg of a trip: a journey, a walk or a transfer.
- Location
List - The answer of
location.nameandlocation.nearbystops. - Location
Name - Finds locations by name (
location.name). - Location
Note - A note on a location.
- Message
- A message about a disruption or a change (from HIM).
- Name
- A name a journey has on part of its route.
- Nearby
Stops - Finds stops near a position (
location.nearbystops). - Note
- A note on a stop, a journey or a part of it.
- Occupancy
- How full a vehicle is expected to be.
- Origin
Dest - The start or the end of a trip or a leg (
OriginDestType). - Platform
- A platform, a stand or the like.
- Product
- A line or a vehicle (
ProductType). - Recon
- Checks a trip again with current data (
recon). - Response
Info - What every response says about itself (
CommonResponseType). - Service
Days - The days a journey or a trip runs.
- Stop
- A stop of a journey (
StopType). - Stop
Location - A stop or station.
- Trip
- A connection between two places (
TripType). - Trip
List - The answer of
tripandrecon. - Trip
Search - Searches connections between two places (
trip). - Trip
Status - Remarks of the server on a trip.
- Url
- A parsed URL record.
Enums§
- Error
- What can go wrong talking to the API.
- Journey
Status - What kind of journey a departure, an arrival or a leg is
(
JourneyStatusType). - Location
- A match of a location search.
- Location
Kind - What kind of place a location is: a stop, an address, a point of interest or a coordinate.
- Place
- Where a trip starts or ends.
- Platform
Kind - What a platform text names (
PlatformTypeType). - Prognosis
Type - Where a real-time time comes from (
PrognosisType). - RtMode
- How much real-time data a search takes into account (
rtMode).
Constants§
- DEFAULT_
TIMEOUT - The default time to wait for a response.
- DIALECT_
VERSIONS - The dialect versions of the API this crate reads.
- REDACTED
- What stands in for the access key in texts of the API that echo it.
Traits§
- Request
- A request to one service, sent with
Client::send.