aghpb

Crates.ioaghpb
lib.rsaghpb
version1.4.1
sourcesrc
created_at2023-08-01 21:24:47.354166
updated_at2023-11-19 04:01:49.515284
descriptionAnime girls holding programming books API wrapper for πŸ¦€Rust.
homepage
repositoryhttps://github.com/THEGOLDENPRO/aghpb.rs
max_upload_size
id932224
size542,301
Goldy (THEGOLDENPRO)

documentation

https://docs.rs/aghpb

README

πŸ¦€ aghpb.rs πŸ“š

Rust API wrapper for the anime girls holding programming books API

Crates.io docs.rs


[!Note]

This is part of my aghpb api wrapper challenge where I attempt to write an api wrapper in every language possible. So yes expect spaghetti code as it will be my first time writing in these languages. Although I'm 100% open to improvements and corrections so feel free to contribute anything. Other languages I've done

Install

cargo add aghpb

More install instructions at crates.io.

Examples

This is how you may retrieve a random anime girls holding programming books:

use tokio::fs;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let book = aghpb::random(None).await?;

    println!("Name: {}", book.name);
    println!("Category: {}", book.category);
    println!("Date added: {}", book.date_added);

    fs::write("./anime_girl.png", book.raw_bytes).await?;

    Ok(())
}

You can also retrieve specific categories of anime girls holding programming books like so:

let book = aghpb::random(Some("rust".into())).await?;

This is how you may retrieve a list of available categories:

use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let categories = aghpb::categories().await?;

    for category in categories {
        println!("{}", category);
    }

    Ok(())
}

How to search for an anime girl holding a programming book.

[!NOTE] NEW in v1.4!

use std::error::Error;

use tokio::fs;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let books = aghpb::search("tohru".into(), None, None).await?;

    let book_data = &books[0]; // I'm selecting the first book just for this example.

    println!("Name: {}", book_data.name);
    println!("Category: {}", book_data.category);
    println!("Commit Author: {}", book_data.commit_author);
    println!("Commit URL: {}", book_data.commit_url);
    println!("Date Added: {}", book_data.date_added);
    println!("Search ID: {}", book_data.search_id);

    let book = book_data.get_book().await?;

    fs::write("./anime_girl.png", book.raw_bytes).await?;

    Ok(())
}

Made using my API at πŸ‘‰ https://api.devgoldy.xyz/aghpb/v1/

Commit count: 37

cargo fmt