crypto-ws-client

Crates.iocrypto-ws-client
lib.rscrypto-ws-client
version4.12.11
sourcesrc
created_at2020-12-28 22:43:35.214055
updated_at2023-02-26 12:15:52.930301
descriptionA versatile websocket client that supports many cryptocurrency exchanges.
homepage
repositoryhttps://github.com/crypto-crawler/crypto-crawler-rs/tree/main/crypto-ws-client
max_upload_size
id328471
size353,510
Frank Dai (soulmachine)

documentation

README

crypto-ws-client

A versatile websocket client that supports many cryptocurrency exchanges.

Usage

use crypto_ws_client::{BinanceSpotWSClient, WSClient};

#[tokio::main]
async fn main() {
    let (tx, rx) = std::sync::mpsc::channel();
    tokio::task::spawn(async move {
        let symbols = vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()];
        let ws_client = BinanceSpotWSClient::new(tx, None).await;
        ws_client.subscribe_trade(&symbols).await;
        // run for 5 seconds
        let _ = tokio::time::timeout(std::time::Duration::from_secs(5), ws_client.run()).await;
        ws_client.close();
    });

    for msg in rx {
        println!("{}", msg);
    }
}
Commit count: 0

cargo fmt