Crate asoiaf_api

Source
Expand description

§asoiaf-api

This is a library for interacting with the An API of Ice and Fire.

§Examples

§Basic calls

use asoiaf_api::Client;

#[tokio::main]
async fn main() {
    let client = Client::new();

    let books = client.get_books().await.unwrap();
    let characters = client.get_characters().await.unwrap();
    let houses = client.get_houses().await.unwrap();
}

§Iterators

 use asoiaf_api::Client;

 #[tokio::main]
 async fn main() {
     // We specify a maximum size of 50 items per page
     let mut iterator = Client::new().get_character_iterator(50);

     // We iterate over all the characters
     while let Ok(result) = iterator.next().await {
         println!("{:?}", result);
     }
 }

§Filters


use asoiaf_api::{Client, CharacterFilter};

#[tokio::main]
async fn main() {
    // We filter by culture
    let character_filter = CharacterFilter::Culture("Northmen".to_string());
    // We specify a maximum size of 50 items per page
    let iterator = Client::new().get_character_filter_iterator(character_filter, 50);
}

§Features

Client is the main struct of this library. It is used to make requests to the API. We can filter the results of the requests by using the Filter structs. We can also iterate over the results of the requests by using the Iterator structs.

Re-exports§

Modules§