gelbooru_api/
lib.rs

1#[cfg(test)]
2mod test;
3
4pub mod api;
5mod auth;
6mod client;
7mod error;
8pub use api::{Rating, Ordering, TagType};
9//pub use api::{comments};
10pub use auth::AuthDetails;
11pub use client::Client;
12pub use error::Error;
13
14/// Gateway to interacting with the Posts API
15///
16/// ## Example
17/// ```rust
18/// # use gelbooru_api::{Client, Error, Rating, posts};
19/// # async fn example() -> Result<(), Error> {
20/// let client = Client::public();
21///
22/// posts()
23///     .limit(50)                       // 50 posts
24///     .rating(Rating::Safe)            // that have the safe rating
25///     .tags(&["hatsune_miku", "solo"]) // and the `hatsune_miku` and `solo` tags
26///     .send(&client)                   // send request
27///     .await?;
28///
29/// # Ok(())
30/// # }
31/// ```
32pub fn posts<'a>() -> api::PostsRequestBuilder<'a> {
33    api::PostsRequestBuilder {
34        limit: None, // server-side default is 100
35        tags: Vec::new(),
36        tags_raw: String::new(),
37        rating: None,
38        sort_random: false,
39    }
40}
41
42/// Gateway to interacting with the Tags API
43///
44/// ## Example
45/// ```rust
46/// # use gelbooru_api::{Client, Error, Ordering, tags};
47/// # async fn example() -> Result<(), Error> {
48/// let client = Client::public();
49///
50/// tags()
51///     .limit(5)
52///     .pattern(&client, "_ol_")
53///     .await?;
54/// # Ok(())
55/// # }
56/// ```
57pub fn tags() -> api::TagsRequestBuilder {
58    api::TagsRequestBuilder::new()
59}