A library for consuming the Hyrule Compendium API in Rust
This library exposes a client that can be used to request information from the API
Currently you'll need to clone this repository and build it yourself
In future it's hoped that you'll be able to install as a crate below in your Cargo.toml
toml
[dependencies]
rusty_hyrule_compendium = "0.1.0"
To use this library, you'll need to instantiate the Compendium client. CompendiumClient::default();
preconfigures the underlying HTTP client and API url with sensible values.
```rust use rustyhyrulecompendium::blocking::CompendiumClient; use rustyhyrulecompendium::domain::inputs::EntryIdentifier;
// Preconfigured client using v2 of the API let client = CompendiumClient::default(); // Requests can fail for a number of reasons, see the error module for available errors let monsterentry = client.monster(EntryIdentifier::Id(123))?; // "white-maned lynel" let monstername = monster.name(); // "https://botw-compendium.herokuapp.com/api/v2/entry/white-maned_lynel/image" let image = monster.image(); ```
Each of the resources (see below for comprehensive list) have a struct representation with helper methods to the underlying data (e.g. .name()
, .image()
etc)
Here contains the raw JSON response for the example
Furthermore it's possbile to request all of the above by category but pattern matching is required to get the entries.
rust
let result = client.category(CompendiumCategory::Treasure)?;
match result {
CategoryResult::Treasure(treasure) => {
// Do something with the Vec<TreasureEntry>
}
_ => panic!("Unexpected result while search for treasure category"),
}
It's also possible to get all entries by the .all_entries()
method
E.g.
rust
let all_entries = client.all_entries()?;
// Get all creature entries that are food specific, &Vec<CreatureEntry> type
let food_creatures = all_entries.creatures().food();
.monster()
.creature()