Struct MangoClient

Source
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

Source

pub const BASE_URL: &str = "https://api.mangadex.org"

Source

pub async fn query( &self, base_url: &str, query: &impl Query, ) -> Result<Response>

Lowest level function that executes arbitrary Query and returnes its response

Source

pub async fn parse_respond_data<T>(resp: Value) -> Result<T>
where for<'a> T: Entity + Deserialize<'a> + Serialize,

Deserializes responses that can be deserialized into Entity or a Vec of entities

Source

pub async fn search_manga(&self, data: &MangaQuery) -> Result<Vec<Manga>>

Searches for manga with parameteres, specified by data

Source

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

Source

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

Source

pub async fn search_manga_by_name(&self, name: &str) -> Result<Vec<Manga>>

Shorthand for searching manga just by name

Source

pub async fn search_manga_by_name_include_cover( &self, name: &str, ) -> Result<Vec<Manga>>

Source

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

Source

pub async fn get_chapter_download_meta( &self, id: &str, ) -> Result<ChapterDownloadMeta>

Queries for the meta info about downloading chapter with the given id

Source

pub async fn get_scanlation_group(&self, id: &str) -> Result<ScanlationGroup>

Queries for the info about the scanlation group with the specified id

Source

pub async fn get_tags(&self) -> Result<Vec<Tag>>

Queries for available tags

Source

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

Source

pub async fn download_full_page(&self, url: &str) -> Result<Bytes>

Downloads page from the specified url

Source

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

Source

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

Source

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

Source

pub fn new() -> Result<Self>

Creates new instance of MangoClient

Trait Implementations§

Source§

impl Clone for MangoClient

Source§

fn clone(&self) -> MangoClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MangoClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,