Skip to main content

ApiClient

Trait ApiClient 

Source
pub trait ApiClient: ApiClientCore {
Show 18 methods // Provided methods fn create_get_request<P, K, V>( &self, path: P, params: Params<'_, K, V>, ) -> Result<RequestBuilder, HttpClientError> where P: RequestPath, K: AsRef<str>, V: AsRef<str> { ... } fn create_post_request<P, B, K, V>( &self, path: P, params: Params<'_, K, V>, json_body: &B, ) -> Result<RequestBuilder, HttpClientError> where P: RequestPath, B: Serialize + ?Sized, K: AsRef<str>, V: AsRef<str> { ... } fn create_delete_request<P, K, V>( &self, path: P, params: Params<'_, K, V>, ) -> Result<RequestBuilder, HttpClientError> where P: RequestPath, K: AsRef<str>, V: AsRef<str> { ... } fn create_patch_request<P, B, K, V>( &self, path: P, params: Params<'_, K, V>, json_body: &B, ) -> Result<RequestBuilder, HttpClientError> where P: RequestPath, B: Serialize + ?Sized, K: AsRef<str>, V: AsRef<str> { ... } fn send_get_request<'life0, 'life1, 'async_trait, P, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn send_post_request<'life0, 'life1, 'life2, 'async_trait, P, B, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn send_delete_request<'life0, 'life1, 'async_trait, P, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn send_patch_request<'life0, 'life1, 'life2, 'async_trait, P, B, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn get_json<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn parse_response<'life0, 'async_trait, T>( &'life0 self, res: Response, allow_empty: bool, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where T: DeserializeOwned + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait { ... } fn get_response<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn post_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn delete_json<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn patch_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn get_json_from<'life0, 'async_trait, T, S>( &'life0 self, endpoint: S, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait { ... } fn post_json_data_to<'life0, 'life1, 'async_trait, B, T, S>( &'life0 self, endpoint: S, json_body: &'life1 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn delete_json_from<'life0, 'async_trait, T, S>( &'life0 self, endpoint: S, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait { ... } fn patch_json_data_at<'life0, 'life1, 'async_trait, B, T, S>( &'life0 self, endpoint: S, json_body: &'life1 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>> where B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Common usage functionality for the http client.

These functions allow for cleaner downstream usage free of type parameters and unneeded imports.

Provided Methods§

Source

fn create_get_request<P, K, V>( &self, path: P, params: Params<'_, K, V>, ) -> Result<RequestBuilder, HttpClientError>
where P: RequestPath, K: AsRef<str>, V: AsRef<str>,

Create an HTTP GET Request with the provided path and parameters

Source

fn create_post_request<P, B, K, V>( &self, path: P, params: Params<'_, K, V>, json_body: &B, ) -> Result<RequestBuilder, HttpClientError>
where P: RequestPath, B: Serialize + ?Sized, K: AsRef<str>, V: AsRef<str>,

Create an HTTP POST Request with the provided path, parameters, and json body

Source

fn create_delete_request<P, K, V>( &self, path: P, params: Params<'_, K, V>, ) -> Result<RequestBuilder, HttpClientError>
where P: RequestPath, K: AsRef<str>, V: AsRef<str>,

Create an HTTP DELETE Request with the provided path and parameters

Source

fn create_patch_request<P, B, K, V>( &self, path: P, params: Params<'_, K, V>, json_body: &B, ) -> Result<RequestBuilder, HttpClientError>
where P: RequestPath, B: Serialize + ?Sized, K: AsRef<str>, V: AsRef<str>,

Create an HTTP PATCH Request with the provided path, parameters, and json body

Source

fn send_get_request<'life0, 'life1, 'async_trait, P, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create and send an HTTP GET Request with the provided path and parameters

Source

fn send_post_request<'life0, 'life1, 'life2, 'async_trait, P, B, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create and send an HTTP POST Request with the provided path, parameters, and json data

Source

fn send_delete_request<'life0, 'life1, 'async_trait, P, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create and send an HTTP DELETE Request with the provided path and parameters

Source

fn send_patch_request<'life0, 'life1, 'life2, 'async_trait, P, B, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create and send an HTTP PATCH Request with the provided path, parameters, and json data

Source

fn get_json<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

‘get’ json data from the segment-defined path, e.g. ["api", "v1", "mixnodes"], with tuple defined key-value parameters, e.g. [("since", "12345")]. Attempt to parse the response into the provided type T.

Source

fn parse_response<'life0, 'async_trait, T>( &'life0 self, res: Response, allow_empty: bool, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where T: DeserializeOwned + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Attempt to parse a response object from an HTTP response

Source

fn get_response<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

‘get’ data from the segment-defined path, e.g. ["api", "v1", "mixnodes"], with tuple defined key-value parameters, e.g. [("since", "12345")]. Attempt to parse the response into the provided type T based on the content type header

Source

fn post_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

‘post’ json data to the segment-defined path, e.g. ["api", "v1", "mixnodes"], with tuple defined key-value parameters, e.g. [("since", "12345")]. Attempt to parse the response into the provided type T.

Source

fn delete_json<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

‘delete’ json data from the segment-defined path, e.g. ["api", "v1", "mixnodes"], with tuple defined key-value parameters, e.g. [("since", "12345")]. Attempt to parse the response into the provided type T.

Source

fn patch_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>( &'life0 self, path: P, params: Params<'life1, K, V>, json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where P: RequestPath + Send + Sync + 'async_trait, B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, K: AsRef<str> + Sync + 'async_trait, V: AsRef<str> + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

‘patch’ json data at the segment-defined path, e.g. ["api", "v1", "mixnodes"], with tuple defined key-value parameters, e.g. [("since", "12345")]. Attempt to parse the response into the provided type T.

Source

fn get_json_from<'life0, 'async_trait, T, S>( &'life0 self, endpoint: S, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

get json data from the provided absolute endpoint, e.g. "/api/v1/mixnodes?since=12345". Attempt to parse the response into the provided type T.

Source

fn post_json_data_to<'life0, 'life1, 'async_trait, B, T, S>( &'life0 self, endpoint: S, json_body: &'life1 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

post json data to the provided absolute endpoint, e.g. "/api/v1/mixnodes?since=12345". Attempt to parse the response into the provided type T.

Source

fn delete_json_from<'life0, 'async_trait, T, S>( &'life0 self, endpoint: S, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

delete json data from the provided absolute endpoint, e.g. "/api/v1/mixnodes?since=12345". Attempt to parse the response into the provided type T.

Source

fn patch_json_data_at<'life0, 'life1, 'async_trait, B, T, S>( &'life0 self, endpoint: S, json_body: &'life1 B, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
where B: Serialize + ?Sized + Sync + 'async_trait, for<'a> T: Deserialize<'a> + 'async_trait, S: AsRef<str> + Sync + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

patch json data at the provided absolute endpoint, e.g. "/api/v1/mixnodes?since=12345". Attempt to parse the response into the provided type T.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<C> ApiClient for C
where C: ApiClientCore + Sync,