mod account;
mod at_home;
mod auth;
mod author;
mod captcha;
mod chapter;
mod cover;
pub(crate) mod custom_list;
mod feed;
mod infrastructure;
mod legacy;
mod manga;
mod rating;
pub(crate) mod report;
mod scanlation_group;
mod search;
mod settings;
mod statistics;
mod upload;
pub(crate) mod user;
#[cfg(not(feature = "multi-thread"))]
use std::cell::RefCell;
#[cfg(not(feature = "multi-thread"))]
use std::rc::Rc;
#[cfg(feature = "multi-thread")]
use std::sync::Arc;
#[cfg(feature = "multi-thread")]
use futures::lock::Mutex;
pub use mangadex_api_schema::v5 as schema;
pub(crate) use mangadex_api_schema::v5::AuthTokens;
use reqwest::Client;
use crate::v5::account::AccountBuilder;
use crate::v5::at_home::AtHomeBuilder;
use crate::v5::auth::AuthBuilder;
use crate::v5::author::AuthorBuilder;
use crate::v5::captcha::CaptchaBuilder;
use crate::v5::chapter::ChapterBuilder;
use crate::v5::cover::CoverBuilder;
use crate::v5::custom_list::CustomListBuilder;
use crate::v5::feed::FeedBuilder;
use crate::v5::infrastructure::InfrastructureBuilder;
use crate::v5::legacy::LegacyBuilder;
use crate::v5::manga::MangaBuilder;
use crate::v5::rating::RatingBuilder;
use crate::v5::report::ReportBuilder;
use crate::v5::scanlation_group::ScanlationGroupBuilder;
use crate::v5::search::SearchBuilder;
use crate::v5::settings::SettingsBuilder;
use crate::v5::statistics::StatisticsBuilder;
use crate::v5::upload::UploadBuilder;
use crate::v5::user::UserBuilder;
use crate::HttpClient;
use crate::HttpClientRef;
#[derive(Clone, Debug)]
pub struct MangaDexClient {
pub(crate) http_client: HttpClientRef,
}
impl Default for MangaDexClient {
fn default() -> Self {
Self {
http_client: create_ref_counted_http_client(HttpClient::default()),
}
}
}
impl MangaDexClient {
pub fn new(client: Client) -> Self {
Self {
http_client: create_ref_counted_http_client(HttpClient::new(client)),
}
}
pub fn new_with_http_client(http_client: HttpClient) -> Self {
Self {
http_client: create_ref_counted_http_client(http_client),
}
}
pub fn get_http_client(&self) -> HttpClientRef {
self.http_client.clone()
}
pub fn account(&self) -> AccountBuilder {
AccountBuilder::new(self.http_client.clone())
}
pub fn at_home(&self) -> AtHomeBuilder {
AtHomeBuilder::new(self.http_client.clone())
}
pub fn auth(&self) -> AuthBuilder {
AuthBuilder::new(self.http_client.clone())
}
pub fn author(&self) -> AuthorBuilder {
AuthorBuilder::new(self.http_client.clone())
}
pub fn captcha(&self) -> CaptchaBuilder {
CaptchaBuilder::new(self.http_client.clone())
}
pub fn chapter(&self) -> ChapterBuilder {
ChapterBuilder::new(self.http_client.clone())
}
pub fn cover(&self) -> CoverBuilder {
CoverBuilder::new(self.http_client.clone())
}
pub fn custom_list(&self) -> CustomListBuilder {
CustomListBuilder::new(self.http_client.clone())
}
pub fn feed(&self) -> FeedBuilder {
FeedBuilder::new(self.http_client.clone())
}
pub fn infrastructure(&self) -> InfrastructureBuilder {
InfrastructureBuilder::new(self.http_client.clone())
}
pub fn legacy(&self) -> LegacyBuilder {
LegacyBuilder::new(self.http_client.clone())
}
pub fn manga(&self) -> MangaBuilder {
MangaBuilder::new(self.http_client.clone())
}
pub fn rating(&self) -> RatingBuilder {
RatingBuilder::new(self.http_client.clone())
}
pub fn report(&self) -> ReportBuilder {
ReportBuilder::new(self.http_client.clone())
}
pub fn scanlation_group(&self) -> ScanlationGroupBuilder {
ScanlationGroupBuilder::new(self.http_client.clone())
}
pub fn search(&self) -> SearchBuilder {
SearchBuilder::new(self.http_client.clone())
}
#[allow(unused)]
fn settings(&self) -> SettingsBuilder {
SettingsBuilder::new(self.http_client.clone())
}
pub fn statistics(&self) -> StatisticsBuilder {
StatisticsBuilder::new(self.http_client.clone())
}
pub fn upload(&self) -> UploadBuilder {
UploadBuilder::new(self.http_client.clone())
}
pub fn user(&self) -> UserBuilder {
UserBuilder::new(self.http_client.clone())
}
}
fn create_ref_counted_http_client(http_client: HttpClient) -> HttpClientRef {
#[cfg(not(feature = "multi-thread"))]
{
Rc::new(RefCell::new(http_client))
}
#[cfg(feature = "multi-thread")]
{
Arc::new(Mutex::new(http_client))
}
}