pub struct KrakenClient { /* private fields */ }
Expand description
Asynchronous HTTP client implementation sending instances of KrakenInput to the Kraken servers
Implementations§
Source§impl KrakenClient
impl KrakenClient
Sourcepub fn new(key: &str, secret: &str) -> Self
pub fn new(key: &str, secret: &str) -> Self
Construct a new KrakenClient instance
KrakenInput instances will be passed into the client and the fully parsed data will be returned
§Note
If only calling public endpoints, passing empty string literals for key and secret is acceptable. However, trying to call a private endpoint with empty credentials will panic. If needing to call both public and private endpoints, a single authenticated client will suffice but unique clients can be used as well
Sourcepub fn set_url(&mut self, url: &str)
pub fn set_url(&mut self, url: &str)
Set the base url where requests will be sent. Not currently useful as Kraken only has one REST API
Defaults to https://api.kraken.com
Sourcepub fn set_version(&mut self, version: &str)
pub fn set_version(&mut self, version: &str)
Set the API version number as defined by Kraken
Defaults to 0
Sourcepub fn set_auth(&mut self, key: &str, secret: &str)
pub fn set_auth(&mut self, key: &str, secret: &str)
Assign new credentials for this KrakenClient
Sourcepub fn url(&self) -> &String
pub fn url(&self) -> &String
Returns the current base url that this client will send requests to
Sourcepub async fn request<'a, T>(&self, input: &KrakenInput) -> KrakenResult<T>where
T: Output + DeserializeOwned,
pub async fn request<'a, T>(&self, input: &KrakenInput) -> KrakenResult<T>where
T: Output + DeserializeOwned,
Make a request to the desired API endpoint by passing a fully constructed KrakenInput
§Note
The types of the input and the output must match otherwise the parsing will fail
For instance: if input
is constructed from a KITicker instance, then T
must be KOTicker