pub struct HttpClient {
pub client: Client,
pub base_url: Url,
auth_tokens: Option<AuthTokens>,
captcha: Option<String>,
client_info: Option<ClientInfo>,
}
oauth
only.Fields§
§client: Client
§base_url: Url
§auth_tokens: Option<AuthTokens>
§captcha: Option<String>
§client_info: Option<ClientInfo>
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(client: Client) -> Self
pub fn new(client: Client) -> Self
Create a new HttpClient
with a custom reqwest::Client
.
Sourcepub fn builder() -> HttpClientBuilder
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);
Sourcepub(crate) async fn send_request_without_deserializing_with_other_base_url<E>(
&self,
endpoint: &E,
base_url: &Url,
) -> Result<Response>where
E: Endpoint,
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.
Sourcepub(crate) async fn send_request_without_deserializing<E>(
&self,
endpoint: &E,
) -> Result<Response>where
E: Endpoint,
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.
pub(crate) async fn send_request_with_checks<E>(
&self,
endpoint: &E,
) -> Result<Response>where
E: Endpoint,
pub(crate) async fn handle_result<T>(&self, res: Response) -> Result<T>where
T: DeserializeOwned,
Sourcepub(crate) async fn send_request<E>(&self, endpoint: &E) -> Result<E::Response>
pub(crate) async fn send_request<E>(&self, endpoint: &E) -> Result<E::Response>
Send the request to the endpoint and deserialize the response body.
Sourcepub(crate) async fn send_request_with_rate_limit<E>(
&self,
endpoint: &E,
) -> Result<Limited<E::Response>>where
E: Endpoint,
<<E as Endpoint>::Response as FromResponse>::Response: DeserializeOwned,
<E as Endpoint>::Response: Clone,
Available on non-crate feature serialize
only.
pub(crate) async fn send_request_with_rate_limit<E>(
&self,
endpoint: &E,
) -> Result<Limited<E::Response>>where
E: Endpoint,
<<E as Endpoint>::Response as FromResponse>::Response: DeserializeOwned,
<E as Endpoint>::Response: Clone,
serialize
only.Send the request to the endpoint and deserialize the response body.
Sourcepub fn get_tokens(&self) -> Option<&AuthTokens>
pub fn get_tokens(&self) -> Option<&AuthTokens>
Get the authentication tokens stored in the client.
Sourcepub fn set_auth_tokens(&mut self, auth_tokens: &AuthTokens)
pub fn set_auth_tokens(&mut self, auth_tokens: &AuthTokens)
Set new authentication tokens into the client.
Sourcepub fn clear_auth_tokens(&mut self)
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.
Sourcepub fn get_captcha(&self) -> Option<&String>
pub fn get_captcha(&self) -> Option<&String>
Get the captcha solution stored in the client.
Sourcepub fn set_captcha<T: Into<String>>(&mut self, captcha: T)
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.
Sourcepub fn clear_captcha(&mut self)
pub fn clear_captcha(&mut self)
Remove the captcha solution from the client.
pub fn set_client_info(&mut self, client_info: &ClientInfo)
pub fn get_client_info(&self) -> Option<&ClientInfo>
pub fn clear_client_info(&mut self)
pub fn api_dev_client() -> Self
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more