Rusty Hyrule Compendium

A library for consuming the Hyrule Compendium API in Rust

MIT licensed

Overview

This library exposes a client that can be used to request information from the API

Examples

Start by adding the following snippet to your Cargo.toml

toml [dependencies] rusty_hyrule_compendium = "0.1.3"

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.

Singular entry by identifer

```rust use rustyhyrulecompendium::blocking::{CompendiumApiClient, CompendiumClient}; use rustyhyrulecompendium::domain::inputs::EntryIdentifier; use rustyhyrulecompendium::Result;

fn main() -> Result<()> { // 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 = monsterentry.name(); // "https://botw-compendium.herokuapp.com/api/v2/entry/white-manedlynel/image" let monsterimage = monsterentry.image(); Ok(()) } ```

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

All entries for a given category

Furthermore it's possbile to request all of the above by category but pattern matching is required to get the entries.

```rust use rustyhyrulecompendium::blocking::{CompendiumApiClient, CompendiumClient}; use rustyhyrulecompendium::domain::inputs::CompendiumCategory; use rustyhyrulecompendium::domain::responses::CategoryResult; use rustyhyrulecompendium::Result;

fn main() -> Result<()> { // Preconfigured client using v2 of the API let client = CompendiumClient::default(); let result = client.category(CompendiumCategory::Treasure)?; match result { CategoryResult::Treasure(treasure) => { // Do something with the Vec } _ => { /* Return some form of error, unexpected scenario */} } Ok(()) } ```

All entries in compendium

It's also possible to get all entries by the .all_entries() method

E.g.

```rust use rustyhyrulecompendium::blocking::{CompendiumApiClient, CompendiumClient}; use rustyhyrulecompendium::Result;

fn main() -> Result<()> { // Preconfigured client using v2 of the API let client = CompendiumClient::default(); let allentries = client.allentries()?; // Get all creature entries that are food specific, &Vec type let foodcreatures = allentries.creatures().food(); Ok(()) } ```

Available resources from the API