Struct dynasty_api::DynastyApi
source · [−]pub struct DynastyApi { /* private fields */ }Expand description
Dynasty reader’s JSON API client.
Implementations
sourceimpl DynastyApi
impl DynastyApi
sourcepub fn new() -> DynastyApi
pub fn new() -> DynastyApi
Creates a DynastyApi client.
DynastyApi is wrapped inside an Arc internally, so you don’t need to wrap it inside an Arc to reuse it.
See with_base if you want to create a DynastyApi client with a custom base.
Examples
let dynasty = DynastyApi::new();sourcepub fn with_base<U: IntoUrl>(url: U) -> DynastyApi
pub fn with_base<U: IntoUrl>(url: U) -> DynastyApi
Creates a DynastyApi client with a custom base url.
base is assumed to be compatible with https://dynasty-scans.com / route.
Examples
Create a client with custom base url.
let dynasty = DynastyApi::with_base("https://dynasty-proxy.netlify.app/");Panics
Panics if it fails to parse the base url as Url.
let _ = DynastyApi::with_base("invalid-url");Or if you supplied a base url that cannot be used as base.
let _ = DynastyApi::with_base("data:text/plain,Stuff");sourcepub async fn latest_chapters(&self, page: u16) -> Result<LatestListing>
pub async fn latest_chapters(&self, page: u16) -> Result<LatestListing>
List Dynasty reader’s LatestListing https://dynasty-scans.com/chapters/added.
sample: latest::sample
sourcepub async fn list_directory(
&self,
kind: TagKind,
page: u16
) -> Result<DirectoryListing>
pub async fn list_directory(
&self,
kind: TagKind,
page: u16
) -> Result<DirectoryListing>
List Dynasty reader’s DirectoryListing with pagination.
sample: directory::sample
Examples
List anthologies at page 1.
let kind = TagKind::Anthology;
let anthology_1 = dynasty.list_directory(kind, 1).await?;You can use total_pages and current_page from DirectoryListing as limit and pointer respectively, you can use DirectoryListing::next_page method to get the next page easily.
let kind = TagKind::Series;
let series_1 = dynasty.list_directory(kind, 1).await?;
let next = series_1.next_page();
assert_eq!(next, Some(2));Keep in mind that if you exceed the limit you won’t get any error or whatsoever, but you will instead get an empty tags.
let kind = TagKind::Scanlator;
let scanlator_65535 = dynasty.list_directory(kind, 65535).await?;
assert!(scanlator_65535.tags.is_empty());sourcepub async fn list_tag<P: IntoDynastyTagPath>(&self, s: P) -> Result<TagListing>
pub async fn list_tag<P: IntoDynastyTagPath>(&self, s: P) -> Result<TagListing>
List Dynasty reader’s TagListing.
sample: tag::sample
If you use &str, it must follow one of the formats below:
{kind}/{permalink}wherekindmust be parse-able intoTagKindwhilepermalinkcan be anything.{permalink}it’ll be as if you wrotetags/{permalink}.
Examples
// valid
assert!(dynasty.list_tag("authors/manio").await.is_ok());
// also valid
assert!(dynasty.list_tag("tags/bread").await.is_ok());
// same as above
assert!(dynasty.list_tag("bread").await.is_ok());
// you could also use the `title`
assert!(dynasty.list_tag("404: Men Not Found").await.is_ok());
// above will be parsed as "tags/404_men_not_found"sourcepub async fn chapter<P: IntoDynastyChapterPath>(&self, s: P) -> Result<Chapter>
pub async fn chapter<P: IntoDynastyChapterPath>(&self, s: P) -> Result<Chapter>
Get a Dynasty reader’s Chapter.
sample: chapter::sample
If you use &str, it must follow one of the formats below:
chapters/{permalink}where permalink can be anything.{permalink}it’ll be as if you wrotechapters/{permalink}.
Examples
// valid
assert!(dynasty.chapter("chapters/kichiku_yousei").await.is_ok());
// same as above
assert!(dynasty.chapter("kichiku_yousei").await.is_ok());
// you could also use the `title`
assert!(dynasty.chapter("Adachi and Shimamura (Moke ver.) ch27.1").await.is_ok());
// above will be parsed as "chapters/adachi_and_shimamura_moke_ver_ch27_1"
// `long_title` also works
assert!(dynasty.chapter("Adachi and Shimamura (Moke ver.) ch27.1: Leaving Azure").await.is_ok());Trait Implementations
sourceimpl Clone for DynastyApi
impl Clone for DynastyApi
sourcefn clone(&self) -> DynastyApi
fn clone(&self) -> DynastyApi
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for DynastyApi
impl Debug for DynastyApi
Auto Trait Implementations
impl !RefUnwindSafe for DynastyApi
impl Send for DynastyApi
impl Sync for DynastyApi
impl Unpin for DynastyApi
impl !UnwindSafe for DynastyApi
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more