mangadex_api::http_client

Struct HttpClient

Source
pub struct HttpClient {
    pub client: Client,
    pub base_url: Url,
    auth_tokens: Option<AuthTokens>,
    captcha: Option<String>,
    client_info: Option<ClientInfo>,
}
Available on crate feature oauth only.

Fields§

§client: Client§base_url: Url§auth_tokens: Option<AuthTokens>§captcha: Option<String>§client_info: Option<ClientInfo>

Implementations§

Source§

impl HttpClient

Source

pub fn new(client: Client) -> Self

Create a new HttpClient with a custom reqwest::Client.

Source

pub fn builder() -> HttpClientBuilder

Get a builder struct to customize the HttpClient fields.

§Examples
use url::Url;

use mangadex_api::{MangaDexClient, HttpClient};

let http_client = HttpClient::builder()
    .base_url(Url::parse("127.0.0.1:8000")?)
    .build()?;

let mangadex_client = MangaDexClient::new_with_http_client(http_client);
Source

pub(crate) async fn send_request_without_deserializing_with_other_base_url<E>( &self, endpoint: &E, base_url: &Url, ) -> Result<Response>
where E: Endpoint,

Send the request to the endpoint but don’t deserialize the response.

This is useful to handle things such as response header data for more control over areas such as rate limiting.

Source

pub(crate) async fn send_request_without_deserializing<E>( &self, endpoint: &E, ) -> Result<Response>
where E: Endpoint,

Send the request to the endpoint but don’t deserialize the response.

This is useful to handle things such as response header data for more control over areas such as rate limiting.

Source

pub(crate) async fn send_request_with_checks<E>( &self, endpoint: &E, ) -> Result<Response>
where E: Endpoint,

Source

pub(crate) async fn handle_result<T>(&self, res: Response) -> Result<T>

Source

pub(crate) async fn send_request<E>(&self, endpoint: &E) -> Result<E::Response>

Send the request to the endpoint and deserialize the response body.

Source

pub(crate) async fn send_request_with_rate_limit<E>( &self, endpoint: &E, ) -> Result<Limited<E::Response>>

Available on non-crate feature serialize only.

Send the request to the endpoint and deserialize the response body.

Source

pub fn get_tokens(&self) -> Option<&AuthTokens>

Get the authentication tokens stored in the client.

Source

pub fn set_auth_tokens(&mut self, auth_tokens: &AuthTokens)

Set new authentication tokens into the client.

Source

pub fn clear_auth_tokens(&mut self)

Remove all authentication tokens from the client.

This is effectively the same as logging out, though will not remove the active session from the MangaDex server. Be sure to call the logout endpoint to ensure your session is removed.

Source

pub fn get_captcha(&self) -> Option<&String>

Get the captcha solution stored in the client.

Source

pub fn set_captcha<T: Into<String>>(&mut self, captcha: T)

Set a new captcha solution into the client.

The code needed for this can be found in the “X-Captcha-Sitekey” header field, or the siteKey parameter in the error context of a 403 response, captcha_required_exception error code.

Source

pub fn clear_captcha(&mut self)

Remove the captcha solution from the client.

Source

pub fn set_client_info(&mut self, client_info: &ClientInfo)

Source

pub fn get_client_info(&self) -> Option<&ClientInfo>

Source

pub fn clear_client_info(&mut self)

Source

pub fn api_dev_client() -> Self

Trait Implementations§

Source§

impl Clone for HttpClient

Source§

fn clone(&self) -> HttpClient

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 HttpClient

Source§

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

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

impl Default for HttpClient

Source§

fn default() -> Self

Returns the “default value” for a type. 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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,

Source§

impl<T> MaybeSendSync for T