Crates.io | ergast-rs |
lib.rs | ergast-rs |
version | 0.3.2 |
source | src |
created_at | 2022-06-26 12:30:38.189685 |
updated_at | 2022-12-15 19:45:01.934255 |
description | An async client for getting Formula 1 schedules, qualifying, and race results powered by the Ergast API |
homepage | |
repository | |
max_upload_size | |
id | 613522 |
size | 89,602 |
This project introduces an Ergast
trait and the main implementation in ErgastClient
which can be used to query the
Ergast API.
To query the API you can either use the RequestBuilder
or directly provide the URL as a string to the client.
If you are providing your own request string, do not forget to append .json
to the query string, otherwise the lib is unable to parse the response.
The client provide some pre-built methods to query
let client = ErgastClient::new()?;
let race_results = client
.race_results(None, None)
.await?;
let client = ErgastClient::new()?;
let races = client
.schedule(Some(2020))
.await?;
RequestBuilder
let request = RequestBuilder::new()
.query(RequestType::QualifyingResult)
.add_parameter(RequestParameter::Season(2019))
.add_parameter(RequestParameter::Round(1))
.build();
let client = ErgastClient::new()?;
let qualifying = client
.query(request)
.await?;