pub struct ClientBuilder { /* private fields */ }Expand description
Configures and builds a Client.
use oanda_rs::{Client, Environment};
use oanda_rs::models::AcceptDatetimeFormat;
let client = Client::builder()
.environment(Environment::Practice)
.token("my-token")
.datetime_format(AcceptDatetimeFormat::Unix)
.rest_rate_limit(50)
.build()
.unwrap();Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn environment(self, environment: Environment) -> Self
pub fn environment(self, environment: Environment) -> Self
Selects the OANDA environment. Defaults to Environment::Practice.
Sourcepub fn token(self, token: impl Into<String>) -> Self
pub fn token(self, token: impl Into<String>) -> Self
Sets the personal access token used as the bearer token on every request. Required.
Sourcepub fn datetime_format(self, format: AcceptDatetimeFormat) -> Self
pub fn datetime_format(self, format: AcceptDatetimeFormat) -> Self
Selects the datetime wire format requested via the
Accept-Datetime-Format header. Defaults to
AcceptDatetimeFormat::Rfc3339.
Sourcepub fn http_client(self, http: Client) -> Self
pub fn http_client(self, http: Client) -> Self
Supplies a pre-configured reqwest::Client (proxies, timeouts,
custom TLS). When set, ClientBuilder::user_agent is ignored.
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> Self
pub fn user_agent(self, user_agent: impl Into<String>) -> Self
Overrides the User-Agent header of the default HTTP client.
Defaults to oanda-rs/<version>.
Sourcepub fn rest_rate_limit(self, requests_per_second: u32) -> Self
pub fn rest_rate_limit(self, requests_per_second: u32) -> Self
Sets the client-side REST rate limit in requests per second. Defaults to 100 (OANDA rejects above 120/s per IP).
Note that OANDA’s limits apply per IP address: if several processes
or Client instances share one IP, their combined rate matters.
Within one process, share a single Client (it is cheap to clone).
Sourcepub fn rate_limiting(self, enabled: bool) -> Self
pub fn rate_limiting(self, enabled: bool) -> Self
Enables or disables built-in rate limiting entirely (REST requests and stream connections). Enabled by default; disable only when you provide your own throttling.