Skip to content

LiveSplit/splits-io-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.