betfair_stream_api/
lib.rs

1//! Stream API client for Betfair
2
3pub mod cache;
4mod connection;
5mod error;
6mod tls_sream;
7
8extern crate alloc;
9
10pub use cache::market_subscriber::MarketSubscriber;
11pub use cache::order_subscriber::OrderSubscriber;
12pub use cache::primitives::{MarketBookCache, OrderBookCache};
13pub use connection::builder::{HeartbeatStrategy, StreamApiBuilder};
14pub use connection::{CacheEnabledMessages, ExternalUpdates, MetadataUpdates, StreamApi};
15pub use error::StreamError;
16pub use futures::StreamExt;
17pub use tls_sream::{CodecError, StreamAPIClientCodec};
18pub use {betfair_stream_types as types, tokio_util};
19
20/// Extension to connect to the betfair stream
21pub trait BetfairProviderExt {
22    /// connect to the stream
23    fn connect_to_stream(&self) -> StreamApiBuilder;
24
25    /// connect to the stream using a heartbeat configuration
26    fn connect_to_stream_with_hb(&self, hb: HeartbeatStrategy) -> StreamApiBuilder;
27}
28
29impl BetfairProviderExt for betfair_adapter::UnauthenticatedBetfairRpcProvider {
30    fn connect_to_stream(&self) -> StreamApiBuilder {
31        self.connect_to_stream_with_hb(HeartbeatStrategy::None)
32    }
33
34    fn connect_to_stream_with_hb(&self, hb: HeartbeatStrategy) -> StreamApiBuilder {
35        StreamApiBuilder::new(self.clone(), hb)
36    }
37}
38
39#[cfg(feature = "integration-test")]
40/// allows the `betfair-stream-server-mock` to set a custom certificate to be used by the server and
41/// client on a mock TLS connection
42pub static CERTIFICATE: std::sync::OnceLock<String> = std::sync::OnceLock::<String>::new();