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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BinanceKlineStream
impl !RefUnwindSafe for BinanceKlineStream
impl Send for BinanceKlineStream
impl Sync for BinanceKlineStream
impl Unpin for BinanceKlineStream
impl UnsafeUnpin for BinanceKlineStream
impl !UnwindSafe for BinanceKlineStream
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more