pub struct UserStream {
pub client: Client,
pub recv_window: u64,
}Fields§
§client: Client§recv_window: u64Implementations§
Source§impl UserStream
impl UserStream
Sourcepub async fn start(&self) -> Result<UserDataStream>
pub async fn start(&self) -> Result<UserDataStream>
Get a listen key for the stream
§Examples
use binance::{api::*, userstream::*, config::*};
let userstream: UserStream = Binance::new_with_env(&Config::testnet());
let start = tokio_test::block_on(userstream.start());
assert!(start.is_ok(), "{:?}", start);
assert!(start.unwrap().listen_key.len() > 0)Sourcepub async fn keep_alive(&self, listen_key: &str) -> Result<Success>
pub async fn keep_alive(&self, listen_key: &str) -> Result<Success>
Keep the connection alive, as the listen key becomes invalid after 60mn
§Examples
use binance::{api::*, userstream::*, config::*};
let userstream: UserStream = Binance::new_with_env(&Config::testnet());
let start = tokio_test::block_on(userstream.start());
assert!(start.is_ok(), "{:?}", start);
let keep_alive = tokio_test::block_on(userstream.keep_alive(&start.unwrap().listen_key));
assert!(keep_alive.is_ok())Sourcepub async fn close(&self, listen_key: &str) -> Result<Success>
pub async fn close(&self, listen_key: &str) -> Result<Success>
Invalidate the listen key
§Examples
use binance::{api::*, userstream::*, config::*};
let userstream: UserStream = Binance::new_with_env(&Config::testnet());
let start = tokio_test::block_on(userstream.start());
assert!(start.is_ok(), "{:?}", start);
let close = tokio_test::block_on(userstream.close(&start.unwrap().listen_key));
assert!(close.is_ok())Trait Implementations§
Source§impl Binance for UserStream
impl Binance for UserStream
fn new_with_config( api_key: Option<String>, secret_key: Option<String>, config: &Config, ) -> UserStream
fn new(api_key: Option<String>, secret_key: Option<String>) -> Self
Source§fn new_with_env(config: &Config) -> Self
fn new_with_env(config: &Config) -> Self
Create a binance API using environment variables for credentials
BINANCE_API_KEY=$YOUR_API_KEY
BINANCE_API_SECRET_KEY=$YOUR_SECRET_KEY
Source§impl Clone for UserStream
impl Clone for UserStream
Source§fn clone(&self) -> UserStream
fn clone(&self) -> UserStream
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UserStream
impl !RefUnwindSafe for UserStream
impl Send for UserStream
impl Sync for UserStream
impl Unpin for UserStream
impl !UnwindSafe for UserStream
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