Struct simple_hyper_client::Client
source · 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>where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<Error>,
pub fn request<U>( &self, method: Method, uri: U ) -> Result<RequestBuilder<'_>, Error>where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<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>where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<Error>,
pub fn get<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<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>where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<Error>,
pub fn head<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<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>where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<Error>,
pub fn post<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<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>where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<Error>,
pub fn patch<U>(&self, uri: U) -> Result<RequestBuilder<'_>, Error>where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<Error>,
Initiate a PATCH request with the specified URI.
Returns an error if uri
is invalid.