1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
use serde_json::Value;
use crate::client::*;
use crate::errors::*;
use crate::rest_model::*;
#[derive(Clone)]
pub struct General {
pub client: Client,
}
impl General {
/// Test connectivity
/// # Examples
/// ```rust
/// use binance::{api::*, general::*, config::*};
/// let conf = Config::default().set_rest_api_endpoint(DATA_REST_ENDPOINT);
/// let general: General = Binance::new_with_env(&conf);
/// let pong = tokio_test::block_on(general.ping());
/// assert!(pong.is_ok(), "{:?}", pong);
/// assert_eq!(pong.unwrap(), "pong");
/// ```
pub async fn ping(&self) -> Result<&'static str> {
let _: Value = self.client.get("/api/v3/ping", None).await?;
Ok("pong")
}
/// Check server time
/// # Examples
/// ```rust
/// use binance::{api::*, general::*, config::*};
/// let conf = Config::default().set_rest_api_endpoint(DATA_REST_ENDPOINT);
/// let general: General = Binance::new_with_env(&conf);
/// let server_time = tokio_test::block_on(general.get_server_time());
/// assert!(server_time.is_ok(), "{:?}", server_time);
/// ```
pub async fn get_server_time(&self) -> Result<ServerTime> { self.client.get("/api/v3/time", None).await }
/// Obtain exchange information (rate limits, symbol metadata etc)
/// # Examples
/// ```rust
/// use binance::{api::*, general::*, config::*};
/// let conf = Config::default().set_rest_api_endpoint(DATA_REST_ENDPOINT);
/// let general: General = Binance::new_with_env(&conf);
/// let exchange_info = tokio_test::block_on(general.exchange_info());
/// assert!(exchange_info.is_ok(), "{:?}", exchange_info);
/// ```
pub async fn exchange_info(&self) -> Result<ExchangeInformation> {
self.client.get("/api/v3/exchangeInfo", None).await
}
}