Skip to main content

gateio_rs/http/
credentials.rs

1/// Gate.io API Credentials.
2///
3/// Communication with Gate.io API authenticated endpoints requires
4/// valid API credentials. These credentials are used for HMAC SHA-512
5/// signing of requests to ensure authenticity.
6///
7/// Note: Production and testnet API credentials are not interchangeable.
8/// Make sure to use the appropriate credentials for your environment.
9///
10/// [API Documentation](https://www.gate.com/docs/developers/apiv4/#authentication)
11///
12#[derive(PartialEq, Eq, Clone)]
13pub struct Credentials {
14    /// API key for authentication
15    pub api_key: String,
16    /// API secret for HMAC signing
17    pub api_secret: String,
18}
19
20impl Credentials {
21    /// Creates new API credentials
22    pub fn new(api_key: impl Into<String>, api_secret: impl Into<String>) -> Self {
23        Credentials {
24            api_key: api_key.into(),
25            api_secret: api_secret.into(),
26        }
27    }
28}
29
30impl std::fmt::Debug for Credentials {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        f.debug_struct("Credentials")
33            .field("api_key", &"api_secret")
34            .finish()
35    }
36}