pub struct UserDataStreamManager { /* private fields */ }Expand description
Manages a user data stream with automatic keep-alive.
This manager automatically refreshes the listen key every 30 minutes to prevent the stream from expiring (listen keys expire after 60 minutes).
§Example
ⓘ
use binance_api_client::Binance;
use binance_api_client::websocket::UserDataStreamManager;
let client = Binance::new("api_key", "secret_key")?;
let mut manager = UserDataStreamManager::new(client).await?;
while let Some(event) = manager.next().await {
match event? {
WebSocketEvent::ExecutionReport(report) => {
println!("Order update: {:?}", report);
}
WebSocketEvent::AccountPosition(position) => {
println!("Account update: {:?}", position);
}
_ => {}
}
}Implementations§
Source§impl UserDataStreamManager
impl UserDataStreamManager
Sourcepub async fn new(client: Binance) -> Result<Self>
pub async fn new(client: Binance) -> Result<Self>
Create a new user data stream manager.
This will start the listen key and begin receiving user data events.
Sourcepub async fn next(&mut self) -> Option<Result<WebSocketEvent>>
pub async fn next(&mut self) -> Option<Result<WebSocketEvent>>
Receive the next user data event.
Sourcepub async fn listen_key(&self) -> String
pub async fn listen_key(&self) -> String
Get the current listen key.
Sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
Check if the manager is stopped.
Auto Trait Implementations§
impl Freeze for UserDataStreamManager
impl !RefUnwindSafe for UserDataStreamManager
impl Send for UserDataStreamManager
impl Sync for UserDataStreamManager
impl Unpin for UserDataStreamManager
impl !UnwindSafe for UserDataStreamManager
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