pub struct BetfairStreamBuilder<T: MessageProcessor> {
pub client: BetfairRpcClient<Unauthenticated>,
pub heartbeat_interval: Option<Duration>,
pub processor: T,
}Expand description
A Betfair Stream API client that handles connection, handshake, incoming/outgoing messages, heartbeat and automatic reconnects. Builder for creating a Betfair Streaming API client.
§Type Parameters
T: A type that implementsMessageProcessor, used to handle incomingResponseMessageobjects.
Fields§
§client: BetfairRpcClient<Unauthenticated>betfair client
heartbeat_interval: Option<Duration>Heartbeat interval (used only if heartbeat_enabled is true)
processor: TThe intermediate processor of messages
Implementations§
Source§impl<T: MessageProcessor> BetfairStreamBuilder<T>
impl<T: MessageProcessor> BetfairStreamBuilder<T>
Sourcepub fn new(
client: BetfairRpcClient<Unauthenticated>,
) -> BetfairStreamBuilder<Cache>
pub fn new( client: BetfairRpcClient<Unauthenticated>, ) -> BetfairStreamBuilder<Cache>
Creates a new BetfairStreamBuilder with the given authenticated RPC client.
Uses the default Cache message processor to maintain market and order caches.
By default, no heartbeat messages are sent.
§Parameters
client- An authenticated Betfair RPC client for establishing the streaming connection.
§Returns
A BetfairStreamBuilder configured with cache-based message processing.
Sourcepub fn new_without_cache(
client: BetfairRpcClient<Unauthenticated>,
) -> BetfairStreamBuilder<Forwarder>
pub fn new_without_cache( client: BetfairRpcClient<Unauthenticated>, ) -> BetfairStreamBuilder<Forwarder>
Creates a new BetfairStreamBuilder with raw message forwarding.
Uses the Forwarder message processor to forward raw ResponseMessage objects without caching.
By default, no heartbeat messages are sent.
§Parameters
client- An authenticated Betfair RPC client for establishing the streaming connection.
§Returns
A BetfairStreamBuilder configured to forward raw messages.
Sourcepub fn with_heartbeat(self, interval: Duration) -> Self
pub fn with_heartbeat(self, interval: Duration) -> Self
Sourcepub fn start_with<const C: usize, Sp, H>(
self,
spawner: Sp,
) -> (BetfairStreamClient<T>, H)
pub fn start_with<const C: usize, Sp, H>( self, spawner: Sp, ) -> (BetfairStreamClient<T>, H)
Starts the Betfair streaming client and returns handles for interaction.
This will spawn an asynchronous task that manages the connection, handshake, incoming/outgoing messages, heartbeats (if enabled), and automatic reconnections.
§Type Parameters
C- The capacity of the internal message channels.Sp- The type of the spawner function.H- The type of the handle returned by the spawner.
§Parameters
spawner- A function that takes a boxed future and returns a handle to the spawned task.
§Returns
BetfairStreamClient<T>- A client handle providing:send_to_stream: a channel sender for outgoingRequestMessages.sink: a channel receiver for processed messages of typeT::Output.
H- A handle to the background task driving the streaming logic, type depends on the spawner.
Sourcepub fn start<const C: usize>(
self,
) -> (BetfairStreamClient<T>, JoinHandle<Result<()>>)
pub fn start<const C: usize>( self, ) -> (BetfairStreamClient<T>, JoinHandle<Result<()>>)
Starts the Betfair streaming client with the default Tokio task spawner.
This is a convenience method that uses tokio::spawn to run the streaming task.
§Type Parameters
C- The capacity of the internal message channels.
§Returns
BetfairStreamClient<T>- A client handle for interacting with the stream.JoinHandle<eyre::Result<()>>- A Tokio join handle for the background streaming task.
Trait Implementations§
Source§impl<T: Clone + MessageProcessor> Clone for BetfairStreamBuilder<T>
impl<T: Clone + MessageProcessor> Clone for BetfairStreamBuilder<T>
Source§fn clone(&self) -> BetfairStreamBuilder<T>
fn clone(&self) -> BetfairStreamBuilder<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more