Crates.io | splits-io-api |
lib.rs | splits-io-api |
version | 0.4.0 |
source | src |
created_at | 2019-12-10 21:29:26.517498 |
updated_at | 2024-01-18 23:56:33.508483 |
description | Bindings to the splits.io API for Rust. |
homepage | |
repository | https://github.com/LiveSplit/splits-io-api |
max_upload_size | |
id | 188315 |
size | 80,444 |
Bindings to the splits.io API for Rust. Both native platforms and the web are supported.
// Create a splits.io API client.
let client = Client::new();
// Search for a runner.
let runner = Runner::search(&client, "cryze")
.await?
.into_iter()
.next()
.context("There is no runner with that name")?;
assert_eq!(&*runner.name, "cryze92");
// Get the PBs for the runner.
let first_pb = runner.pbs(&client)
.await?
.into_iter()
.next()
.context("This runner doesn't have any PBs")?;
// Get the game for the PB.
let game = first_pb.game.context("There is no game for the PB")?;
assert_eq!(&*game.name, "The Legend of Zelda: The Wind Waker");
// Get the categories for the game.
let categories = game.categories(&client).await?;
// Get the runs for the Any% category.
let runs = categories
.iter()
.find(|category| &*category.name == "Any%")
.context("Couldn't find category")?
.runs(&client)
.await?;
assert!(!runs.is_empty());
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.