pub struct UserDataClient { /* private fields */ }Expand description
Client for dealing with the user data stream.
Implementations§
Source§impl UserDataClient
impl UserDataClient
Sourcepub fn connect<A, U>(api_key: A, url: U) -> Result<Self>
pub fn connect<A, U>(api_key: A, url: U) -> Result<Self>
Creates new client instance
§Example
use tokio_binance::{UserDataClient, BINANCE_US_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = UserDataClient::connect("<api-key>", BINANCE_US_URL)?;
Ok(())
}Sourcepub fn start_stream(&self) -> ParamBuilder<'_, '_, StartStreamParams>
pub fn start_stream(&self) -> ParamBuilder<'_, '_, StartStreamParams>
Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent.
§Example
use serde_json::Value;
let response = client
.start_stream()
.json::<Value>()
.await?;Sourcepub fn keep_alive<'a>(
&self,
listen_key: &'a str,
) -> ParamBuilder<'a, '_, KeepAliveStreamParams>
pub fn keep_alive<'a>( &self, listen_key: &'a str, ) -> ParamBuilder<'a, '_, KeepAliveStreamParams>
Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It’s recommended to send a ping about every 30 minutes.
§Example
use serde_json::Value;
let response = client
.keep_alive("<listen-key>")
.json::<Value>()
.await?;Sourcepub fn close_stream<'a>(
&self,
listen_key: &'a str,
) -> ParamBuilder<'a, '_, CloseStreamParams>
pub fn close_stream<'a>( &self, listen_key: &'a str, ) -> ParamBuilder<'a, '_, CloseStreamParams>
Close out a user data stream.
§Example
use serde_json::Value;
let response = client
.close_stream("<listen-key>")
.json::<Value>()
.await?;Trait Implementations§
Source§impl Clone for UserDataClient
impl Clone for UserDataClient
Source§fn clone(&self) -> UserDataClient
fn clone(&self) -> UserDataClient
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 UserDataClient
impl !RefUnwindSafe for UserDataClient
impl Send for UserDataClient
impl Sync for UserDataClient
impl Unpin for UserDataClient
impl !UnwindSafe for UserDataClient
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