pub struct HttpClient {
pub client: Client,
/* private fields */
}Expand description
HTTP client for communicating with Pixiv API
Fields§
§client: ClientInternal reqwest client
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn set_access_token(&mut self, token: String)
pub fn set_access_token(&mut self, token: String)
Set authentication token
Sourcepub fn access_token(&self) -> Option<&str>
pub fn access_token(&self) -> Option<&str>
Get current authentication token
Sourcepub fn set_refresh_token(&mut self, token: String)
pub fn set_refresh_token(&mut self, token: String)
Set refresh token
Sourcepub fn refresh_token(&self) -> Option<&str>
pub fn refresh_token(&self) -> Option<&str>
Get current refresh token
Sourcepub async fn post<T: Serialize + ?Sized>(
&self,
url: &str,
body: &T,
) -> Result<Response>
pub async fn post<T: Serialize + ?Sized>( &self, url: &str, body: &T, ) -> Result<Response>
Send POST request
Sourcepub async fn send_request<T: Serialize + ?Sized>(
&self,
method: Method,
url: &str,
body: Option<&T>,
) -> Result<Response>
pub async fn send_request<T: Serialize + ?Sized>( &self, method: Method, url: &str, body: Option<&T>, ) -> Result<Response>
Send authenticated API request
Sourcepub fn set_base_url(&mut self, base_url: String)
pub fn set_base_url(&mut self, base_url: String)
Set API base URL
Sourcepub fn generate_security_headers(&self) -> HashMap<String, String>
pub fn generate_security_headers(&self) -> HashMap<String, String>
Generate security headers
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpClient
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl !UnwindSafe for HttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more