pub struct Client { /* private fields */ }Expand description
An async client for sending HTTP QUERY requests.
The client wraps a reqwest::Client; clone it freely (it is cheap and
shares the underlying connection pool).
Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a client with a default reqwest::Client.
Sourcepub fn with_http_client(http: HttpClient) -> Self
pub fn with_http_client(http: HttpClient) -> Self
Creates a client wrapping an existing reqwest::Client.
Sourcepub fn with_base_url(self, base: &str) -> Result<Self>
pub fn with_base_url(self, base: &str) -> Result<Self>
Sets a base URL used to resolve relative request URLs.
Sourcepub async fn query(
&self,
url: &str,
content_type: &str,
body: impl Into<Body>,
) -> Result<Response>
pub async fn query( &self, url: &str, content_type: &str, body: impl Into<Body>, ) -> Result<Response>
Sends a QUERY request with a raw body and the given content type.
Sourcepub async fn query_string(
&self,
url: &str,
content_type: &str,
body: impl Into<String>,
) -> Result<Response>
pub async fn query_string( &self, url: &str, content_type: &str, body: impl Into<String>, ) -> Result<Response>
Sends a QUERY request with a string body.
Sourcepub async fn query_json<T: Serialize + ?Sized>(
&self,
url: &str,
value: &T,
) -> Result<Response>
pub async fn query_json<T: Serialize + ?Sized>( &self, url: &str, value: &T, ) -> Result<Response>
Sends a QUERY request whose body is value serialized to JSON.
Sourcepub async fn query_json_into<T, R>(&self, url: &str, value: &T) -> Result<R>
pub async fn query_json_into<T, R>(&self, url: &str, value: &T) -> Result<R>
Sends a JSON QUERY request and decodes a JSON response, validating the status first.
Sourcepub async fn options(&self, url: &str) -> Result<Discovery>
pub async fn options(&self, url: &str) -> Result<Discovery>
Issues an OPTIONS request and reports QUERY support from the response.
Sourcepub async fn fetch_result(&self, resp: &Response) -> Result<Response>
pub async fn fetch_result(&self, resp: &Response) -> Result<Response>
Performs a GET on the stored result of the query (Content-Location,
RFC 10008 §2.3), resolved against the original request URL.
Sourcepub async fn fetch_equivalent(&self, resp: &Response) -> Result<Response>
pub async fn fetch_equivalent(&self, resp: &Response) -> Result<Response>
Performs a GET on the equivalent resource (Location, RFC 10008 §2.4),
which re-runs the query without resending the body.