13 unstable releases (3 breaking)
0.6.0 | Aug 31, 2024 |
---|---|
0.5.0 | Mar 7, 2024 |
0.4.1 | Dec 30, 2023 |
0.3.8 | Oct 3, 2023 |
0.3.4 | Sep 30, 2023 |
#1460 in Web programming
37KB
886 lines
booru
An async Booru client for Rust.
Note: This project has been forked from booru-rs since September of 2023, but a lot has changed.
Overview
The client currently supports:
- Gelbooru
- Safebooru
- Danbooru
- Rule 34
Example
Remember to bring the Client
trait into scope with use booru::client::Client;
.
use booru::{
client::{gelbooru::GelbooruClient, generic::*, Client},
model::gelbooru::GelbooruRating,
};
#[tokio::main]
async fn main() {
let posts = GelbooruClient::builder()
.tag("kafuu_chino")
.tag("2girls")
.rating(GelbooruRating::General)
.sort(Sort::Score)
.limit(5)
.random()
.blacklist_tag(GelbooruRating::Explicit)
.build()
.get()
.await
.expect("There was an error retrieving posts from the API");
}
Customizing http client
If you want to customize http client, you can use builder_with_http_client
:
use booru::{
client::{gelbooru::GelbooruClient, generic::*, Client},
model::gelbooru::GelbooruRating,
};
use reqwest;
use std::time::Duration;
#[tokio::main]
async fn main() {
let http_client_builder = reqwest::ClientBuilder::new()
.timeout(Duration::from_secs(10));
let posts = GelbooruClient::builder_with_http_client(http_client_builder)
.tag("kafuu_chino")
.limit(5)
.build()
.get()
.await
.expect("There was an error retrieving posts from the API");
}
Dependencies
~5–16MB
~201K SLoC