pub struct RegionProviderChain { /* private fields */ }
Expand description
Load a region by selecting the first from a series of region providers.
§Examples
use aws_types::region::Region;
use std::env;
use aws_config::meta::region::RegionProviderChain;
// region provider that first checks the `CUSTOM_REGION` environment variable,
// then checks the default provider chain, then falls back to us-east-2
let provider = RegionProviderChain::first_try(env::var("CUSTOM_REGION").ok().map(Region::new))
.or_default_provider()
.or_else(Region::new("us-east-2"));
Implementations§
Source§impl RegionProviderChain
impl RegionProviderChain
Sourcepub async fn region(&self) -> Option<Region>
pub async fn region(&self) -> Option<Region>
Load a region from the provider chain
The first provider to return a non-optional region will be selected
Sourcepub fn first_try(provider: impl ProvideRegion + 'static) -> Self
pub fn first_try(provider: impl ProvideRegion + 'static) -> Self
Create a default provider chain that starts by checking this provider.
Sourcepub fn or_else(self, fallback: impl ProvideRegion + 'static) -> Self
pub fn or_else(self, fallback: impl ProvideRegion + 'static) -> Self
Add a fallback provider to the region provider chain.
Sourcepub fn default_provider() -> Self
pub fn default_provider() -> Self
Create a region provider chain that starts by checking the default provider.
Sourcepub fn or_default_provider(self) -> Self
pub fn or_default_provider(self) -> Self
Fallback to the default provider
Trait Implementations§
Source§impl Debug for RegionProviderChain
impl Debug for RegionProviderChain
Source§impl ProvideRegion for RegionProviderChain
impl ProvideRegion for RegionProviderChain
Source§fn region(&self) -> ProvideRegion<'_> ⓘ
fn region(&self) -> ProvideRegion<'_> ⓘ
Load a region from this provider
Auto Trait Implementations§
impl Freeze for RegionProviderChain
impl !RefUnwindSafe for RegionProviderChain
impl Send for RegionProviderChain
impl Sync for RegionProviderChain
impl Unpin for RegionProviderChain
impl !UnwindSafe for RegionProviderChain
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.