Struct containers_api::conn::client::RequestClient
source · pub struct RequestClient<E> { /* private fields */ }
Implementations§
source§impl<E: From<Error> + From<Error>> RequestClient<E>
impl<E: From<Error> + From<Error>> RequestClient<E>
sourcepub fn new(transport: Transport, validate_fn: Box<ValidateResponseFn<E>>) -> Self
pub fn new(transport: Transport, validate_fn: Box<ValidateResponseFn<E>>) -> Self
Creates a new RequestClient with a specified transport and a function to validate each response.
sourcepub async fn get(&self, endpoint: impl AsRef<str>) -> Result<Response<Body>, E>
pub async fn get(&self, endpoint: impl AsRef<str>) -> Result<Response<Body>, E>
Make a GET request to the endpoint
and return the response.
sourcepub async fn get_string(&self, endpoint: impl AsRef<str>) -> Result<String, E>
pub async fn get_string(&self, endpoint: impl AsRef<str>) -> Result<String, E>
Make a GET request to the endpoint
and return the response as a string.
sourcepub async fn get_json<T: DeserializeOwned>(
&self,
endpoint: impl AsRef<str>
) -> Result<T, E>
pub async fn get_json<T: DeserializeOwned>(
&self,
endpoint: impl AsRef<str>
) -> Result<T, E>
Make a GET request to the endpoint
and return the response as a JSON deserialized object.
sourcepub fn get_stream<'client>(
&'client self,
endpoint: impl AsRef<str> + 'client
) -> impl Stream<Item = Result<Bytes, E>> + 'client
pub fn get_stream<'client>(
&'client self,
endpoint: impl AsRef<str> + 'client
) -> impl Stream<Item = Result<Bytes, E>> + 'client
Make a GET request to the endpoint
and return a stream of byte chunks.
sourcepub fn get_json_stream<'client, T>(
&'client self,
endpoint: impl AsRef<str> + 'client
) -> impl Stream<Item = Result<T, E>> + 'clientwhere
T: DeserializeOwned,
pub fn get_json_stream<'client, T>(
&'client self,
endpoint: impl AsRef<str> + 'client
) -> impl Stream<Item = Result<T, E>> + 'clientwhere
T: DeserializeOwned,
Make a GET request to the endpoint
and return a stream of JSON chunk results.
sourcepub async fn post<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>,
headers: Option<Headers>
) -> Result<Response<Body>, E>where
B: Into<Body>,
pub async fn post<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>,
headers: Option<Headers>
) -> Result<Response<Body>, E>where
B: Into<Body>,
Make a POST request to the endpoint
and return the response.
sourcepub async fn post_string<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>,
headers: Option<Headers>
) -> Result<String, E>where
B: Into<Body>,
pub async fn post_string<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>,
headers: Option<Headers>
) -> Result<String, E>where
B: Into<Body>,
Make a POST request to the endpoint
and return the response as a string.
sourcepub async fn post_json<B, T>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>,
headers: Option<Headers>
) -> Result<T, E>where
T: DeserializeOwned,
B: Into<Body>,
pub async fn post_json<B, T>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>,
headers: Option<Headers>
) -> Result<T, E>where
T: DeserializeOwned,
B: Into<Body>,
Make a POST request to the endpoint
and return the response as a JSON
deserialized value.
sourcepub fn post_stream<'client, B>(
&'client self,
endpoint: impl AsRef<str> + 'client,
body: Payload<B>,
headers: Option<Headers>
) -> impl Stream<Item = Result<Bytes, E>> + 'clientwhere
B: Into<Body> + 'client,
pub fn post_stream<'client, B>(
&'client self,
endpoint: impl AsRef<str> + 'client,
body: Payload<B>,
headers: Option<Headers>
) -> impl Stream<Item = Result<Bytes, E>> + 'clientwhere
B: Into<Body> + 'client,
Make a straeming POST request to the endpoint
and return a
stream of byte chunks.
Use post_into_stream
if the endpoint
returns JSON values.
sourcepub fn post_into_stream<'client, B, T>(
&'client self,
endpoint: impl AsRef<str> + 'client,
body: Payload<B>,
headers: Option<Headers>
) -> impl Stream<Item = Result<T, E>> + 'clientwhere
B: Into<Body> + 'client,
T: DeserializeOwned,
pub fn post_into_stream<'client, B, T>(
&'client self,
endpoint: impl AsRef<str> + 'client,
body: Payload<B>,
headers: Option<Headers>
) -> impl Stream<Item = Result<T, E>> + 'clientwhere
B: Into<Body> + 'client,
T: DeserializeOwned,
Make a streaming POST request to the endpoint
and return a stream of
JSON deserialized chunks.
pub async fn post_upgrade_stream<'client, B>(
&'client self,
endpoint: impl AsRef<str> + 'client,
body: Payload<B>
) -> Result<impl AsyncRead + AsyncWrite + 'client, E>where
B: Into<Body> + 'client,
sourcepub async fn put<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>
) -> Result<Response<Body>, E>where
B: Into<Body>,
pub async fn put<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>
) -> Result<Response<Body>, E>where
B: Into<Body>,
Make a PUT request to the endpoint
and return the response.
sourcepub async fn put_string<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>
) -> Result<String, E>where
B: Into<Body>,
pub async fn put_string<B>(
&self,
endpoint: impl AsRef<str>,
body: Payload<B>
) -> Result<String, E>where
B: Into<Body>,
Make a PUT request to the endpoint
and return the response as a string.
sourcepub async fn delete(
&self,
endpoint: impl AsRef<str>
) -> Result<Response<Body>, E>
pub async fn delete(
&self,
endpoint: impl AsRef<str>
) -> Result<Response<Body>, E>
Make a DELETE request to the endpoint
and return the response.
sourcepub async fn delete_string(&self, endpoint: impl AsRef<str>) -> Result<String, E>
pub async fn delete_string(&self, endpoint: impl AsRef<str>) -> Result<String, E>
Make a DELETE request to the endpoint
and return the response as a string.
sourcepub async fn delete_json<T: DeserializeOwned>(
&self,
endpoint: impl AsRef<str>
) -> Result<T, E>
pub async fn delete_json<T: DeserializeOwned>(
&self,
endpoint: impl AsRef<str>
) -> Result<T, E>
Make a DELETE request to the endpoint
and return the response as a JSON
deserialized object.
Trait Implementations§
source§impl<E: Clone> Clone for RequestClient<E>
impl<E: Clone> Clone for RequestClient<E>
source§fn clone(&self) -> RequestClient<E>
fn clone(&self) -> RequestClient<E>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more