pub struct Client { /* private fields */ }
Expand description
The HTTP client able to call the endpoints.
The client will automatically call the required method for an endpoint with the optional data to ensure security needs.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(host: String, api_key: impl Into<Option<String>>) -> Self
pub fn new(host: String, api_key: impl Into<Option<String>>) -> Self
Create a new client with an optional API key.
Sourcepub fn with_signed(
self,
key: String,
recv_window: impl Into<Option<u16>>,
) -> Self
pub fn with_signed( self, key: String, recv_window: impl Into<Option<u16>>, ) -> Self
Add a secret key to sign the queries.
An additional parameter, recv_window
, may be sent to specify the number of milliseconds
after timestamp the request is valid for.
If recv_window will not be sent, it defaults to 5_000.
Sourcepub async fn request<T: DeserializeOwned, E: Endpoint>(
&self,
endpoint: &E,
query: &[(&dyn ToString, &dyn ToString)],
) -> Result<T>
pub async fn request<T: DeserializeOwned, E: Endpoint>( &self, endpoint: &E, query: &[(&dyn ToString, &dyn ToString)], ) -> Result<T>
Request data from endpoint.
For better experience use the url_query! macro to construct key-value pairs of the URL query.
Trait Implementations§
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<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