Struct tankerkoenig::api::station::StationApi
source · pub struct StationApi { /* private fields */ }
Expand description
Struct that holds the current reqwest client of the library and gives access to the station api of the tankerkoenig API.
Implementations§
source§impl StationApi
impl StationApi
sourcepub async fn fetch_near(
&self,
lat: f64,
lng: f64,
radius: f64,
) -> Result<AreaNearResponse, TankerkoenigError>
pub async fn fetch_near( &self, lat: f64, lng: f64, radius: f64, ) -> Result<AreaNearResponse, TankerkoenigError>
Fetch all stations near a given area with some basic informations
§Example
use tankerkoenig::Tankerkoenig;
use tankerkoenig::models;
async fn request_near_stations() -> Result<models::AreaNearResponse, tankerkoenig::Error> {
let tanker = Tankerkoenig::new("your-api-key")?;
let latitude: f64 = 52.52;
let longitude: f64 = 13.40;
let radius: f64 = 10.0;
let near_stations_res = tanker.station.fetch_near(latitude, longitude, radius).await?;
Ok(near_stations_res)
}
sourcepub async fn fetch_by_fuel(
&self,
lat: f64,
lng: f64,
radius: f64,
fuel: Fuel,
sort: Sort,
) -> Result<AreaFuelResponse, TankerkoenigError>
pub async fn fetch_by_fuel( &self, lat: f64, lng: f64, radius: f64, fuel: Fuel, sort: Sort, ) -> Result<AreaFuelResponse, TankerkoenigError>
Fetch all stations in a radius around the given coordinates that sell a specific kind of Fuel and sort them in a certain order.
§Example
use tankerkoenig::Tankerkoenig;
use tankerkoenig::models;
async fn request_fuel_near() -> Result<models::AreaFuelResponse, tankerkoenig::Error> {
let tanker = Tankerkoenig::new("your-api-key")?;
let latitude: f64 = 52.52;
let longitude: f64 = 13.40;
let radius: f64 = 10.0;
let fuel = models::Fuel::Diesel;
let sorting = models::Sort::Distance;
let stations = tanker.station.fetch_by_fuel(latitude, longitude, radius, fuel, sorting).await?;
Ok(stations)
}
sourcepub async fn fetch_details<S: AsRef<str>>(
&self,
id: S,
) -> Result<DetailsResponse, TankerkoenigError>
pub async fn fetch_details<S: AsRef<str>>( &self, id: S, ) -> Result<DetailsResponse, TankerkoenigError>
Fetch informations about a certain station by id.
§Example
use tankerkoenig::Tankerkoenig;
use tankerkoenig::models;
async fn request_station() -> Result<models::DetailsResponse, tankerkoenig::Error> {
let tanker = Tankerkoenig::new("your-api-key")?;
let station_details = tanker.station.fetch_details("<station_id>").await?;
Ok(station_details)
}
Trait Implementations§
source§impl Clone for StationApi
impl Clone for StationApi
source§fn clone(&self) -> StationApi
fn clone(&self) -> StationApi
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for StationApi
impl !RefUnwindSafe for StationApi
impl !Send for StationApi
impl !Sync for StationApi
impl Unpin for StationApi
impl !UnwindSafe for StationApi
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)