pub struct Client { /* private fields */ }Expand description
A simple extendable client wrapper for http request with extra url sanitization.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new_url<U>(
url: U,
timeout: Option<Duration>,
) -> Result<Client, HttpClientError>where
U: IntoUrl,
pub fn new_url<U>(
url: U,
timeout: Option<Duration>,
) -> Result<Client, HttpClientError>where
U: IntoUrl,
Attempt to create a new http client from a something that can be converted to a URL
Sourcepub fn builder<U>(url: U) -> Result<ClientBuilder, HttpClientError>where
U: IntoUrl,
pub fn builder<U>(url: U) -> Result<ClientBuilder, HttpClientError>where
U: IntoUrl,
Creates a ClientBuilder to configure a Client.
This is the same as ClientBuilder::new().
Sourcepub fn change_base_urls(&mut self, new_urls: Vec<Url>)
pub fn change_base_urls(&mut self, new_urls: Vec<Url>)
Update the set of hosts that this client uses when sending API requests.
Sourcepub fn clone_with_new_url(&self, new_url: Url) -> Client
pub fn clone_with_new_url(&self, new_url: Url) -> Client
Create new instance of Client using the provided base url and existing client config
Sourcepub fn current_url(&self) -> &Url
pub fn current_url(&self) -> &Url
Get the currently configured host that this client uses when sending API requests.
Sourcepub fn base_urls(&self) -> &[Url]
pub fn base_urls(&self) -> &[Url]
Get the currently configured host that this client uses when sending API requests.
Sourcepub fn base_urls_mut(&mut self) -> &mut [Url]
pub fn base_urls_mut(&mut self) -> &mut [Url]
Get a mutable reference to the hosts that this client uses when sending API requests.
Sourcepub fn change_retry_limit(&mut self, limit: usize)
pub fn change_retry_limit(&mut self, limit: usize)
Change the currently configured limit on the number of retries for a request.
Trait Implementations§
Source§impl ApiClientCore for Client
impl ApiClientCore for Client
Source§fn create_request<P, B, K, V>(
&self,
method: Method,
path: P,
params: &[(K, V)],
body: Option<&B>,
) -> Result<RequestBuilder, HttpClientError>
fn create_request<P, B, K, V>( &self, method: Method, path: P, params: &[(K, V)], body: Option<&B>, ) -> Result<RequestBuilder, HttpClientError>
Create an HTTP request using the host configured in this client.
Source§fn send<'life0, 'async_trait>(
&'life0 self,
request: RequestBuilder,
) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Client: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
request: RequestBuilder,
) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Client: 'async_trait,
Send a created HTTP request. Read more
Source§fn create_request_endpoint<B, S>(
&self,
method: Method,
endpoint: S,
body: Option<&B>,
) -> Result<RequestBuilder, HttpClientError>
fn create_request_endpoint<B, S>( &self, method: Method, endpoint: S, body: Option<&B>, ) -> Result<RequestBuilder, HttpClientError>
Create an HTTP request using the host configured in this client and an API endpoint (i.e.
"/api/v1/mixnodes?since=12345"). If the provided endpoint fails to parse as path (and
optionally query parameters). Read moreSource§impl NymNodeApiClientExt for Client
impl NymNodeApiClientExt for Client
fn get_health<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NodeHealth, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_node_load<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NodeLoad, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_host_information<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<SignedHostInformation, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_description<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NodeDescription, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_build_information<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BinaryBuildInformationOwned, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_roles<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NodeRoles, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_auxiliary_details<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AuxiliaryDetails, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_mixnet_websockets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<WebSockets, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_network_requester<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NetworkRequester, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_exit_policy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<UsedExitPolicy, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_ip_packet_router<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<IpPacketRouter, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_authenticator<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Authenticator, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_wireguard<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Wireguard, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_sessions_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<SessionStats, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn get_lewes_protocol<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<LewesProtocol, NymNodeApiClientError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<C> ApiClient for Cwhere
C: ApiClientCore + Sync,
impl<C> ApiClient for Cwhere
C: ApiClientCore + Sync,
Source§fn create_get_request<P, K, V>(
&self,
path: P,
params: &[(K, V)],
) -> Result<RequestBuilder, HttpClientError>
fn create_get_request<P, K, V>( &self, path: P, params: &[(K, V)], ) -> Result<RequestBuilder, HttpClientError>
Create an HTTP GET Request with the provided path and parameters
Source§fn create_post_request<P, B, K, V>(
&self,
path: P,
params: &[(K, V)],
json_body: &B,
) -> Result<RequestBuilder, HttpClientError>
fn create_post_request<P, B, K, V>( &self, path: P, params: &[(K, V)], json_body: &B, ) -> Result<RequestBuilder, HttpClientError>
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: &[(K, V)],
) -> Result<RequestBuilder, HttpClientError>
fn create_delete_request<P, K, V>( &self, path: P, params: &[(K, V)], ) -> Result<RequestBuilder, HttpClientError>
Create an HTTP DELETE Request with the provided path and parameters
Source§fn create_patch_request<P, B, K, V>(
&self,
path: P,
params: &[(K, V)],
json_body: &B,
) -> Result<RequestBuilder, HttpClientError>
fn create_patch_request<P, B, K, V>( &self, path: P, params: &[(K, V)], json_body: &B, ) -> Result<RequestBuilder, HttpClientError>
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: &'life1 [(K, V)],
) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
fn send_get_request<'life0, 'life1, 'async_trait, P, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + '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: &'life1 [(K, V)],
json_body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
fn send_post_request<'life0, 'life1, 'life2, 'async_trait, P, B, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + '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: &'life1 [(K, V)],
) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
fn send_delete_request<'life0, 'life1, 'async_trait, P, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + '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: &'life1 [(K, V)],
json_body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + 'async_trait>>
fn send_patch_request<'life0, 'life1, 'life2, 'async_trait, P, B, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], json_body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpClientError>> + Send + '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: &'life1 [(K, V)],
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
fn get_json<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + '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 get_response<'life0, 'life1, 'async_trait, P, T, K, V>(
&'life0 self,
path: P,
params: &'life1 [(K, V)],
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
fn get_response<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + '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 headerSource§fn post_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>(
&'life0 self,
path: P,
params: &'life1 [(K, V)],
json_body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: RequestPath + Send + Sync + 'async_trait,
B: Serialize + Sync + 'async_trait + ?Sized,
T: for<'a> Deserialize<'a> + 'async_trait,
K: AsRef<str> + Sync + 'async_trait,
V: AsRef<str> + Sync + 'async_trait,
Self: Sync + 'async_trait,
fn post_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>(
&'life0 self,
path: P,
params: &'life1 [(K, V)],
json_body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: RequestPath + Send + Sync + 'async_trait,
B: Serialize + Sync + 'async_trait + ?Sized,
T: for<'a> Deserialize<'a> + 'async_trait,
K: AsRef<str> + Sync + 'async_trait,
V: AsRef<str> + Sync + 'async_trait,
Self: Sync + '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: &'life1 [(K, V)],
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>
fn delete_json<'life0, 'life1, 'async_trait, P, T, K, V>( &'life0 self, path: P, params: &'life1 [(K, V)], ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + '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: &'life1 [(K, V)],
json_body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: RequestPath + Send + Sync + 'async_trait,
B: Serialize + Sync + 'async_trait + ?Sized,
T: for<'a> Deserialize<'a> + 'async_trait,
K: AsRef<str> + Sync + 'async_trait,
V: AsRef<str> + Sync + 'async_trait,
Self: Sync + 'async_trait,
fn patch_json<'life0, 'life1, 'life2, 'async_trait, P, B, T, K, V>(
&'life0 self,
path: P,
params: &'life1 [(K, V)],
json_body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: RequestPath + Send + Sync + 'async_trait,
B: Serialize + Sync + 'async_trait + ?Sized,
T: for<'a> Deserialize<'a> + 'async_trait,
K: AsRef<str> + Sync + 'async_trait,
V: AsRef<str> + Sync + 'async_trait,
Self: Sync + '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>>
fn get_json_from<'life0, 'async_trait, T, S>( &'life0 self, endpoint: S, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + '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>>
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>>
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>>
fn delete_json_from<'life0, 'async_trait, T, S>( &'life0 self, endpoint: S, ) -> Pin<Box<dyn Future<Output = Result<T, HttpClientError>> + Send + '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>>
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>>
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.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more