Skip to main content

BetfairStreamBuilder

Struct BetfairStreamBuilder 

Source
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 implements MessageProcessor, used to handle incoming ResponseMessage objects.

Fields§

§client: BetfairRpcClient<Unauthenticated>

betfair client

§heartbeat_interval: Option<Duration>

Heartbeat interval (used only if heartbeat_enabled is true)

§processor: T

The intermediate processor of messages

Implementations§

Source§

impl<T: MessageProcessor> BetfairStreamBuilder<T>

Source

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.

Source

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.

Source

pub fn with_heartbeat(self, interval: Duration) -> Self

Enables periodic heartbeat messages to keep the streaming connection alive.

§Parameters
  • interval - The duration between heartbeat messages.
§Returns

The updated BetfairStreamBuilder with heartbeat enabled.

Source

pub fn start_with<const C: usize, Sp, H>( self, spawner: Sp, ) -> (BetfairStreamClient<T>, H)
where Sp: FnOnce(BoxFuture<'static, Result<()>>) -> 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 outgoing RequestMessages.
    • sink: a channel receiver for processed messages of type T::Output.
  • H - A handle to the background task driving the streaming logic, type depends on the spawner.
Source

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>

Source§

fn clone(&self) -> BetfairStreamBuilder<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + MessageProcessor> Debug for BetfairStreamBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more