pub struct LTAClient { /* private fields */ }
Expand description
A Client
to make requests with
The Client
holds a connection pool internally, so it is advised that you create one and reuse it
There are some instance where you might need to customise your client due to certain limitations.
The Client
trait has a general constructor method and you should use the reqwest
re-export
to build you own customised client from the ground up.
Take a look at the reqwest documentation on how to build your own client
Example
use lta::r#async::client::LTAClient;
use lta::reqwest::ClientBuilder;
use std::time::Duration;
use lta::Client;
fn my_custom_client() -> LTAClient {
let client = ClientBuilder::new()
.no_gzip()
.connect_timeout(Duration::new(420, 0))
.build()
.unwrap();
LTAClient::new("API_KEY", client)
}
Trait Implementations
sourceimpl BusRequests<LTAClient> for Bus
impl BusRequests<LTAClient> for Bus
sourcefn get_arrival<'a, 'life0, 'async_trait, S>(
client: &'life0 LTAClient,
bus_stop_code: u32,
service_no: S
) -> Pin<Box<dyn Future<Output = LTAResult<BusArrivalResp>> + Send + 'async_trait>> where
S: Into<Option<&'a str>> + Send,
'a: 'async_trait,
S: 'async_trait,
'life0: 'async_trait,
fn get_arrival<'a, 'life0, 'async_trait, S>(
client: &'life0 LTAClient,
bus_stop_code: u32,
service_no: S
) -> Pin<Box<dyn Future<Output = LTAResult<BusArrivalResp>> + Send + 'async_trait>> where
S: Into<Option<&'a str>> + Send,
'a: 'async_trait,
S: 'async_trait,
'life0: 'async_trait,
Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including Read more
sourcefn get_bus_services<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BusService>>> + Send + 'async_trait>> where
S: 'async_trait + Into<Option<u32>> + Send,
'life0: 'async_trait,
fn get_bus_services<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BusService>>> + Send + 'async_trait>> where
S: 'async_trait + Into<Option<u32>> + Send,
'life0: 'async_trait,
Returns detailed service information for all buses currently in operation, including: first stop, last stop, peak / offpeak frequency of dispatch. Read more
sourcefn get_bus_routes<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BusRoute>>> + Send + 'async_trait>> where
S: 'async_trait + Into<Option<u32>> + Send,
'life0: 'async_trait,
fn get_bus_routes<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BusRoute>>> + Send + 'async_trait>> where
S: 'async_trait + Into<Option<u32>> + Send,
'life0: 'async_trait,
Returns detailed route information for all services currently in operation, including: all bus stops along each route, first/last bus timings for each stop Read more
sourcefn get_bus_stops<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BusStop>>> + Send + 'async_trait>> where
S: 'async_trait + Into<Option<u32>> + Send,
'life0: 'async_trait,
fn get_bus_stops<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BusStop>>> + Send + 'async_trait>> where
S: 'async_trait + Into<Option<u32>> + Send,
'life0: 'async_trait,
Returns detailed information for all bus stops currently being serviced by buses, including: Bus Stop Code, location coordinates. Read more
sourceimpl Client for LTAClient
impl Client for LTAClient
type InternalClient = Client
type InternalClient = Client
Any backend Client
type RB = RequestBuilder
type RB = RequestBuilder
Any type that can build requests
sourcefn new(api_key: impl Into<String>, client: Self::InternalClient) -> LTAClient
fn new(api_key: impl Into<String>, client: Self::InternalClient) -> LTAClient
General constructor for Self
sourcefn with_api_key(api_key: impl Into<String>) -> LTAResult<Self>
fn with_api_key(api_key: impl Into<String>) -> LTAResult<Self>
This method not assign the api_key
in struct if the provided key is empty or whitespaces
Instead, assign None
Read more
sourcefn req_builder(&self, url: &str) -> Self::RB
fn req_builder(&self, url: &str) -> Self::RB
Returns Self::RB
sourceimpl CrowdRequests<LTAClient> for Crowd
impl CrowdRequests<LTAClient> for Crowd
sourcefn get_passenger_vol_by<'life0, 'async_trait, S, D>(
client: &'life0 LTAClient,
vol_type: VolType,
date: D,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<String>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
D: Into<Option<NaiveDate>> + Send,
S: 'async_trait,
D: 'async_trait,
'life0: 'async_trait,
fn get_passenger_vol_by<'life0, 'async_trait, S, D>(
client: &'life0 LTAClient,
vol_type: VolType,
date: D,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<String>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
D: Into<Option<NaiveDate>> + Send,
S: 'async_trait,
D: 'async_trait,
'life0: 'async_trait,
Update freq: By 15th of every month, the passenger volume for previous month data will be generated Read more
sourcefn get_crowd_density_rt<'life0, 'async_trait>(
client: &'life0 LTAClient,
train_line: MrtLine
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<StationCrowdLevel>>> + Send + 'async_trait>> where
'life0: 'async_trait,
fn get_crowd_density_rt<'life0, 'async_trait>(
client: &'life0 LTAClient,
train_line: MrtLine
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<StationCrowdLevel>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Returns real-time platform crowdedness level for the MRT/LRT stations of a particular train network line Read more
sourcefn get_crowd_density_forecast<'life0, 'async_trait>(
client: &'life0 LTAClient,
train_line: MrtLine
) -> Pin<Box<dyn Future<Output = LTAResult<CrowdDensityForecast>> + Send + 'async_trait>> where
'life0: 'async_trait,
fn get_crowd_density_forecast<'life0, 'async_trait>(
client: &'life0 LTAClient,
train_line: MrtLine
) -> Pin<Box<dyn Future<Output = LTAResult<CrowdDensityForecast>> + Send + 'async_trait>> where
'life0: 'async_trait,
Returns forecasted platform crowdedness level for the MRT/LRT stations of a particular train network line at 30 minutes interval Read more
sourceimpl FacilityRequests<LTAClient> for Facility
impl FacilityRequests<LTAClient> for Facility
sourcefn get_facilities_maintenance<'life0, 'async_trait>(
client: &'life0 LTAClient,
station_code: StationCode
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<String>>> + Send + 'async_trait>> where
'life0: 'async_trait,
fn get_facilities_maintenance<'life0, 'async_trait>(
client: &'life0 LTAClient,
station_code: StationCode
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<String>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Returns pre-signed links to JSON file containing facilities maintenance schedules of the particular station Read more
sourceimpl GeoRequests<LTAClient> for Geo
impl GeoRequests<LTAClient> for Geo
sourceimpl TaxiRequests<LTAClient> for Taxi
impl TaxiRequests<LTAClient> for Taxi
sourcefn get_taxi_avail<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<Coordinates>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_taxi_avail<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<Coordinates>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns location coordinates of all Taxis that are currently available for hire. Does not include “Hired” or “Busy” Taxis. Read more
sourcefn get_taxi_stands<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TaxiStand>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_taxi_stands<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TaxiStand>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns detailed information of Taxi stands, such as location and whether is it barrier free. Read more
sourceimpl TrafficRequests<LTAClient> for Traffic
impl TrafficRequests<LTAClient> for Traffic
sourcefn get_erp_rates<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<ErpRate>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_erp_rates<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<ErpRate>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns ERP rates of all vehicle types across all timings for each zone. Read more
sourcefn get_carpark_avail<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<CarPark>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_carpark_avail<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<CarPark>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns no. of available lots for HDB, LTA and URA carpark data. The LTA carpark data consist of major shopping malls and developments within Orchard, Marina, HarbourFront, Jurong Lake District. (Note: list of LTA carpark data available on this API is subset of those listed on One.Motoring and MyTransport Portals) Read more
sourcefn get_est_travel_time<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<EstTravelTime>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_est_travel_time<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<EstTravelTime>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns estimated travel times of expressways (in segments). Read more
sourcefn get_faulty_traffic_lights<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<FaultyTrafficLight>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_faulty_traffic_lights<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<FaultyTrafficLight>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns alerts of traffic lights that are currently faulty, or currently undergoing scheduled maintenance. Read more
sourcefn get_road_details<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
road_details_type: RoadDetailsType,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<RoadDetails>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_road_details<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
road_details_type: RoadDetailsType,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<RoadDetails>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns all planned road openings or road works depending on the RoadDetailsType
supplied Read more
sourcefn get_traffic_speed_band<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TrafficSpeedBand>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_traffic_speed_band<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TrafficSpeedBand>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns current traffic speeds on expressways and arterial roads, expressed in speed bands. Read more
sourcefn get_traffic_images<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TrafficImage>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_traffic_images<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TrafficImage>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns links to images of live traffic conditions along expressways and Woodlands & Tuas Checkpoints. Read more
sourcefn get_traffic_incidents<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TrafficIncident>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_traffic_incidents<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<TrafficIncident>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns current traffic speeds on expressways and arterial roads, expressed in speed bands. Read more
sourcefn get_vms_emas<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<Vms>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_vms_emas<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<Vms>>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns traffic advisories (via variable message services) concerning current traffic conditions that are displayed on EMAS signboards along expressways and arterial roads. Read more
sourcefn get_bike_parking<'life0, 'async_trait, D>(
client: &'life0 LTAClient,
lat: f64,
long: f64,
dist: D
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BikeParking>>> + Send + 'async_trait>> where
D: Into<Option<f64>> + Send,
D: 'async_trait,
'life0: 'async_trait,
fn get_bike_parking<'life0, 'async_trait, D>(
client: &'life0 LTAClient,
lat: f64,
long: f64,
dist: D
) -> Pin<Box<dyn Future<Output = LTAResult<Vec<BikeParking>>> + Send + 'async_trait>> where
D: Into<Option<f64>> + Send,
D: 'async_trait,
'life0: 'async_trait,
Returns bicycle parking locations within a radius Read more
sourceimpl TrainRequests<LTAClient> for Train
impl TrainRequests<LTAClient> for Train
sourcefn get_train_service_alert<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<TrainServiceAlert>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
fn get_train_service_alert<'life0, 'async_trait, S>(
client: &'life0 LTAClient,
skip: S
) -> Pin<Box<dyn Future<Output = LTAResult<TrainServiceAlert>> + Send + 'async_trait>> where
S: Into<Option<u32>> + Send,
S: 'async_trait,
'life0: 'async_trait,
Returns detailed information on train service unavailability during scheduled operating hours, such as affected line and stations etc. Read more
Auto Trait Implementations
impl !RefUnwindSafe for LTAClient
impl Send for LTAClient
impl Sync for LTAClient
impl Unpin for LTAClient
impl !UnwindSafe for LTAClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more