asoiaf_api/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
//! # asoiaf-api
//!
//! This is a library for interacting with the [An API of Ice and Fire](https://anapioficeandfire.com/).
//! # Examples
//!
//! ## Basic calls
//!
//! ```rust
//! 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
//!
//!```rust
//! 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
//!
//! ```rust
//!
//! 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`](client::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`](requester::filter) structs.
//! We can also iterate over the results of the requests by using the [`Iterator`](item::iterator) structs.
pub mod client;
pub mod error;
pub mod item;
pub mod requester;
pub use item::{Book, Character, House, Items};
pub use requester::filter::{BookFilter, CharacterFilter, HouseFilter};
pub use requester::pagination::Pagination;
pub use item::iterator::{BookIterator, CharacterIterator, HouseIterator};
pub use client::Client;
pub use error::Error;