Crate dot4ch

Crate dot4ch 

Source
Expand description

§dot4ch

dot4ch is a convenient wrapper library around an imageboard’s read-only API.

This library can fetch and update:

While respecting:

  • 1 second-per-request rate-limits.
  • If-Modified-Since headers with update requests.
  • 10 seconds per thread update rate limits.

§Example: Printing the comment from a thread.

use dot4ch::thread::Post;
use dot4ch::thread::Thread;
use dot4ch::Client;

#[tokio::main]
async fn main() -> Result<()> {
    let client = Client::new();
    let mut thread = Thread::new(&client, "po", 570368).await?;

    // update thread
    thread.update(&client).await?;

    // print thread's OP comment
    let comment = thread.first().and_then(Post::com).unwrap();
    let comment = comment.replace("<br>", "\n"); // replace line breaks
    println!("op says: {comment}");
    Ok(())
}

Re-exports§

pub use client::Client;

Modules§

archive
Contains bindings to imageboard’s native Archive.
board
Contains bidnings to list of Boards and their attributes.
catalog
Contains bindings for imageboard’s native Catalog
client
Client module contains Client for requesting and updating data.
error
Contains Errors that can be thrown by the libary.
thread
Contains bindings for specific Threads
threadlist
Contains bindings for threads + their attributes in a ThreadList