Struct lta::async::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<Client>> for Bus

source§

async fn get_arrival<'a, S>( client: &LTAClient<ReqwestAsync>, bus_stop_code: u32, service_no: S ) -> LTAResult<BusArrivalResp>
where S: Into<Option<&'a str>>,

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

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

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

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

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§

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

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<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<ReqwestAsync>

source§

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

source§

async 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<Client>> for Crowd

source§

async fn get_passenger_vol_by<S, D>( client: &LTAClient<ReqwestAsync>, vol_type: VolType, date: D, skip: S ) -> LTAResult<Vec<String>>
where S: Into<Option<u32>>, D: Into<Option<Date>>,

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

async fn get_crowd_density_rt( client: &LTAClient<ReqwestAsync>, 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§

async fn get_crowd_density_forecast( client: &LTAClient<ReqwestAsync>, 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<Client>> for Facility

source§

async fn get_facilities_maintenance( client: &LTAClient<ReqwestAsync>, 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<Client>> for Geo

source§

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

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

impl TaxiRequests<LTAClient<Client>> for Taxi

source§

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

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

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

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

impl TrafficRequests<LTAClient<Client>> for Traffic

source§

async fn get_bike_parking<D>( client: &LTAClient<ReqwestAsync>, lat: f64, long: f64, dist: D ) -> LTAResult<Vec<BikeParking>>
where D: Into<Option<f64>>,

Returns bicycle parking locations within a radius Read more
source§

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

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

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

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§

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

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

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

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

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

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

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

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

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

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

async fn get_traffic_incidents<S>( client: &C, skip: S ) -> LTAResult<Vec<TrafficIncident>>
where S: Into<Option<u32>> + Send,

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

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

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§

async 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<Client>> for Train

source§

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

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