Skip to main content

binance/
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,
11}
12
13impl UserStream {
14    // User Stream
15    pub fn start(&self) -> Result<UserDataStream> {
16        self.client.post(API::Spot(Spot::UserDataStream))
17    }
18
19    // Current open orders on a symbol
20    pub fn keep_alive(&self, listen_key: &str) -> Result<Success> {
21        self.client.put(API::Spot(Spot::UserDataStream), listen_key)
22    }
23
24    pub fn close(&self, listen_key: &str) -> Result<Success> {
25        self.client
26            .delete(API::Spot(Spot::UserDataStream), listen_key)
27    }
28}