pub trait Provider<R: Requester> {
type Error: Error;
// Required methods
fn journeys<'life0, 'async_trait>(
&'life0 self,
from: Place,
to: Place,
opts: JourneysOptions,
) -> Pin<Box<dyn Future<Output = Result<JourneysResponse, Error<R::Error, Self::Error>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn locations<'life0, 'async_trait>(
&'life0 self,
opts: LocationsOptions,
) -> Pin<Box<dyn Future<Output = Result<LocationsResponse, Error<R::Error, Self::Error>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn station_board<'life0, 'async_trait>(
&'life0 self,
place: Place,
kind: StationBoardKind,
opts: StationBoardOptions,
) -> Pin<Box<dyn Future<Output = Result<StationBoardResponse, Error<R::Error, Self::Error>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn refresh_journey<'life0, 'life1, 'async_trait>(
&'life0 self,
journey: &'life1 Journey,
opts: RefreshJourneyOptions,
) -> Pin<Box<dyn Future<Output = Result<RefreshJourneyResponse, Error<R::Error, Self::Error>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
The core type definition specifying what a provider needs to do.
To implement the required methods, a provider usually queries an external but public API.
Required Associated Types§
Required Methods§
Sourcefn journeys<'life0, 'async_trait>(
&'life0 self,
from: Place,
to: Place,
opts: JourneysOptions,
) -> Pin<Box<dyn Future<Output = Result<JourneysResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn journeys<'life0, 'async_trait>(
&'life0 self,
from: Place,
to: Place,
opts: JourneysOptions,
) -> Pin<Box<dyn Future<Output = Result<JourneysResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Query a list of journeys.
Be careful about timezones! The types given to you are annotated with an arbitrary timezone, your public API may only understand one specific timezone though. Ensure you correctly convert the given timezone to a timezone you require. For returning a date and time, you may choose an arbitrary timezone.
Sourcefn locations<'life0, 'async_trait>(
&'life0 self,
opts: LocationsOptions,
) -> Pin<Box<dyn Future<Output = Result<LocationsResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn locations<'life0, 'async_trait>(
&'life0 self,
opts: LocationsOptions,
) -> Pin<Box<dyn Future<Output = Result<LocationsResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Autocomplete a location.
This takes a query string and should return a list of locations which match the given string.
Sourcefn station_board<'life0, 'async_trait>(
&'life0 self,
place: Place,
kind: StationBoardKind,
opts: StationBoardOptions,
) -> Pin<Box<dyn Future<Output = Result<StationBoardResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn station_board<'life0, 'async_trait>(
&'life0 self,
place: Place,
kind: StationBoardKind,
opts: StationBoardOptions,
) -> Pin<Box<dyn Future<Output = Result<StationBoardResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Query a list of arrivals/departures from a given station.
Sourcefn refresh_journey<'life0, 'life1, 'async_trait>(
&'life0 self,
journey: &'life1 Journey,
opts: RefreshJourneyOptions,
) -> Pin<Box<dyn Future<Output = Result<RefreshJourneyResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn refresh_journey<'life0, 'life1, 'async_trait>(
&'life0 self,
journey: &'life1 Journey,
opts: RefreshJourneyOptions,
) -> Pin<Box<dyn Future<Output = Result<RefreshJourneyResponse, Error<R::Error, Self::Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Refresh a journey.
This takes a previously queried journey and refreshes real-time data.
A naive implementation may call Provider::journeys
again and return the matching journey, this is a valid strategy if there is no API for refreshing a journey.