Crate hentai[−][src]
hentai
The aptly named hentai crate provides an easy mechanism to consume nhentai’s public facing APIs in Rust. As of now, hentai relies solely on these APIs instead of scraping their website. However, this capability may be added in the near future.
hentai will provide information about a doujin given its six-digit code. Alternatively, the JSON response from nhentai’s /api/gallery/{id} endpoint may be provided directly.
hentai is based on the similar package for python.
Examples
more info for these samples is provided in the documentation for Hentai
use hentai::{Hentai, Result, Website}; #[tokio::main] async fn main() -> Result<()> { let response = Hentai::new(165961, Website::NET).await?; println!("{:?}", response); // makes use of the Debug trait on Hentai Ok(()) }
use hentai::{Hentai, Result, Website} #[tokio::main] async fn main() -> Result<()> { let response = Hentai::random(Website::XXX).await?; println!("{:?}", response); Ok(()) }
use hentai::{Hentai, Result, Website}; use std::env; fn main() -> Result<()> { let path = env::current_dir()?; let response = Hentai::from_json(path, Website::XXX)?; println!("{:?}", result); Ok(()) }
Structs
Hentai | The main object containing the formatted information retrieved from nhentai. The raw image data is converted to into image URLs. A brief explanation of each field is located below. |
Tag | Tags are used to categorize doujins. Each doujin published on nhentai has tags indicating its content and additional data like the language and artist. For example, the tag with the category field equal to “artist” contains the name by which the author is recognized on nhentai. |
Title | nhentai provides three different types of titles. The first one is |
Enums
HentaiError | Global error type for Hentai that catches all other types of errors that may occur. This still provides the original error message when printed. |
Website | In cases where the standard output domain nhentai.net may be restricted
on the end user’s network, an option can be provided to use nhentai.xxx
URLs instead. Note that the |
Type Definitions
Result | Shorthand for Result<T, HentaiError> meant to make catching errors slightly more simple. |