pub struct Client {
pub config: RequestConfig,
/* private fields */
}Expand description
Client for communicating with APIs through HTTP/HTTPS.
When making a HTTP request or starting a websocket connection with this client, a handler that implements RequestHandler is required.
Fields§
§config: RequestConfigImplementations§
Source§impl Client
impl Client
Sourcepub async fn request<Q, B, H>(
&self,
method: Method,
url: &str,
query: Option<&Q>,
body: Option<B>,
handler: &H,
) -> Result<H::Successful, RequestError>
pub async fn request<Q, B, H>( &self, method: Method, url: &str, query: Option<&Q>, body: Option<B>, handler: &H, ) -> Result<H::Successful, RequestError>
Makes an HTTP request with the given RequestHandler and returns the response.
It is recommended to use methods like get() because this method takes many type parameters and parameters.
The request is passed to handler before being sent, and the response is passed to handler before being returned.
Note, that as stated in the docs for RequestBuilder::query(), parameter query only accepts a sequence of key-value pairs.
Sourcepub async fn get<Q, H>(
&self,
url: &str,
query: &Q,
handler: &H,
) -> Result<H::Successful, RequestError>
pub async fn get<Q, H>( &self, url: &str, query: &Q, handler: &H, ) -> Result<H::Successful, RequestError>
Makes an GET request with the given RequestHandler.
This method just calls request(). It requires less typing for type parameters and parameters.
This method requires that handler can handle a request with a body of type (). The actual body passed will be None.
For more information, see request().
Sourcepub async fn get_no_query<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
pub async fn get_no_query<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
Derivation of get().
Sourcepub async fn post<B, H>(
&self,
url: &str,
body: B,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<B>,
pub async fn post<B, H>(
&self,
url: &str,
body: B,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<B>,
Makes an POST request with the given RequestHandler.
This method just calls request(). It requires less typing for type parameters and parameters.
For more information, see request().
Sourcepub async fn post_no_body<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
pub async fn post_no_body<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
Derivation of post().
Sourcepub async fn put<B, H>(
&self,
url: &str,
body: B,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<B>,
pub async fn put<B, H>(
&self,
url: &str,
body: B,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<B>,
Makes an PUT request with the given RequestHandler.
This method just calls request(). It requires less typing for type parameters and parameters.
For more information, see request().
Sourcepub async fn put_no_body<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
pub async fn put_no_body<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
Derivation of put().
Sourcepub async fn delete<Q, H>(
&self,
url: &str,
query: &Q,
handler: &H,
) -> Result<H::Successful, RequestError>
pub async fn delete<Q, H>( &self, url: &str, query: &Q, handler: &H, ) -> Result<H::Successful, RequestError>
Makes an DELETE request with the given RequestHandler.
This method just calls request(). It requires less typing for type parameters and parameters.
This method requires that handler can handle a request with a body of type (). The actual body passed will be None.
For more information, see request().
Sourcepub async fn delete_no_query<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
pub async fn delete_no_query<H>(
&self,
url: &str,
handler: &H,
) -> Result<H::Successful, RequestError>where
H: RequestHandler<()>,
Derivation of delete().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)