Struct aws_sdk_s3::middleware::DefaultMiddleware
source · #[non_exhaustive]pub struct DefaultMiddleware;
Expand description
AWS Middleware Stack
This implements the middleware stack for this service. It will:
- Load credentials asynchronously into the property bag
- Sign the request with SigV4
- Resolve an Endpoint for the request
- Add a user agent to the request
Implementations§
source§impl DefaultMiddleware
impl DefaultMiddleware
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new DefaultMiddleware
stack
Note: DefaultMiddleware
holds no state.
Examples found in repository?
src/client.rs (line 17097)
17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107
pub fn from_conf(conf: crate::Config) -> Self {
let retry_config = conf
.retry_config()
.cloned()
.unwrap_or_else(aws_smithy_types::retry::RetryConfig::disabled);
let timeout_config = conf
.timeout_config()
.cloned()
.unwrap_or_else(aws_smithy_types::timeout::TimeoutConfig::disabled);
let sleep_impl = conf.sleep_impl();
if (retry_config.has_retry() || timeout_config.has_timeouts()) && sleep_impl.is_none() {
panic!("An async sleep implementation is required for retries or timeouts to work. \
Set the `sleep_impl` on the Config passed into this function to fix this panic.");
}
let connector = conf.http_connector().and_then(|c| {
let timeout_config = conf
.timeout_config()
.cloned()
.unwrap_or_else(aws_smithy_types::timeout::TimeoutConfig::disabled);
let connector_settings =
aws_smithy_client::http_connector::ConnectorSettings::from_timeout_config(
&timeout_config,
);
c.connector(&connector_settings, conf.sleep_impl())
});
let builder = aws_smithy_client::Builder::new();
let builder = match connector {
// Use provided connector
Some(c) => builder.connector(c),
None => {
#[cfg(any(feature = "rustls", feature = "native-tls"))]
{
// Use default connector based on enabled features
builder.dyn_https_connector(
aws_smithy_client::http_connector::ConnectorSettings::from_timeout_config(
&timeout_config,
),
)
}
#[cfg(not(any(feature = "rustls", feature = "native-tls")))]
{
panic!("No HTTP connector was available. Enable the `rustls` or `native-tls` crate feature or set a connector to fix this.");
}
}
};
let mut builder = builder
.middleware(aws_smithy_client::erase::DynMiddleware::new(
crate::middleware::DefaultMiddleware::new(),
))
.retry_config(retry_config.into())
.operation_timeout_config(timeout_config.into());
builder.set_sleep_impl(sleep_impl);
let client = builder.build();
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
Trait Implementations§
source§impl Clone for DefaultMiddleware
impl Clone for DefaultMiddleware
source§fn clone(&self) -> DefaultMiddleware
fn clone(&self) -> DefaultMiddleware
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DefaultMiddleware
impl Debug for DefaultMiddleware
source§impl Default for DefaultMiddleware
impl Default for DefaultMiddleware
source§fn default() -> DefaultMiddleware
fn default() -> DefaultMiddleware
Returns the “default value” for a type. Read more
source§impl<S> Layer<S> for DefaultMiddleware
impl<S> Layer<S> for DefaultMiddleware
§type Service = <Stack<MapRequestLayer<RecursionDetectionStage>, Stack<MapRequestLayer<SigV4SigningStage>, Stack<AsyncMapRequestLayer<CredentialsStage>, Stack<MapRequestLayer<UserAgentStage>, Stack<MapRequestLayer<AwsAuthStage>, Stack<MapRequestLayer<SmithyEndpointStage>, Identity>>>>>> as Layer<S>>::Service
type Service = <Stack<MapRequestLayer<RecursionDetectionStage>, Stack<MapRequestLayer<SigV4SigningStage>, Stack<AsyncMapRequestLayer<CredentialsStage>, Stack<MapRequestLayer<UserAgentStage>, Stack<MapRequestLayer<AwsAuthStage>, Stack<MapRequestLayer<SmithyEndpointStage>, Identity>>>>>> as Layer<S>>::Service
The wrapped service