Struct aws_sdk_dynamodb::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 8605)
8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615
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