pub struct Api { /* private fields */ }
Expand description
Dmzj API
Implementations§
source§impl Api
impl Api
pub fn new() -> Self
sourcepub fn from_http_client(http_client: ClientWithMiddleware) -> Self
pub fn from_http_client(http_client: ClientWithMiddleware) -> Self
Construct a Client instance from a provided reqwest_middleware
HTTP client
pub async fn fetch_popular_manga( &self, page: u16 ) -> DmzjResult<Vec<PopularMangaItem>>
pub async fn fetch_latest_updates_manga( &self, page: u16 ) -> DmzjResult<Vec<LatestUpdatesMangaItem>>
sourcepub async fn fetch_manga_details(
&self,
id: u32
) -> DmzjResult<ComicDetailResponse>
pub async fn fetch_manga_details( &self, id: u32 ) -> DmzjResult<ComicDetailResponse>
use dmzj::Api;
#[tokio::main]
async fn main() {
let api = Api::new();
let popular_manga = api.fetch_latest_updates_manga(0).await.unwrap();
let first = &popular_manga[0];
let first_id = first.id;
println!("manga id = {:?}", first_id);
let response = api.fetch_manga_details(first_id).await.unwrap();
let description = &response.data.description;
let title = &response.data.title;
let cover = &response.data.cover;
let authors = &response.data.authors;
println!("title = {}", title);
println!("description = {}", description);
println!("cover = {}", cover);
println!("authors = {:?}", authors);
}
sourcepub async fn fetch_chapter_images(
&self,
manga_id: u32,
chapter_id: i32
) -> DmzjResult<ComicChapterResponse>
pub async fn fetch_chapter_images( &self, manga_id: u32, chapter_id: i32 ) -> DmzjResult<ComicChapterResponse>
use dmzj::Api;
#[tokio::main]
async fn main() {
let api = Api::new();
let chapter_images = api.fetch_chapter_images(71857, 146271).await.unwrap();
println!("{:?}", chapter_images.data);
}
sourcepub async fn fetch_category(&self) -> DmzjResult<CategoryResponse>
pub async fn fetch_category(&self) -> DmzjResult<CategoryResponse>
use dmzj::Api;
#[tokio::main]
async fn main() {
let api = Api::new();
let category = api.fetch_category().await.unwrap();
println!("{:?}", category);
}
use dmzj::Api;
use tracing::Level;
use tracing_subscriber::FmtSubscriber;
#[tokio::main]
async fn main() {
let subscriber = FmtSubscriber::builder()
// all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
// will be written to stdout.
.with_max_level(Level::DEBUG)
// completes the builder.
.finish();
tracing::subscriber::set_global_default(subscriber)
.expect("setting default subscriber failed");
let api = Api::new();
let manga_details = api.fetch_manga_details(14841).await.unwrap();
let first_author = &manga_details.data.authors[0];
let first_author_tag_id = first_author.tagId;
let author_details =
api.fetch_author_details(first_author_tag_id).await.unwrap();
println!("{:?}", author_details);
}
sourcepub async fn search_manga<T: AsRef<str> + Debug>(
&self,
keyword: T,
page: u16
) -> DmzjResult<MangaSearchResponse>
pub async fn search_manga<T: AsRef<str> + Debug>( &self, keyword: T, page: u16 ) -> DmzjResult<MangaSearchResponse>
use dmzj::Api;
#[tokio::main]
async fn main() {
let api = Api::new();
let results = api.search_manga("天国", 0).await.unwrap();
println!("{:?}", results);
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Api
impl !RefUnwindSafe for Api
impl Send for Api
impl Sync for Api
impl Unpin for Api
impl !UnwindSafe for Api
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more