Struct dmzj::Api

source ·
pub struct Api { /* private fields */ }
Expand description

Dmzj API

Implementations§

source§

impl Api

source

pub fn new() -> Self

source

pub fn from_http_client(http_client: ClientWithMiddleware) -> Self

Construct a Client instance from a provided reqwest_middleware HTTP client

source

pub async fn fetch_latest_updates_manga( &self, page: u16 ) -> DmzjResult<Vec<LatestUpdatesMangaItem>>

source

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);
}
source

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);
}
source

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);
}
source

pub async fn fetch_author_details( &self, author_tag_id: i64 ) -> DmzjResult<AuthorDetailsResponse>

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);
}
source

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§

source§

impl Clone for Api

source§

fn clone(&self) -> Api

Returns a copy 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 Api

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Api

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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