Crate tankerkoenig
source ·Expand description
§tankerkoenig-rs
The Tankerkoenig crate provides an easy to use wrapper over the tankerkoenig api.
- Easy to use
- Async api calls with reqwest
- Ready deserialized structs of the tankerkoenig responses
- Manages authentication for you, just pass your api token once
§Requirements
- Your own tankerkoenig api key
- Async runtime configured e.g. tokio
§Getting started
Install the latest version of this crate by adding the following line to your Cargo.toml
[dependencies]
tankerkoenig = { git = "https://github.com/jontze/tankerkoenig-rs" }
Import the crate and create a new instance of the Tankerkoenig struct.
use tankerkoenig::Tankerkoenig;
use tankerkoenig::models;
async fn run() -> Result<models::station::DetailsResponse, tankerkoenig::Error> {
let tanker = Tankerkoenig::new("your-api-key")?;
let details = tanker.station.fetch_details("id-of-the-fuel-station").await?;
Ok(details)
}
§Examples
§Optional Features
§Troubleshooting
If you get a ResponseParsingError during usage of the crate this is very likely
due to an invalid input where the tankerkoenig api will throw an error or
due to some unexpected values that were returned by the api. E.g. sometimes the api
will return false
instead of a number for certain fields or other fields were missing.
In this case please check if your input is valid and if so create a bug report on the crate repository and provide some information about your input.
Re-exports§
pub use api::Tankerkoenig;
Modules§
- Module that contains the main Tankerkoenig struct that gives access to the two child structs PriceApi and StationApi.
Macros§
- Macro to transform a vector into a vector of arrays with a fixed size of 10. The last array will be filled with None if the vector is not divisible by 10.
Enums§
- Contains all possible errors of the crate