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§
pub use item::Book;
pub use item::Character;
pub use item::House;
pub use item::Items;
pub use requester::filter::BookFilter;
pub use requester::filter::CharacterFilter;
pub use requester::filter::HouseFilter;
pub use requester::pagination::Pagination;
pub use item::iterator::BookIterator;
pub use item::iterator::CharacterIterator;
pub use item::iterator::HouseIterator;
pub use client::Client;
pub use error::Error;