Struct containers_api::conn::client::RequestClient
source · [−]pub struct RequestClient<E> { /* private fields */ }Implementations
sourceimpl<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
sourceimpl<E: Clone> Clone for RequestClient<E>
impl<E: Clone> Clone for RequestClient<E>
sourcefn clone(&self) -> RequestClient<E>
fn clone(&self) -> RequestClient<E>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl<E> !RefUnwindSafe for RequestClient<E>
impl<E> Send for RequestClient<E>where
E: Send,
impl<E> Sync for RequestClient<E>where
E: Sync,
impl<E> Unpin for RequestClient<E>where
E: Unpin,
impl<E> !UnwindSafe for RequestClient<E>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more