Skip to main content

binance_spot/asynchronous/
general.rs

1use binance_common::error::BinanceError;
2use binance_common::spot::endpoint::route::General;
3use binance_common::spot::model::params::{EmptyParams, general::ExchangeInformationParams};
4use binance_common::spot::model::response::general::{
5    EmptyResponse, ExchangeInformationResponse, ServerTimeResponse,
6};
7use binance_core::{client::asynchronous::Client, signer::signature::Signature};
8
9pub struct GeneralApi<'a, S>
10where
11    S: Signature<'a>,
12{
13    client: Client<'a, S>,
14}
15
16impl<'a, S> GeneralApi<'a, S>
17where
18    S: Signature<'a>,
19{
20    pub async fn new(client: Client<'a, S>) -> GeneralApi<'a, S> {
21        GeneralApi { client }
22    }
23
24    pub async fn ping(&self) -> Result<EmptyResponse, BinanceError> {
25        self.client.get(General::Ping, EmptyParams).await
26    }
27
28    pub async fn get_server_time(&self) -> Result<ServerTimeResponse, BinanceError> {
29        self.client.get(General::ServerTime, EmptyParams).await
30    }
31
32    pub async fn get_exchange_info(
33        &self,
34        params: &ExchangeInformationParams<'a>,
35    ) -> Result<ExchangeInformationResponse, BinanceError> {
36        self.client.get(General::ExchangeInfo, params).await
37    }
38}