pub struct BetfairHttpClient { /* private fields */ }Expand description
Betfair HTTP client for raw API operations.
Handles session-token authentication, JSON-RPC protocol, form-encoded identity requests, REST navigation, rate limiting, and retry logic.
Implementations§
Source§impl BetfairHttpClient
impl BetfairHttpClient
Sourcepub fn new(
credential: BetfairCredential,
timeout_secs: Option<u64>,
max_retries: Option<u32>,
retry_delay_ms: Option<u64>,
proxy_url: Option<String>,
request_rate_per_second: Option<u32>,
order_request_rate_per_second: Option<u32>,
) -> Result<Self, BetfairHttpError>
pub fn new( credential: BetfairCredential, timeout_secs: Option<u64>, max_retries: Option<u32>, retry_delay_ms: Option<u64>, proxy_url: Option<String>, request_rate_per_second: Option<u32>, order_request_rate_per_second: Option<u32>, ) -> Result<Self, BetfairHttpError>
Sourcepub fn with_urls(
self,
identity_login: String,
betting: String,
accounts: String,
navigation: String,
) -> Self
pub fn with_urls( self, identity_login: String, betting: String, accounts: String, navigation: String, ) -> Self
Overrides the API base URLs (for testing with mock servers).
The keep-alive URL is derived from identity_login by replacing the
path with /keepAlive.
Sourcepub fn cancellation_token(&self) -> &CancellationToken
pub fn cancellation_token(&self) -> &CancellationToken
Returns the cancellation token for this client.
Sourcepub async fn session_token(&self) -> Option<String>
pub async fn session_token(&self) -> Option<String>
Returns the current session token, if authenticated.
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Returns whether the client has an active session.
Sourcepub async fn connect(&self) -> Result<(), BetfairHttpError>
pub async fn connect(&self) -> Result<(), BetfairHttpError>
Authenticates with Betfair using interactive (non-cert) login.
Sends credentials to the Identity API and stores the returned session token for subsequent requests.
§Errors
Returns an error if the login request fails or authentication is rejected.
Sourcepub async fn reconnect(&self) -> Result<(), BetfairHttpError>
pub async fn reconnect(&self) -> Result<(), BetfairHttpError>
Sourcepub async fn disconnect(&self)
pub async fn disconnect(&self)
Clears the session token.
Sourcepub async fn keep_alive(&self) -> Result<(), BetfairHttpError>
pub async fn keep_alive(&self) -> Result<(), BetfairHttpError>
Sends a keep-alive request to renew the session.
§Errors
Returns an error if the keep-alive request fails.
Sourcepub async fn send_betting<T, P>(
&self,
method: &str,
params: P,
) -> Result<T, BetfairHttpError>where
T: DeserializeOwned,
P: Serialize,
pub async fn send_betting<T, P>(
&self,
method: &str,
params: P,
) -> Result<T, BetfairHttpError>where
T: DeserializeOwned,
P: Serialize,
Sends a JSON-RPC request to the Betting API.
§Errors
Returns an error if the request fails, authentication is missing, or the response contains a JSON-RPC error.
Sourcepub async fn send_betting_order<T, P>(
&self,
method: &str,
params: P,
) -> Result<T, BetfairHttpError>where
T: DeserializeOwned,
P: Serialize,
pub async fn send_betting_order<T, P>(
&self,
method: &str,
params: P,
) -> Result<T, BetfairHttpError>where
T: DeserializeOwned,
P: Serialize,
Sends a JSON-RPC request to the Betting API with order rate limiting.
§Errors
Returns an error if the request fails, authentication is missing, or the response contains a JSON-RPC error.
Sourcepub async fn send_accounts<T, P>(
&self,
method: &str,
params: P,
) -> Result<T, BetfairHttpError>where
T: DeserializeOwned,
P: Serialize,
pub async fn send_accounts<T, P>(
&self,
method: &str,
params: P,
) -> Result<T, BetfairHttpError>where
T: DeserializeOwned,
P: Serialize,
Sends a JSON-RPC request to the Accounts API.
§Errors
Returns an error if the request fails, authentication is missing, or the response contains a JSON-RPC error.
Sends a GET request to the Navigation API.
§Errors
Returns an error if the request fails or the response cannot be parsed.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BetfairHttpClient
impl !RefUnwindSafe for BetfairHttpClient
impl Send for BetfairHttpClient
impl Sync for BetfairHttpClient
impl Unpin for BetfairHttpClient
impl UnsafeUnpin for BetfairHttpClient
impl !UnwindSafe for BetfairHttpClient
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