splits-io-api

Crates.iosplits-io-api
lib.rssplits-io-api
version0.4.0
sourcesrc
created_at2019-12-10 21:29:26.517498
updated_at2024-01-18 23:56:33.508483
descriptionBindings to the splits.io API for Rust.
homepage
repositoryhttps://github.com/LiveSplit/splits-io-api
max_upload_size
id188315
size80,444
Christopher Serr (CryZe)

documentation

https://docs.rs/splits-io-api/

README

splits.io splits-io-api

Build Status crates.io docs.rs dependency status

Bindings to the splits.io API for Rust. Both native platforms and the web are supported.

Example Usage

// 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());

License

Licensed under either of

Contribution

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.

Commit count: 54

cargo fmt