pub struct MangoClient { /* private fields */ }
Expand description
Entry point for most of the crate interactions
Provides functions for interacting with the mangadex servers as well as
the access to the ChapterViewer
struct
Implementations§
Source§impl MangoClient
impl MangoClient
pub const BASE_URL: &str = "https://api.mangadex.org"
Sourcepub async fn query(
&self,
base_url: &str,
query: &impl Query,
) -> Result<Response>
pub async fn query( &self, base_url: &str, query: &impl Query, ) -> Result<Response>
Lowest level function that executes arbitrary Query and returnes its response
Sourcepub async fn parse_respond_data<T>(resp: Value) -> Result<T>
pub async fn parse_respond_data<T>(resp: Value) -> Result<T>
Sourcepub async fn search_manga(&self, data: &MangaQuery) -> Result<Vec<Manga>>
pub async fn search_manga(&self, data: &MangaQuery) -> Result<Vec<Manga>>
Searches for manga with parameteres, specified by data
Sourcepub async fn search_manga_include_cover(
&self,
data: &MangaQuery,
) -> Result<Vec<Manga>>
pub async fn search_manga_include_cover( &self, data: &MangaQuery, ) -> Result<Vec<Manga>>
Essentially the same as search_manga
but the returned response would also contain information
about covers for each entry
Sourcepub async fn search_manga_with_cover(
&self,
data: &MangaQuery,
) -> Result<Vec<(Manga, Bytes)>>
pub async fn search_manga_with_cover( &self, data: &MangaQuery, ) -> Result<Vec<(Manga, Bytes)>>
Executes search_manga_include_cover
and downloads cover
for each entry. Returns each search entry paired with byte respresentation of its cover
Sourcepub async fn search_manga_by_name(&self, name: &str) -> Result<Vec<Manga>>
pub async fn search_manga_by_name(&self, name: &str) -> Result<Vec<Manga>>
Shorthand for searching manga just by name
Sourcepub async fn search_manga_by_name_include_cover(
&self,
name: &str,
) -> Result<Vec<Manga>>
pub async fn search_manga_by_name_include_cover( &self, name: &str, ) -> Result<Vec<Manga>>
The same as search_manga_by_name
combined with
search_manga_include_cover
Sourcepub async fn get_manga_feed(
&self,
id: &str,
data: &MangaFeedQuery,
) -> Result<Vec<Chapter>>
pub async fn get_manga_feed( &self, id: &str, data: &MangaFeedQuery, ) -> Result<Vec<Chapter>>
Queries for the feed of the manga with the given id
and parameteres specified by data
Sourcepub async fn get_chapter_download_meta(
&self,
id: &str,
) -> Result<ChapterDownloadMeta>
pub async fn get_chapter_download_meta( &self, id: &str, ) -> Result<ChapterDownloadMeta>
Queries for the meta info about downloading chapter with the given id
Sourcepub async fn get_scanlation_group(&self, id: &str) -> Result<ScanlationGroup>
pub async fn get_scanlation_group(&self, id: &str) -> Result<ScanlationGroup>
Queries for the info about the scanlation group with the specified id
Queries for available tags
Sourcepub async fn download_full_cover(
&self,
manga_id: &str,
cover_filename: &str,
) -> Result<Bytes>
pub async fn download_full_cover( &self, manga_id: &str, cover_filename: &str, ) -> Result<Bytes>
Given the name of the cover filename (on mangadex server) and the manga id
,
downloads the needed cover art
Sourcepub async fn download_full_page(&self, url: &str) -> Result<Bytes>
pub async fn download_full_page(&self, url: &str) -> Result<Bytes>
Downloads page from the specified url
Sourcepub async fn get_page_chunks(&self, url: &str) -> Result<Response>
pub async fn get_page_chunks(&self, url: &str) -> Result<Response>
Queries for chunked downloading of the page from the specified url
.
The returned Response can then be used to download the page chunk by chunk
Sourcepub async fn download_full_chapter(
&self,
chapter_id: &str,
max_concurrent_downloads: usize,
) -> Result<PathBuf>
pub async fn download_full_chapter( &self, chapter_id: &str, max_concurrent_downloads: usize, ) -> Result<PathBuf>
Downloads the chapter with the specified id
, uses maximum max_concurrent downloads
pages
downloading at each moment of time. Downloaded chapter pages are stored in the directory
“tmp/{chapter_id}”
Source§impl MangoClient
impl MangoClient
Sourcepub async fn chapter_viewer(
&self,
chapter_id: &str,
max_concurrent_downloads: usize,
) -> Result<ChapterViewer>
pub async fn chapter_viewer( &self, chapter_id: &str, max_concurrent_downloads: usize, ) -> Result<ChapterViewer>
Setups new ChapterViewer instance. The gist of how this works is as following.
This function creates two working green threads:
- downloadings_manager
- downloadings_spawner
These threads interact with each other via channels.
Manager is responsible for deciding what to download next and an overall process status.
Spawner is responsible for creating small green thread downloaders for each page.
The maximum number of concurrently downloading pages is specified by max_concurrent_downloads
.
The function returnes an instance of ChapterViewer that can be used to interact with
the manager task by means of the open_page
function.
Working threads shutdown when the ChapterViewer is dropped or when all pages are downloaded
Source§impl MangoClient
impl MangoClient
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates new instance of MangoClient
Trait Implementations§
Source§impl Clone for MangoClient
impl Clone for MangoClient
Source§fn clone(&self) -> MangoClient
fn clone(&self) -> MangoClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more