pub struct BinanceKlineStream { /* private fields */ }live-binance only.Expand description
A live Binance kline stream.
Implementations§
Source§impl BinanceKlineStream
impl BinanceKlineStream
Sourcepub async fn connect(symbols: &[String], interval: Interval) -> Result<Self>
pub async fn connect(symbols: &[String], interval: Interval) -> Result<Self>
Connect to Binance’s combined-stream endpoint for one or more symbols.
Symbols may be passed in either case; they are lowercased to match
Binance’s stream-name conventions. A dropped or stalled connection is
re-established transparently by next_event.
Sourcepub async fn connect_with_config(
symbols: &[String],
interval: Interval,
config: BinanceConfig,
) -> Result<Self>
pub async fn connect_with_config( symbols: &[String], interval: Interval, config: BinanceConfig, ) -> Result<Self>
Connect with a custom BinanceConfig. Useful for Binance Testnet
("wss://testnet.binance.vision") or for shrinking the reconnect
timing in integration tests.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether the caller has closed the stream. Once closed, every further
next_event call yields Ok(None) immediately.
Sourcepub async fn next_event(&mut self) -> Result<Option<KlineEvent>>
pub async fn next_event(&mut self) -> Result<Option<KlineEvent>>
Receive the next kline event. A dropped, errored or stalled connection
is re-established transparently (exponential backoff, up to
BinanceConfig::max_reconnect_attempts); an exhausted reconnect
surfaces as Err. Ok(None) is returned only after the caller has
closed the stream.
Sourcepub async fn close(&mut self) -> Result<()>
pub async fn close(&mut self) -> Result<()>
Close the underlying socket cleanly and mark the stream closed. After
this, next_event yields Ok(None) and never
reconnects.