Struct bonsaidb::keystorage::s3::aws_sdk_s3::config::Builder
pub struct Builder { /* private fields */ }
Expand description
Builder for creating a Config
.
Implementations§
§impl Builder
impl Builder
pub fn http_connector(self, http_connector: impl Into<HttpConnector>) -> Builder
pub fn http_connector(self, http_connector: impl Into<HttpConnector>) -> Builder
Sets the HTTP connector to use when making requests.
Examples
use std::time::Duration;
use aws_smithy_client::{Client, hyper_ext};
use aws_smithy_client::erase::DynConnector;
use aws_smithy_client::http_connector::ConnectorSettings;
use aws_sdk_s3::config::Config;
let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_only()
.enable_http1()
.enable_http2()
.build();
let smithy_connector = hyper_ext::Adapter::builder()
// Optionally set things like timeouts as well
.connector_settings(
ConnectorSettings::builder()
.connect_timeout(Duration::from_secs(5))
.build()
)
.build(https_connector);
pub fn set_http_connector(
&mut self,
http_connector: Option<impl Into<HttpConnector>>
) -> &mut Builder
pub fn set_http_connector( &mut self, http_connector: Option<impl Into<HttpConnector>> ) -> &mut Builder
Sets the HTTP connector to use when making requests.
Examples
use std::time::Duration;
use aws_smithy_client::hyper_ext;
use aws_smithy_client::http_connector::ConnectorSettings;
use aws_sdk_s3::config::{Builder, Config};
fn override_http_connector(builder: &mut Builder) {
let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_only()
.enable_http1()
.enable_http2()
.build();
let smithy_connector = hyper_ext::Adapter::builder()
// Optionally set things like timeouts as well
.connector_settings(
ConnectorSettings::builder()
.connect_timeout(Duration::from_secs(5))
.build()
)
.build(https_connector);
builder.set_http_connector(Some(smithy_connector));
}
let mut builder = aws_sdk_s3::Config::builder();
override_http_connector(&mut builder);
let config = builder.build();
pub fn force_path_style(self, force_path_style: impl Into<bool>) -> Builder
pub fn force_path_style(self, force_path_style: impl Into<bool>) -> Builder
Forces this client to use path-style addressing for buckets.
pub fn set_force_path_style(
&mut self,
force_path_style: Option<bool>
) -> &mut Builder
pub fn set_force_path_style( &mut self, force_path_style: Option<bool> ) -> &mut Builder
Forces this client to use path-style addressing for buckets.
pub fn use_arn_region(self, use_arn_region: impl Into<bool>) -> Builder
pub fn use_arn_region(self, use_arn_region: impl Into<bool>) -> Builder
Enables this client to use an ARN’s region when constructing an endpoint instead of the client’s configured region.
pub fn set_use_arn_region(
&mut self,
use_arn_region: Option<bool>
) -> &mut Builder
pub fn set_use_arn_region( &mut self, use_arn_region: Option<bool> ) -> &mut Builder
Enables this client to use an ARN’s region when constructing an endpoint instead of the client’s configured region.
pub fn disable_multi_region_access_points(
self,
disable_multi_region_access_points: impl Into<bool>
) -> Builder
pub fn disable_multi_region_access_points( self, disable_multi_region_access_points: impl Into<bool> ) -> Builder
Disables this client’s usage of Multi-Region Access Points.
pub fn set_disable_multi_region_access_points(
&mut self,
disable_multi_region_access_points: Option<bool>
) -> &mut Builder
pub fn set_disable_multi_region_access_points( &mut self, disable_multi_region_access_points: Option<bool> ) -> &mut Builder
Disables this client’s usage of Multi-Region Access Points.
pub fn accelerate(self, accelerate: impl Into<bool>) -> Builder
pub fn accelerate(self, accelerate: impl Into<bool>) -> Builder
Enables this client to use S3 Transfer Acceleration endpoints.
pub fn set_accelerate(&mut self, accelerate: Option<bool>) -> &mut Builder
pub fn set_accelerate(&mut self, accelerate: Option<bool>) -> &mut Builder
Enables this client to use S3 Transfer Acceleration endpoints.
pub fn endpoint_resolver(
self,
endpoint_resolver: impl ResolveEndpoint<Params> + 'static
) -> Builder
pub fn endpoint_resolver( self, endpoint_resolver: impl ResolveEndpoint<Params> + 'static ) -> Builder
Sets the endpoint resolver to use when making requests.
Note: setting an endpoint resolver will replace any endpoint URL that has been set.
When unset, the client will used a generated endpoint resolver based on the endpoint resolution
rules for aws_sdk_s3
.
Examples
use aws_smithy_http::endpoint;
use aws_sdk_s3::config::endpoint::{Params as EndpointParams, DefaultResolver};
/// Endpoint resolver which adds a prefix to the generated endpoint
#[derive(Debug)]
struct PrefixResolver {
base_resolver: DefaultResolver,
prefix: String
}
impl endpoint::ResolveEndpoint<EndpointParams> for PrefixResolver {
fn resolve_endpoint(&self, params: &EndpointParams) -> endpoint::Result {
self.base_resolver
.resolve_endpoint(params)
.map(|ep|{
let url = ep.url().to_string();
ep.into_builder().url(format!("{}.{}", &self.prefix, url)).build()
})
}
}
let prefix_resolver = PrefixResolver {
base_resolver: DefaultResolver::new(),
prefix: "subdomain".to_string()
};
let config = aws_sdk_s3::Config::builder().endpoint_resolver(prefix_resolver);
pub fn set_endpoint_resolver(
&mut self,
endpoint_resolver: Option<SharedEndpointResolver<Params>>
) -> &mut Builder
pub fn set_endpoint_resolver( &mut self, endpoint_resolver: Option<SharedEndpointResolver<Params>> ) -> &mut Builder
Sets the endpoint resolver to use when making requests.
When unset, the client will used a generated endpoint resolver based on the endpoint resolution
rules for aws_sdk_s3
.
pub fn retry_config(self, retry_config: RetryConfig) -> Builder
pub fn retry_config(self, retry_config: RetryConfig) -> Builder
Set the retry_config for the builder
Examples
use aws_sdk_s3::config::Config;
use aws_sdk_s3::config::retry::RetryConfig;
let retry_config = RetryConfig::standard().with_max_attempts(5);
let config = Config::builder().retry_config(retry_config).build();
pub fn set_retry_config(
&mut self,
retry_config: Option<RetryConfig>
) -> &mut Builder
pub fn set_retry_config( &mut self, retry_config: Option<RetryConfig> ) -> &mut Builder
Set the retry_config for the builder
Examples
use aws_sdk_s3::config::{Builder, Config};
use aws_sdk_s3::config::retry::RetryConfig;
fn disable_retries(builder: &mut Builder) {
let retry_config = RetryConfig::standard().with_max_attempts(1);
builder.set_retry_config(Some(retry_config));
}
let mut builder = Config::builder();
disable_retries(&mut builder);
let config = builder.build();
pub fn sleep_impl(self, sleep_impl: SharedAsyncSleep) -> Builder
pub fn sleep_impl(self, sleep_impl: SharedAsyncSleep) -> Builder
Set the sleep_impl for the builder
Examples
use aws_sdk_s3::config::{AsyncSleep, Config, SharedAsyncSleep, Sleep};
#[derive(Debug)]
pub struct ForeverSleep;
impl AsyncSleep for ForeverSleep {
fn sleep(&self, duration: std::time::Duration) -> Sleep {
Sleep::new(std::future::pending())
}
}
let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
let config = Config::builder().sleep_impl(sleep_impl).build();
pub fn set_sleep_impl(
&mut self,
sleep_impl: Option<SharedAsyncSleep>
) -> &mut Builder
pub fn set_sleep_impl( &mut self, sleep_impl: Option<SharedAsyncSleep> ) -> &mut Builder
Set the sleep_impl for the builder
Examples
use aws_sdk_s3::config::{AsyncSleep, Builder, Config, SharedAsyncSleep, Sleep};
#[derive(Debug)]
pub struct ForeverSleep;
impl AsyncSleep for ForeverSleep {
fn sleep(&self, duration: std::time::Duration) -> Sleep {
Sleep::new(std::future::pending())
}
}
fn set_never_ending_sleep_impl(builder: &mut Builder) {
let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
builder.set_sleep_impl(Some(sleep_impl));
}
let mut builder = Config::builder();
set_never_ending_sleep_impl(&mut builder);
let config = builder.build();
pub fn timeout_config(self, timeout_config: TimeoutConfig) -> Builder
pub fn timeout_config(self, timeout_config: TimeoutConfig) -> Builder
Set the timeout_config for the builder
Examples
use aws_sdk_s3::config::Config;
use aws_sdk_s3::config::timeout::TimeoutConfig;
let timeout_config = TimeoutConfig::builder()
.operation_attempt_timeout(Duration::from_secs(1))
.build();
let config = Config::builder().timeout_config(timeout_config).build();
pub fn set_timeout_config(
&mut self,
timeout_config: Option<TimeoutConfig>
) -> &mut Builder
pub fn set_timeout_config( &mut self, timeout_config: Option<TimeoutConfig> ) -> &mut Builder
Set the timeout_config for the builder
Examples
use aws_sdk_s3::config::{Builder, Config};
use aws_sdk_s3::config::timeout::TimeoutConfig;
fn set_request_timeout(builder: &mut Builder) {
let timeout_config = TimeoutConfig::builder()
.operation_attempt_timeout(Duration::from_secs(1))
.build();
builder.set_timeout_config(Some(timeout_config));
}
let mut builder = Config::builder();
set_request_timeout(&mut builder);
let config = builder.build();
pub fn interceptor(self, interceptor: impl Interceptor + 'static) -> Builder
pub fn interceptor(self, interceptor: impl Interceptor + 'static) -> Builder
Add an Interceptor
that runs at specific stages of the request execution pipeline.
Interceptors targeted at a certain stage are executed according to the pre-defined priority. The SDK provides a default set of interceptors. An interceptor configured by this method will run after those default interceptors.
Examples
use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext};
use aws_smithy_types::config_bag::ConfigBag;
use aws_sdk_s3::config::Config;
fn base_url() -> String {
// ...
}
#[derive(Debug)]
pub struct UriModifierInterceptor;
impl Interceptor for UriModifierInterceptor {
fn modify_before_signing(
&self,
context: &mut InterceptorContext<BeforeTransmit>,
_cfg: &mut ConfigBag,
) -> Result<(), aws_smithy_runtime_api::client::interceptors::BoxError> {
let request = context.request_mut();
let uri = format!("{}{}", base_url(), request.uri().path());
*request.uri_mut() = uri.parse()?;
Ok(())
}
}
let config = Config::builder()
.interceptor(UriModifierInterceptor)
.build();
pub fn push_interceptor(
&mut self,
interceptor: SharedInterceptor
) -> &mut Builder
pub fn push_interceptor( &mut self, interceptor: SharedInterceptor ) -> &mut Builder
Add a SharedInterceptor
that runs at specific stages of the request execution pipeline.
Interceptors targeted at a certain stage are executed according to the pre-defined priority. The SDK provides a default set of interceptors. An interceptor configured by this method will run after those default interceptors.
Examples
use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext, SharedInterceptor};
use aws_smithy_types::config_bag::ConfigBag;
use aws_sdk_s3::config::{Builder, Config};
fn base_url() -> String {
// ...
}
fn modify_request_uri(builder: &mut Builder) {
#[derive(Debug)]
pub struct UriModifierInterceptor;
impl Interceptor for UriModifierInterceptor {
fn modify_before_signing(
&self,
context: &mut InterceptorContext<BeforeTransmit>,
_cfg: &mut ConfigBag,
) -> Result<(), aws_smithy_runtime_api::client::interceptors::BoxError> {
let request = context.request_mut();
let uri = format!("{}{}", base_url(), request.uri().path());
*request.uri_mut() = uri.parse()?;
Ok(())
}
}
builder.push_interceptor(SharedInterceptor::new(UriModifierInterceptor));
}
let mut builder = Config::builder();
modify_request_uri(&mut builder);
let config = builder.build();
pub fn set_interceptors(
&mut self,
interceptors: impl IntoIterator<Item = SharedInterceptor>
) -> &mut Builder
pub fn set_interceptors( &mut self, interceptors: impl IntoIterator<Item = SharedInterceptor> ) -> &mut Builder
Set SharedInterceptor
s for the builder.
pub fn time_source(self, time_source: impl Into<SharedTimeSource>) -> Builder
pub fn time_source(self, time_source: impl Into<SharedTimeSource>) -> Builder
Sets the time source used for this service
pub fn set_time_source(
&mut self,
time_source: Option<SharedTimeSource>
) -> &mut Builder
pub fn set_time_source( &mut self, time_source: Option<SharedTimeSource> ) -> &mut Builder
Sets the time source used for this service
pub fn app_name(self, app_name: AppName) -> Builder
pub fn app_name(self, app_name: AppName) -> Builder
Sets the name of the app that is using the client.
This optional name is used to identify the application in the user agent that gets sent along with requests.
pub fn set_app_name(&mut self, app_name: Option<AppName>) -> &mut Builder
pub fn set_app_name(&mut self, app_name: Option<AppName>) -> &mut Builder
Sets the name of the app that is using the client.
This optional name is used to identify the application in the user agent that gets sent along with requests.
pub fn invocation_id_generator(
self,
gen: impl InvocationIdGenerator + 'static
) -> Builder
pub fn invocation_id_generator( self, gen: impl InvocationIdGenerator + 'static ) -> Builder
Overrides the default invocation ID generator.
The invocation ID generator generates ID values for the amz-sdk-invocation-id
header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
pub fn set_invocation_id_generator(
&mut self,
gen: Option<SharedInvocationIdGenerator>
) -> &mut Builder
pub fn set_invocation_id_generator( &mut self, gen: Option<SharedInvocationIdGenerator> ) -> &mut Builder
Overrides the default invocation ID generator.
The invocation ID generator generates ID values for the amz-sdk-invocation-id
header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
pub fn endpoint_url(self, endpoint_url: impl Into<String>) -> Builder
pub fn endpoint_url(self, endpoint_url: impl Into<String>) -> Builder
Sets the endpoint URL used to communicate with this service
Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
will be prefixed onto this URL. To fully override the endpoint resolver, use
Builder::endpoint_resolver
.
pub fn set_endpoint_url(&mut self, endpoint_url: Option<String>) -> &mut Builder
pub fn set_endpoint_url(&mut self, endpoint_url: Option<String>) -> &mut Builder
Sets the endpoint URL used to communicate with this service
Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
will be prefixed onto this URL. To fully override the endpoint resolver, use
Builder::endpoint_resolver
.
pub fn use_dual_stack(self, use_dual_stack: impl Into<bool>) -> Builder
pub fn use_dual_stack(self, use_dual_stack: impl Into<bool>) -> Builder
When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
pub fn set_use_dual_stack(
&mut self,
use_dual_stack: Option<bool>
) -> &mut Builder
pub fn set_use_dual_stack( &mut self, use_dual_stack: Option<bool> ) -> &mut Builder
When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
pub fn use_fips(self, use_fips: impl Into<bool>) -> Builder
pub fn use_fips(self, use_fips: impl Into<bool>) -> Builder
When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Builder
pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Builder
When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
pub fn region(self, region: impl Into<Option<Region>>) -> Builder
pub fn region(self, region: impl Into<Option<Region>>) -> Builder
Sets the AWS region to use when making requests.
Examples
use aws_types::region::Region;
use aws_sdk_s3::config::{Builder, Config};
let config = aws_sdk_s3::Config::builder()
.region(Region::new("us-east-1"))
.build();
pub fn set_region(&mut self, region: Option<Region>) -> &mut Builder
pub fn set_region(&mut self, region: Option<Region>) -> &mut Builder
Sets the AWS region to use when making requests.
pub fn credentials_provider(
self,
credentials_provider: impl ProvideCredentials + 'static
) -> Builder
pub fn credentials_provider( self, credentials_provider: impl ProvideCredentials + 'static ) -> Builder
Sets the credentials provider for this service
pub fn set_credentials_provider(
&mut self,
credentials_provider: Option<SharedCredentialsProvider>
) -> &mut Builder
pub fn set_credentials_provider( &mut self, credentials_provider: Option<SharedCredentialsProvider> ) -> &mut Builder
Sets the credentials provider for this service
pub fn credentials_cache(self, credentials_cache: CredentialsCache) -> Builder
pub fn credentials_cache(self, credentials_cache: CredentialsCache) -> Builder
Sets the credentials cache for this service
pub fn set_credentials_cache(
&mut self,
credentials_cache: Option<CredentialsCache>
) -> &mut Builder
pub fn set_credentials_cache( &mut self, credentials_cache: Option<CredentialsCache> ) -> &mut Builder
Sets the credentials cache for this service