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
impl BusRequests<LTAClient<Agent>> for Bus
source§fn get_arrival<'a>(
client: <AClient<Agent>,
bus_stop_code: u32,
service_no: impl Into<Option<&'a str>>
) -> LTAResult<BusArrivalResp>
fn get_arrival<'a>( client: <AClient<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>>
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§impl BusRequests<LTAClient<Client>> for Bus
impl BusRequests<LTAClient<Client>> for Bus
source§fn get_arrival<'a>(
client: <AClient<ReqwestBlocking>,
bus_stop_code: u32,
service_no: impl Into<Option<&'a str>>
) -> LTAResult<BusArrivalResp>
fn get_arrival<'a>( client: <AClient<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>>
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§impl Client for LTAClient<Agent>
impl Client for LTAClient<Agent>
§type InternalClient = Agent
type InternalClient = Agent
Any backend Client
source§fn new(
api_key: impl Into<String>,
client: Self::InternalClient,
base_url: impl Into<String>
) -> Self
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>
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
fn req_builder(&self, url: &str) -> Self::RB
Returns
Self::RB
source§impl Client for LTAClient<Client>
impl Client for LTAClient<Client>
§type InternalClient = Client
type InternalClient = Client
Any backend Client
§type RB = RequestBuilder
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
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>
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
fn req_builder(&self, url: &str) -> Self::RB
Returns
Self::RB
source§impl ClientExt for LTAClient<Agent>
impl ClientExt for LTAClient<Agent>
fn build_req_with_skip<T, T2>(
&self,
url: &str,
skip: Option<u32>
) -> LTAResult<T2>where
for<'de> T: Deserialize<'de> + Into<T2>,
fn build_req_with_query<T, T2, F>(&self, url: &str, query: F) -> LTAResult<T2>
source§impl ClientExt for LTAClient<ReqwestBlocking>
impl ClientExt for LTAClient<ReqwestBlocking>
fn build_req_with_skip<T, T2>(
&self,
url: &str,
skip: Option<u32>
) -> LTAResult<T2>where
for<'de> T: Deserialize<'de> + Into<T2>,
fn build_req_with_query<T, T2, F>(&self, url: &str, query: F) -> LTAResult<T2>
source§impl CrowdRequests<LTAClient<Agent>> for Crowd
impl CrowdRequests<LTAClient<Agent>> for Crowd
source§fn get_passenger_vol_by(
client: <AClient<Agent>,
vol_type: VolType,
date: impl Into<Option<Date>>,
skip: impl Into<Option<u32>>
) -> LTAResult<Vec<String>>
fn get_passenger_vol_by( client: <AClient<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§impl CrowdRequests<LTAClient<Client>> for Crowd
impl CrowdRequests<LTAClient<Client>> for Crowd
source§fn get_passenger_vol_by(
client: <AClient<ReqwestBlocking>,
vol_type: VolType,
date: impl Into<Option<Date>>,
skip: impl Into<Option<u32>>
) -> LTAResult<Vec<String>>
fn get_passenger_vol_by( client: <AClient<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: <AClient<ReqwestBlocking>,
train_line: MrtLine
) -> LTAResult<Vec<StationCrowdLevel>>
fn get_crowd_density_rt( client: <AClient<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: <AClient<ReqwestBlocking>,
train_line: MrtLine
) -> LTAResult<CrowdDensityForecast>
fn get_crowd_density_forecast( client: <AClient<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 FacilityRequests<LTAClient<Client>> for Facility
impl FacilityRequests<LTAClient<Client>> for Facility
source§fn get_facilities_maintenance(
client: <AClient<ReqwestBlocking>,
station_code: StationCode
) -> LTAResult<Vec<String>>
fn get_facilities_maintenance( client: <AClient<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<Client>> for Geo
impl GeoRequests<LTAClient<Client>> for Geo
source§fn get_geospatial_whole_island(
client: <AClient<ReqwestBlocking>,
id: GeospatialLayerId
) -> LTAResult<Vec<String>>
fn get_geospatial_whole_island( client: <AClient<ReqwestBlocking>, id: GeospatialLayerId ) -> LTAResult<Vec<String>>
Returns the SHP files of the requested geospatial layer Read more
source§impl TaxiRequests<LTAClient<Agent>> for Taxi
impl TaxiRequests<LTAClient<Agent>> for Taxi
source§impl TaxiRequests<LTAClient<Client>> for Taxi
impl TaxiRequests<LTAClient<Client>> for Taxi
source§impl TrafficRequests<LTAClient<Agent>> for Traffic
impl TrafficRequests<LTAClient<Agent>> for Traffic
source§fn get_bike_parking(
client: <AClient<Agent>,
lat: f64,
long: f64,
dist: impl Into<Option<f64>>
) -> LTAResult<Vec<BikeParking>>
fn get_bike_parking( client: <AClient<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>>
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>>
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>>
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>>
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>>
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 moresource§fn get_traffic_speed_band(
client: &C,
skip: impl Into<Option<u32>>
) -> LTAResult<Vec<TrafficSpeedBand>>
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>>
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>>
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§impl TrafficRequests<LTAClient<Client>> for Traffic
impl TrafficRequests<LTAClient<Client>> for Traffic
source§fn get_bike_parking(
client: <AClient<ReqwestBlocking>,
lat: f64,
long: f64,
dist: impl Into<Option<f64>>
) -> LTAResult<Vec<BikeParking>>
fn get_bike_parking( client: <AClient<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>>
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>>
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>>
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>>
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>>
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 moresource§fn get_traffic_speed_band(
client: &C,
skip: impl Into<Option<u32>>
) -> LTAResult<Vec<TrafficSpeedBand>>
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>>
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>>
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
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more