Expand description
dot4ch
dot4ch is a convenient wrapper library around 4chan’s API.
This library can fetch and update:
- Posts
- Threads
- Catalog
- Boards
While respecting 4chan’s:
- GET 1 second-per-request cooldown.
If-Modified-Since
headers with update requests.- 10 second cooldown with
thread::Thread
,catalog::Catalog
andboard::Board
update requests.
Example: Getting an image from the OP of a thread
#[tokio::main]
async fn main() {
use dot4ch::{Client, thread::Thread};
// Making a client.
let mut client = Client::new();
// Building a board.
let board = "g";
// Getting a specific `Thread` from the board.
let post_id = 76759434;
// Fetching a new thread.
let thread = Thread::new(&client, board, post_id).await.unwrap();
// Getting the OP of the thread.
let post = thread.op();
println!("{}", post.image_url(board).unwrap());
}
Modules
A cache of the entire board.
Holds an information of a single post
Contains information about a 4chan thread.
Structs
A summarized list of all threads on a board including thread numbers, their modification time and reply count.
The main client for accessing API.
Handles updates, board and reqwest::Client
Traits
Helper trait that sends a GET request from the reqwest client with a If-Modified-Since header.
Another helper trait for the Update
trait.
Update trait specifies if something can be updated or not.