pub struct BetfairStreamClient { /* private fields */ }Expand description
Betfair Exchange Stream API client using raw TLS (CRLF-delimited JSON).
On connect, authenticates immediately. On reconnection, replays authentication
and any active subscriptions with the latest clk token for delta resumption.
The auth bytes are stored in a watch channel so the caller can push refreshed
session tokens via update_auth after keep-alive or HTTP
reconnect. The closed flag distinguishes permanent shutdown from transient
reconnect.
Implementations§
Source§impl BetfairStreamClient
impl BetfairStreamClient
Sourcepub async fn connect(
credential: &BetfairCredential,
session_token: String,
handler: TcpMessageHandler,
config: BetfairStreamConfig,
) -> Result<Self, BetfairStreamError>
pub async fn connect( credential: &BetfairCredential, session_token: String, handler: TcpMessageHandler, config: BetfairStreamConfig, ) -> Result<Self, BetfairStreamError>
Connects to the Betfair stream API and authenticates.
§Errors
Returns an error if the connection fails or authentication cannot be sent.
Sourcepub async fn subscribe_markets(
&self,
market_filter: StreamMarketFilter,
data_filter: MarketDataFilter,
heartbeat_ms: Option<u64>,
conflate_ms: Option<u64>,
) -> Result<(), BetfairStreamError>
pub async fn subscribe_markets( &self, market_filter: StreamMarketFilter, data_filter: MarketDataFilter, heartbeat_ms: Option<u64>, conflate_ms: Option<u64>, ) -> Result<(), BetfairStreamError>
Subscribes to market data for the given filter and data fields.
Stores the subscription for automatic replay on reconnection.
§Errors
Returns an error if serialization or sending fails.
Sourcepub async fn subscribe_orders(
&self,
order_filter: Option<OrderFilter>,
heartbeat_ms: Option<u64>,
) -> Result<(), BetfairStreamError>
pub async fn subscribe_orders( &self, order_filter: Option<OrderFilter>, heartbeat_ms: Option<u64>, ) -> Result<(), BetfairStreamError>
Subscribes to order updates.
Stores the subscription for automatic replay on reconnection.
§Errors
Returns an error if serialization or sending fails.
Sourcepub fn update_auth(&self, app_key: &str, session_token: String)
pub fn update_auth(&self, app_key: &str, session_token: String)
Pushes refreshed auth bytes so the next reconnection or subscription uses the current session token instead of the one from initial connect.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BetfairStreamClient
impl RefUnwindSafe for BetfairStreamClient
impl Send for BetfairStreamClient
impl Sync for BetfairStreamClient
impl Unpin for BetfairStreamClient
impl UnsafeUnpin for BetfairStreamClient
impl UnwindSafe for BetfairStreamClient
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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