# Ergast-rs: your one stop shop for Formula 1 (F1) results and schedules
This project introduces an `Ergast` trait and the main implementation in `ErgastClient` which can be used to query the
[Ergast API](https://ergast.com/mrd/).
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
* race schedule
* qualifying results
* sprint qualifying results
* race results
## Example usage
### Get the last race's results
```rust
let client = ErgastClient::new()?;
let race_results = client
.race_results(None, None)
.await?;
```
### Get the race schedule for 2020
```rust
let client = ErgastClient::new()?;
let races = client
.schedule(Some(2020))
.await?;
```
### Get the qualifying results of the season opener in 2019 via the `RequestBuilder`
```rust
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?;
```