Skip to main content

binance_rs_plus/
userstream.rs

1use crate::model::{Success, UserDataStream};
2use crate::client::Client;
3use crate::errors::Result;
4use crate::api::API;
5use crate::api::Spot;
6
7#[derive(Clone)]
8pub struct UserStream {
9    pub client: Client,
10    pub recv_window: u64, // This field seems unused in the provided snippet, but we'll keep it.
11}
12
13impl UserStream {
14    // User Stream
15    pub async fn start(&self) -> Result<UserDataStream> {
16        self.client.post(API::Spot(Spot::UserDataStream)).await
17    }
18
19    // Current open orders on a symbol
20    pub async fn keep_alive(&self, listen_key: &str) -> Result<Success> {
21        self.client
22            .put(API::Spot(Spot::UserDataStream), listen_key)
23            .await
24    }
25
26    pub async fn close(&self, listen_key: &str) -> Result<Success> {
27        self.client
28            .delete(API::Spot(Spot::UserDataStream), listen_key)
29            .await
30    }
31}