dot4ch/
lib.rs

1#![deny(clippy::all, clippy::pedantic)]
2#![deny(missing_docs)]
3#![allow(clippy::must_use_candidate)]
4//! # dot4ch
5//!
6//! dot4ch is a convenient wrapper library around an imageboard's read-only API.
7//!
8//! This library can fetch and update:
9//! - [`Thread`]
10//! - [`Catalog`]
11//! - [`Board`]
12//!
13//! While respecting:
14//! - 1 second-per-request rate-limits.
15//! - `If-Modified-Since` headers with update requests.
16//! - 10 seconds per thread update rate limits.
17//!
18//! ## Example: Printing the comment from a thread.
19//!
20//! ```rust
21//! # type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
22//! use dot4ch::thread::Post;
23//! use dot4ch::thread::Thread;
24//! use dot4ch::Client;
25//!
26//! #[tokio::main]
27//! async fn main() -> Result<()> {
28//!     let client = Client::new();
29//!     let mut thread = Thread::new(&client, "po", 570368).await?;
30//!
31//!     // update thread
32//!     thread.update(&client).await?;
33//!
34//!     // print thread's OP comment
35//!     let comment = thread.first().and_then(Post::com).unwrap();
36//!     let comment = comment.replace("<br>", "\n"); // replace line breaks
37//!     println!("op says: {comment}");
38//!     Ok(())
39//! }
40//! ```
41//!
42//! [`Thread`]:  crate::models::thread::Thread
43//! [`Catalog`]: crate::models::catalog::Catalog
44//! [`Board`]:   crate::models::board::Board
45
46/// Client module contains [`Client`] for requesting and updating data.
47pub mod client;
48
49/// Contains [`Error`]s that can be thrown by the libary.
50///
51/// [`Error`]: crate::error::Error
52pub mod error;
53
54pub(crate) mod models;
55
56pub(crate) mod result;
57
58pub use client::Client;
59pub use models::*;