asoiaf_api/
lib.rs

1//! # asoiaf-api
2//!
3//! This is a library for interacting with the [An API of Ice and Fire](https://anapioficeandfire.com/).
4//! # Examples
5//!
6//! ## Basic calls
7//!
8//! ```rust
9//! use asoiaf_api::Client;
10//!
11//! #[tokio::main]
12//! async fn main() {
13//!     let client = Client::new();
14//!
15//!     let books = client.get_books().await.unwrap();
16//!     let characters = client.get_characters().await.unwrap();
17//!     let houses = client.get_houses().await.unwrap();
18//! }
19//! ```
20//!
21//! ## Iterators
22//!
23//!```rust
24//! use asoiaf_api::Client;
25//!
26//! #[tokio::main]
27//! async fn main() {
28//!     // We specify a maximum size of 50 items per page
29//!     let mut iterator = Client::new().get_character_iterator(50);
30//!
31//!     // We iterate over all the characters
32//!     while let Ok(result) = iterator.next().await {
33//!         println!("{:?}", result);
34//!     }
35//! }
36//! ```
37//!
38//! ## Filters
39//!
40//! ```rust
41//!
42//! use asoiaf_api::{Client, CharacterFilter};
43//!
44//! #[tokio::main]
45//! async fn main() {
46//!     // We filter by culture
47//!     let character_filter = CharacterFilter::Culture("Northmen".to_string());
48//!     // We specify a maximum size of 50 items per page
49//!     let iterator = Client::new().get_character_filter_iterator(character_filter, 50);
50//! }
51//! ```
52//!
53//! # Features
54//!
55//! [`Client`](client::Client) is the main struct of this library. It is used to make requests to the API.
56//! We can filter the results of the requests by using the [`Filter`](requester::filter) structs.
57//! We can also iterate over the results of the requests by using the [`Iterator`](item::iterator) structs.
58
59pub mod client;
60pub mod error;
61pub mod item;
62pub mod requester;
63
64pub use item::{Book, Character, House, Items};
65pub use requester::filter::{BookFilter, CharacterFilter, HouseFilter};
66pub use requester::pagination::Pagination;
67
68pub use item::iterator::{BookIterator, CharacterIterator, HouseIterator};
69
70pub use client::Client;
71pub use error::Error;