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.
Code samples
more info provided in the documentation for Hentai
Hentai::new()
use hentai::Hentai; use std::{error, result}; type Result<T> = result::Result<T, Box<dyn error::Error>>; #[tokio::main] async fn main() -> Result<()> { if let Ok(result) = Hentai::new(165961) { println!("{:?}", result); } Ok(()) }
Hentai::from_json()
use hentai::{Hentai, Result}; use std::env; fn main() -> Result<()> { let mut path = env::current_exe()?; /// path is std::path::PathBuf path.pop(); path.push("sample.json"); if let Ok(result) = Hentai::from_json(path) { println!("{:?}", result); // makes use of the Debug trait on Hentai } 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. |
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. |
Type Definitions
Result | Shorthand for Result<T, HentaiError> meant to make catching errors slightly more simple. |