pub struct ProvidersBuilder { /* private fields */ }Expand description
Builder for Providers.
Implementations§
Source§impl ProvidersBuilder
impl ProvidersBuilder
Sourcepub fn fetch(self, mode: Fetch) -> Self
pub fn fetch(self, mode: Fetch) -> Self
Configure how providers are queried. Default: Sequential.
Use Fetch::Sequential or Fetch::Parallel.
Sourcepub fn api_key(self, provider: Provider, key: impl Into<String>) -> Self
pub fn api_key(self, provider: Provider, key: impl Into<String>) -> Self
Set provider’s API key for the Providers this builds, instead of
the process-global key from its init function.
Two Providers can hold different keys for the same provider, and a
key can be replaced without restarting. Each distinct key gets its own
rate-limit budget. Providers left unset fall back to the process-global
key, then to the environment variable.
Sourcepub fn route(
self,
cap: Capability,
providers: impl IntoIterator<Item = Provider>,
) -> Self
pub fn route( self, cap: Capability, providers: impl IntoIterator<Item = Provider>, ) -> Self
Route a capability to a specific provider priority list.
Providers referenced in the route are automatically added to the initialisation list if not already present. If omitted for a capability, Yahoo is used as default.
Sourcepub fn route_with(
self,
cap: Capability,
providers: impl IntoIterator<Item = Provider>,
fetch: Fetch,
) -> Self
pub fn route_with( self, cap: Capability, providers: impl IntoIterator<Item = Provider>, fetch: Fetch, ) -> Self
Route a capability, overriding fetch for it alone.
Lets a quota-limited capability stay sequential while another races its providers.
Sourcepub fn region(self, region: Region) -> Self
pub fn region(self, region: Region) -> Self
Set the region (automatically sets lang and region code).
Sourcepub fn lang(self, lang: impl Into<String>) -> Self
pub fn lang(self, lang: impl Into<String>) -> Self
Set the language code (e.g., “en-US”, “ja-JP”).
Inherited by every Ticker/Tickers handle created from the built
Providers. With the translation feature, a non-English language
translates text fields on those handles automatically.
Sourcepub fn region_code(self, region: impl Into<String>) -> Self
pub fn region_code(self, region: impl Into<String>) -> Self
Set the region code (e.g., “US”, “JP”, “DE”).
For standard countries, prefer .region() instead to ensure correct
lang/region pairing.
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
Opt into retrying FinanceError::RateLimited errors during dispatch
See RetryPolicy for the exact semantics.
Default is no retry — omitting this call preserves the exact
prior behavior: a RateLimited error is treated like any other
failure and dispatch moves straight to the next routed provider.
Sourcepub fn with_adapter(self, adapter: Arc<dyn ProviderAdapter>) -> Self
pub fn with_adapter(self, adapter: Arc<dyn ProviderAdapter>) -> Self
Register an adapter this crate does not build itself.
Route to it by the id its ProviderCore::id
returns, usually Provider::Custom. Registering alone does not route
anything: a capability with no explicit route still falls back to its
default provider.
let providers = Providers::builder()
.with_adapter(my_adapter)
.route(Capability::ECONOMIC, [Provider::custom("my-source")])
.build()
.await?;Trait Implementations§
Source§impl Debug for ProvidersBuilder
impl Debug for ProvidersBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for ProvidersBuilder
impl !UnwindSafe for ProvidersBuilder
impl Freeze for ProvidersBuilder
impl Send for ProvidersBuilder
impl Sync for ProvidersBuilder
impl Unpin for ProvidersBuilder
impl UnsafeUnpin for ProvidersBuilder
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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