Struct binance::futures::userstream::UserStream
source · pub struct UserStream {
pub client: Client,
pub recv_window: u64,
}
Fields§
§client: Client
§recv_window: u64
Implementations§
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::*, futures::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::*, futures::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::*, futures::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 ) -> Self
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 copy 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 !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