Struct lta::blocking::client::LTAClient

source ·
pub struct LTAClient<T> {
    pub api_key: String,
    pub client: T,
    pub base_url: String,
}
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.

Fields§

§api_key: String§client: T§base_url: String

Trait Implementations§

source§

impl BusRequests<LTAClient<Agent>> for Bus

source§

fn get_arrival<'a>( client: &LTAClient<Agent>, bus_stop_code: u32, service_no: impl Into<Option<&'a str>> ) -> LTAResult<BusArrivalResp>

Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including Read more
source§

fn get_bus_services( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<BusService>>

Returns detailed service information for all buses currently in operation, including: first stop, last stop, peak / offpeak frequency of dispatch. Read more
source§

fn get_bus_routes( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<BusRoute>>

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
source§

fn get_bus_stops( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<BusStop>>

Returns detailed information for all bus stops currently being serviced by buses, including: Bus Stop Code, location coordinates. Read more
source§

impl BusRequests<LTAClient<Client>> for Bus

source§

fn get_arrival<'a>( client: &LTAClient<ReqwestBlocking>, bus_stop_code: u32, service_no: impl Into<Option<&'a str>> ) -> LTAResult<BusArrivalResp>

Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including Read more
source§

fn get_bus_services( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<BusService>>

Returns detailed service information for all buses currently in operation, including: first stop, last stop, peak / offpeak frequency of dispatch. Read more
source§

fn get_bus_routes( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<BusRoute>>

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
source§

fn get_bus_stops( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<BusStop>>

Returns detailed information for all bus stops currently being serviced by buses, including: Bus Stop Code, location coordinates. Read more
source§

impl Client for LTAClient<Agent>

§

type InternalClient = Agent

Any backend Client
§

type RB = Request

Any type that can build requests
source§

fn new( api_key: impl Into<String>, client: Self::InternalClient, base_url: impl Into<String> ) -> Self

General constructor for Self
source§

fn with_api_key( api_key: impl Into<String>, base_url: 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
source§

fn req_builder(&self, url: &str) -> Self::RB

Returns Self::RB
source§

fn base_url(&self) -> &str

Returns the base URL that is set by user
source§

impl Client for LTAClient<Client>

§

type InternalClient = Client

Any backend Client
§

type RB = RequestBuilder

Any type that can build requests
source§

fn new( api_key: impl Into<String>, client: Self::InternalClient, base_url: impl Into<String> ) -> Self

General constructor for Self
source§

fn with_api_key( api_key: impl Into<String>, base_url: 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
source§

fn req_builder(&self, url: &str) -> Self::RB

Returns Self::RB
source§

fn base_url(&self) -> &str

Returns the base URL that is set by user
source§

impl ClientExt for LTAClient<Agent>

source§

fn build_req_with_skip<T, T2>( &self, url: &str, skip: Option<u32> ) -> LTAResult<T2>
where for<'de> T: Deserialize<'de> + Into<T2>,

source§

fn build_req_with_query<T, T2, F>(&self, url: &str, query: F) -> LTAResult<T2>
where F: FnOnce(Self::RB) -> Self::RB, for<'de> T: Deserialize<'de> + Into<T2>,

source§

impl ClientExt for LTAClient<ReqwestBlocking>

source§

fn build_req_with_skip<T, T2>( &self, url: &str, skip: Option<u32> ) -> LTAResult<T2>
where for<'de> T: Deserialize<'de> + Into<T2>,

source§

fn build_req_with_query<T, T2, F>(&self, url: &str, query: F) -> LTAResult<T2>
where F: FnOnce(Self::RB) -> Self::RB, for<'de> T: Deserialize<'de> + Into<T2>,

source§

impl<T: Clone> Clone for LTAClient<T>

source§

fn clone(&self) -> LTAClient<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CrowdRequests<LTAClient<Agent>> for Crowd

source§

fn get_passenger_vol_by( client: &LTAClient<Agent>, vol_type: VolType, date: impl Into<Option<Date>>, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<String>>

Creates a new client for every call Update freq: By 15th of every month, the passenger volume for previous month data will be generated Read more
source§

fn get_crowd_density_rt( client: &LTAClient<Agent>, train_line: MrtLine ) -> LTAResult<Vec<StationCrowdLevel>>

Returns real-time platform crowdedness level for the MRT/LRT stations of a particular train network line Read more
source§

fn get_crowd_density_forecast( client: &LTAClient<Agent>, train_line: MrtLine ) -> LTAResult<CrowdDensityForecast>

Returns forecasted platform crowdedness level for the MRT/LRT stations of a particular train network line at 30 minutes interval Read more
source§

impl CrowdRequests<LTAClient<Client>> for Crowd

source§

fn get_passenger_vol_by( client: &LTAClient<ReqwestBlocking>, vol_type: VolType, date: impl Into<Option<Date>>, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<String>>

Creates a new client for every call Update freq: By 15th of every month, the passenger volume for previous month data will be generated Read more
source§

fn get_crowd_density_rt( client: &LTAClient<ReqwestBlocking>, train_line: MrtLine ) -> LTAResult<Vec<StationCrowdLevel>>

Returns real-time platform crowdedness level for the MRT/LRT stations of a particular train network line Read more
source§

fn get_crowd_density_forecast( client: &LTAClient<ReqwestBlocking>, train_line: MrtLine ) -> LTAResult<CrowdDensityForecast>

Returns forecasted platform crowdedness level for the MRT/LRT stations of a particular train network line at 30 minutes interval Read more
source§

impl<T: Debug> Debug for LTAClient<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FacilityRequests<LTAClient<Agent>> for Facility

source§

fn get_facilities_maintenance( client: &LTAClient<Agent>, station_code: StationCode ) -> LTAResult<Vec<String>>

Returns pre-signed links to JSON file containing facilities maintenance schedules of the particular station Read more
source§

impl FacilityRequests<LTAClient<Client>> for Facility

source§

fn get_facilities_maintenance( client: &LTAClient<ReqwestBlocking>, station_code: StationCode ) -> LTAResult<Vec<String>>

Returns pre-signed links to JSON file containing facilities maintenance schedules of the particular station Read more
source§

impl GeoRequests<LTAClient<Agent>> for Geo

source§

fn get_geospatial_whole_island( client: &LTAClient<Agent>, id: GeospatialLayerId ) -> LTAResult<Vec<String>>

Returns the SHP files of the requested geospatial layer Read more
source§

impl GeoRequests<LTAClient<Client>> for Geo

source§

fn get_geospatial_whole_island( client: &LTAClient<ReqwestBlocking>, id: GeospatialLayerId ) -> LTAResult<Vec<String>>

Returns the SHP files of the requested geospatial layer Read more
source§

impl TaxiRequests<LTAClient<Agent>> for Taxi

source§

fn get_taxi_avail( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<Coordinates>>

Returns location coordinates of all Taxis that are currently available for hire. Does not include “Hired” or “Busy” Taxis. Read more
source§

fn get_taxi_stands( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TaxiStand>>

Returns detailed information of Taxi stands, such as location and whether is it barrier free. Read more
source§

impl TaxiRequests<LTAClient<Client>> for Taxi

source§

fn get_taxi_avail( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<Coordinates>>

Returns location coordinates of all Taxis that are currently available for hire. Does not include “Hired” or “Busy” Taxis. Read more
source§

fn get_taxi_stands( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TaxiStand>>

Returns detailed information of Taxi stands, such as location and whether is it barrier free. Read more
source§

impl TrafficRequests<LTAClient<Agent>> for Traffic

source§

fn get_bike_parking( client: &LTAClient<Agent>, lat: f64, long: f64, dist: impl Into<Option<f64>> ) -> LTAResult<Vec<BikeParking>>

Returns bicycle parking locations within a radius Read more
source§

fn get_erp_rates( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<ErpRate>>

Returns ERP rates of all vehicle types across all timings for each zone. Read more
source§

fn get_carpark_avail( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<CarPark>>

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
source§

fn get_est_travel_time( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<EstTravelTime>>

Returns estimated travel times of expressways (in segments). Read more
source§

fn get_faulty_traffic_lights( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<FaultyTrafficLight>>

Returns alerts of traffic lights that are currently faulty, or currently undergoing scheduled maintenance. Read more
source§

fn get_road_details( client: &C, road_details_type: RoadDetailsType, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<RoadDetails>>

Returns all planned road openings or road works depending on the RoadDetailsType supplied Read more
source§

fn get_traffic_speed_band( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TrafficSpeedBand>>

Returns current traffic speeds on expressways and arterial roads, expressed in speed bands. Read more
source§

fn get_traffic_images( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TrafficImage>>

Returns links to images of live traffic conditions along expressways and Woodlands & Tuas Checkpoints. Read more
source§

fn get_traffic_incidents( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TrafficIncident>>

Returns current traffic speeds on expressways and arterial roads, expressed in speed bands. Read more
source§

fn get_vms_emas(client: &C, skip: impl Into<Option<u32>>) -> LTAResult<Vec<Vms>>

Returns traffic advisories (via variable message services) concerning current traffic conditions that are displayed on EMAS signboards along expressways and arterial roads. Read more
source§

fn get_traffic_flow(client: &C) -> LTAResult<Vec<String>>

Returns hourly average traffic flow, taken from a representative month of every quarter during 0700-0900 hours. Read more
source§

impl TrafficRequests<LTAClient<Client>> for Traffic

source§

fn get_bike_parking( client: &LTAClient<ReqwestBlocking>, lat: f64, long: f64, dist: impl Into<Option<f64>> ) -> LTAResult<Vec<BikeParking>>

Returns bicycle parking locations within a radius Read more
source§

fn get_erp_rates( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<ErpRate>>

Returns ERP rates of all vehicle types across all timings for each zone. Read more
source§

fn get_carpark_avail( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<CarPark>>

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
source§

fn get_est_travel_time( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<EstTravelTime>>

Returns estimated travel times of expressways (in segments). Read more
source§

fn get_faulty_traffic_lights( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<FaultyTrafficLight>>

Returns alerts of traffic lights that are currently faulty, or currently undergoing scheduled maintenance. Read more
source§

fn get_road_details( client: &C, road_details_type: RoadDetailsType, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<RoadDetails>>

Returns all planned road openings or road works depending on the RoadDetailsType supplied Read more
source§

fn get_traffic_speed_band( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TrafficSpeedBand>>

Returns current traffic speeds on expressways and arterial roads, expressed in speed bands. Read more
source§

fn get_traffic_images( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TrafficImage>>

Returns links to images of live traffic conditions along expressways and Woodlands & Tuas Checkpoints. Read more
source§

fn get_traffic_incidents( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<Vec<TrafficIncident>>

Returns current traffic speeds on expressways and arterial roads, expressed in speed bands. Read more
source§

fn get_vms_emas(client: &C, skip: impl Into<Option<u32>>) -> LTAResult<Vec<Vms>>

Returns traffic advisories (via variable message services) concerning current traffic conditions that are displayed on EMAS signboards along expressways and arterial roads. Read more
source§

fn get_traffic_flow(client: &C) -> LTAResult<Vec<String>>

Returns hourly average traffic flow, taken from a representative month of every quarter during 0700-0900 hours. Read more
source§

impl TrainRequests<LTAClient<Agent>> for Train

source§

fn get_train_service_alert( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<TrainServiceAlert>

Returns detailed information on train service unavailability during scheduled operating hours, such as affected line and stations etc. Read more
source§

impl TrainRequests<LTAClient<Client>> for Train

source§

fn get_train_service_alert( client: &C, skip: impl Into<Option<u32>> ) -> LTAResult<TrainServiceAlert>

Returns detailed information on train service unavailability during scheduled operating hours, such as affected line and stations etc. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for LTAClient<T>
where T: RefUnwindSafe,

§

impl<T> Send for LTAClient<T>
where T: Send,

§

impl<T> Sync for LTAClient<T>
where T: Sync,

§

impl<T> Unpin for LTAClient<T>
where T: Unpin,

§

impl<T> UnwindSafe for LTAClient<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more