pub struct RestClient { /* private fields */ }Implementations§
Source§impl RestClient
impl RestClient
Sourcepub fn new(
api_key_pair: ApiKeyPair,
base_url: String,
debug: bool,
) -> RestClient
pub fn new( api_key_pair: ApiKeyPair, base_url: String, debug: bool, ) -> RestClient
Examples found in repository?
examples/account_example.rs (line 16)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let api_key = env::var("BYBIT_API_KEY").unwrap_or_else(|_| "YOUR_API_KEY".to_string());
9 let api_secret = env::var("BYBIT_API_SECRET").unwrap_or_else(|_| "YOUR_API_SECRET".to_string());
10
11 // Using testnet by default
12 let base_url = "https://api-testnet.bybit.com".to_string();
13
14 // ApiKeyPair takes (profile_name, key, secret)
15 let key_pair = ApiKeyPair::new("account_demo".to_string(), api_key, api_secret);
16 let client = RestClient::new(key_pair, base_url, true);
17
18 // AccountClient takes ownership of RestClient
19 let account_client = AccountClient::new(client);
20
21 println!("--- Testing get_wallet_balance ---");
22 let params = GetWalletBalanceParams {
23 account_type: AccountType::UNIFIED,
24 coin: None,
25 };
26
27 match account_client.get_wallet_balance(params).await {
28 Ok(response) => println!("Success: {:?}", response),
29 Err(e) => println!("Error: {:?}", e),
30 }
31
32 println!("\n--- Testing get_fee_rate ---");
33 match account_client.get_fee_rate("spot", None, None).await {
34 Ok(response) => println!("Success: {:?}", response),
35 Err(e) => println!("Error: {:?}", e),
36 }
37
38 Ok(())
39}pub async fn get<A: DeserializeOwned>( &self, endpoint: &str, query: Value, sec_type: SecType, ) -> Result<A, Error>
pub async fn post<A: DeserializeOwned>( &self, endpoint: &str, body: Value, sec_type: SecType, ) -> Result<A, Error>
Auto Trait Implementations§
impl Freeze for RestClient
impl !RefUnwindSafe for RestClient
impl Send for RestClient
impl Sync for RestClient
impl Unpin for RestClient
impl !UnwindSafe for RestClient
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