lotr_api/lib.rs
1//! # `lotr-api`
2//!
3//! This crate is a wrapper for the [lotr-api](https://the-one-api.dev/).
4//! It provides a simple interface to make requests to the API.
5//!
6//! # Examples
7//!
8//! ```rust, no_run
9//! use lotr_api::Client;
10//!
11//! #[tokio::main]
12//! async fn main() {
13//! let client = Client::new("your_token".to_string());
14//! let books = client.get_books().await.unwrap();
15//! let characters = client.get_characters().await.unwrap();
16//! }
17//! ```
18//!
19//! ```rust, no_run
20//! use lotr_api::{Client, ItemType, RequestBuilder};
21//! use lotr_api::filter::{Filter, Operator};
22//! use lotr_api::sort::{Sort, SortOrder};
23//! use lotr_api::attribute::{Attribute, BookAttribute};
24//!
25//! #[tokio::main]
26//! async fn main() {
27//! let client = Client::new("your_token".to_string());
28//! let request = RequestBuilder::new(ItemType::Book)
29//! .filter(Filter::Match(
30//! Attribute::Book(BookAttribute::Name),
31//! Operator::Eq,
32//! vec!["The Fellowship of the Ring".to_string()])
33//! )
34//! .sort(Sort::new(SortOrder::Ascending, Attribute::Book(BookAttribute::Name)))
35//! .build()
36//! .expect("Failed to build request");
37//! let books = client.get(request).await.unwrap();
38//! // ...
39//! }
40//! ```
41//!
42//! # Features
43//!
44//! - [`Client`] functions to get all items of a type .
45//! - [`RequestBuilder`] to build a request with filters, pagination and sorting, which allows the user full control over the request without having to deal with the url.
46//!
47//!
48
49pub mod client;
50pub mod error;
51pub mod item;
52pub mod request;
53
54pub use client::Client;
55pub use error::Error;
56pub use item::attribute;
57pub use item::object::*;
58pub use item::Item;
59pub use item::ItemType;
60pub use request::filter;
61pub use request::pagination::Pagination;
62pub use request::sort;
63pub use request::Request;
64pub use request::RequestBuilder;