pub struct Client { /* private fields */ }
Expand description
A wrapper for hyper’s Client
type providing a simpler interface
Example usage:
ⓘ
let connector = HttpConnector::new();
let client = Client::with_connector(connector);
let response = client.get("http://example.com/")?.send().await?;
Implementations§
Source§impl Client
impl Client
pub fn builder() -> ClientBuilder
Sourcepub fn with_connector<C: NetworkConnector>(connector: C) -> Self
pub fn with_connector<C: NetworkConnector>(connector: C) -> Self
Create a new Client
using the specified connector.
Sourcepub async fn send(
&self,
request: Request<SharedBody>,
) -> Result<Response, Error>
pub async fn send( &self, request: Request<SharedBody>, ) -> Result<Response, Error>
This method can be used instead of Client::request if the caller already has a Request.
Sourcepub fn request<U>(
&self,
method: Method,
uri: U,
) -> Result<RequestBuilder<'_>, Error>
pub fn request<U>( &self, method: Method, uri: U, ) -> Result<RequestBuilder<'_>, Error>
Initiate a request with the specified method and URI.
Returns an error if uri
is invalid.
Sourcepub fn get<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
pub fn get<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
Initiate a GET request with the specified URI.
Returns an error if uri
is invalid.
Sourcepub fn head<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
pub fn head<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
Initiate a HEAD request with the specified URI.
Returns an error if uri
is invalid.
Sourcepub fn post<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
pub fn post<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
Initiate a POST request with the specified URI.
Returns an error if uri
is invalid.
Sourcepub fn patch<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
pub fn patch<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
Initiate a PATCH request with the specified URI.
Returns an error if uri
is invalid.
Sourcepub fn put<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
pub fn put<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>
Initiate a PUT request with the specified URI.
Returns an error if uri
is invalid.
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§
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