Commit 963be327 authored by AWS SDK Rust Bot's avatar AWS SDK Rust Bot
Browse files

[smithy-rs] Rollup of 6 commits



Includes commits:
  f9241adb Re-introduce default generic for server service struct (#3197)
  cbcbed95 Implement ProvideErrorMetadata for service errors (#3189)
  910d42dd Merge remote-tracking branch 'origin/smithy-rs-release-0.57.x' into merge-0.57-to-main
  0b604d7f Merge 0.57 to main (#3200)
  41286629 Fix error struct with default impl (#3190)
  446326c5 Add support for BehaviorMajorVersions (#3151)

Co-authored-by: default avatarAWS SDK Rust Bot <97246200+aws-sdk-rust-ci@users.noreply.github.com>
Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
Co-authored-by: default avatarcodypenta <86309192+codypenta@users.noreply.github.com>
Co-authored-by: default avatardavid-perez <d@vidp.dev>
parent 70fb5361
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ The SDK provides one crate per AWS service. You must add [Tokio](https://crates.

    ```toml
    [dependencies]
    aws-config = "0.57.1"
    aws-config = { version= "0.57.1", features = ["behavior-version-latest"] }
    aws-sdk-dynamodb = "0.37.0"
    tokio = { version = "1", features = ["full"] }
    ```
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ version = "1.23.1"
features = ["macros", "test-util", "rt-multi-thread"]

[features]
behavior-version-latest = []
rustls = ["aws-smithy-runtime/tls-rustls"]
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ your project, add the following to your **Cargo.toml** file:

```toml
[dependencies]
aws-config = "0.57.1"
aws-config = { version = "0.57.1", features = ["behavior-version-latest"] }
aws-sdk-accessanalyzer = "0.37.0"
tokio = { version = "1", features = ["full"] }
```
+4 −0
Original line number Diff line number Diff line
@@ -88,8 +88,10 @@ impl Client {
    ///
    /// - Retries or timeouts are enabled without a `sleep_impl` configured.
    /// - Identity caching is enabled without a `sleep_impl` and `time_source` configured.
    /// - No `behavior_major_version` is provided.
    ///
    /// The panic message for each of these will have instructions on how to resolve them.
    #[track_caller]
    pub fn from_conf(conf: crate::Config) -> Self {
        let handle = Handle {
            conf: conf.clone(),
@@ -127,6 +129,8 @@ impl Client {
    ///     the `sleep_impl` on the Config passed into this function to fix it.
    /// - This method will panic if the `sdk_config` is missing an HTTP connector. If you experience this panic, set the
    ///     `http_connector` on the Config passed into this function to fix it.
    /// - This method will panic if no `BehaviorMajorVersion` is provided. If you experience this panic, set `behavior_major_version` on the Config or enable the `behavior-version-latest` Cargo feature.
    #[track_caller]
    pub fn new(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
        Self::from_conf(sdk_config.into())
    }
+109 −13
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ pub struct Config {
    cloneable: ::aws_smithy_types::config_bag::CloneableLayer,
    pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
    pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
    behavior_major_version: ::std::option::Option<crate::config::BehaviorMajorVersion>,
}
impl Config {
    /// Constructs a config builder.
@@ -37,6 +38,7 @@ impl Config {
            config: self.cloneable.clone(),
            runtime_components: self.runtime_components.clone(),
            runtime_plugins: self.runtime_plugins.clone(),
            behavior_major_version: self.behavior_major_version.clone(),
        }
    }
    /// Deprecated. Don't use.
@@ -131,6 +133,7 @@ pub struct Builder {
    pub(crate) config: ::aws_smithy_types::config_bag::CloneableLayer,
    pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
    pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
    pub(crate) behavior_major_version: ::std::option::Option<crate::config::BehaviorMajorVersion>,
}
impl ::std::default::Default for Builder {
    fn default() -> Self {
@@ -138,6 +141,7 @@ impl ::std::default::Default for Builder {
            config: ::std::default::Default::default(),
            runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
            runtime_plugins: ::std::default::Default::default(),
            behavior_major_version: ::std::default::Default::default(),
        }
    }
}
@@ -946,6 +950,83 @@ impl Builder {
        }
        self
    }
    /// Sets the [`behavior major version`](crate::config::BehaviorMajorVersion).
    ///
    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
    /// all operations might be the ideal behavior but could break existing applications.
    ///
    /// # Examples
    ///
    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
    /// ```no_run
    /// use aws_sdk_accessanalyzer::config::BehaviorMajorVersion;
    ///
    /// let config = aws_sdk_accessanalyzer::Config::builder()
    ///     .behavior_major_version(BehaviorMajorVersion::latest())
    ///     // ...
    ///     .build();
    /// let client = aws_sdk_accessanalyzer::Client::from_conf(config);
    /// ```
    ///
    /// Customizing behavior major version:
    /// ```no_run
    /// use aws_sdk_accessanalyzer::config::BehaviorMajorVersion;
    ///
    /// let config = aws_sdk_accessanalyzer::Config::builder()
    ///     .behavior_major_version(BehaviorMajorVersion::v2023_11_09())
    ///     // ...
    ///     .build();
    /// let client = aws_sdk_accessanalyzer::Client::from_conf(config);
    /// ```

    pub fn behavior_major_version(mut self, behavior_major_version: crate::config::BehaviorMajorVersion) -> Self {
        self.set_behavior_major_version(Some(behavior_major_version));
        self
    }

    /// Sets the [`behavior major version`](crate::config::BehaviorMajorVersion).
    ///
    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
    /// all operations might be the ideal behavior but could break existing applications.
    ///
    /// # Examples
    ///
    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
    /// ```no_run
    /// use aws_sdk_accessanalyzer::config::BehaviorMajorVersion;
    ///
    /// let config = aws_sdk_accessanalyzer::Config::builder()
    ///     .behavior_major_version(BehaviorMajorVersion::latest())
    ///     // ...
    ///     .build();
    /// let client = aws_sdk_accessanalyzer::Client::from_conf(config);
    /// ```
    ///
    /// Customizing behavior major version:
    /// ```no_run
    /// use aws_sdk_accessanalyzer::config::BehaviorMajorVersion;
    ///
    /// let config = aws_sdk_accessanalyzer::Config::builder()
    ///     .behavior_major_version(BehaviorMajorVersion::v2023_11_09())
    ///     // ...
    ///     .build();
    /// let client = aws_sdk_accessanalyzer::Client::from_conf(config);
    /// ```

    pub fn set_behavior_major_version(&mut self, behavior_major_version: Option<crate::config::BehaviorMajorVersion>) -> &mut Self {
        self.behavior_major_version = behavior_major_version;
        self
    }

    /// Convenience method to set the latest behavior major version
    ///
    /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
    pub fn behavior_major_version_latest(mut self) -> Self {
        self.set_behavior_major_version(Some(crate::config::BehaviorMajorVersion::latest()));
        self
    }
    /// Adds a runtime plugin to the config.
    #[allow(unused)]
    pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
@@ -1000,6 +1081,7 @@ impl Builder {
            cloneable: layer,
            runtime_components: self.runtime_components,
            runtime_plugins: self.runtime_plugins,
            behavior_major_version: self.behavior_major_version,
        }
    }
}
@@ -1127,6 +1209,7 @@ impl From<&::aws_types::sdk_config::SdkConfig> for Builder {

        builder.set_http_client(input.http_client());
        builder.set_time_source(input.time_source());
        builder.set_behavior_major_version(input.behavior_major_version());

        if let Some(cache) = input.identity_cache() {
            builder.set_identity_cache(cache);
@@ -1150,21 +1233,32 @@ pub use ::aws_smithy_async::rt::sleep::Sleep;
pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
    let mut configured_plugins = ::std::vec::Vec::new();
    ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
    #[allow(unused_mut)]
    let mut behavior_major_version = config.behavior_major_version.clone();
    #[cfg(feature = "behavior-version-latest")]
    {
        if behavior_major_version.is_none() {
            behavior_major_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorMajorVersion::latest());
        }
    }

    let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
                    // defaults
                    .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
            ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new().with_retry_partition_name("accessanalyzer"),
                        ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
                            .with_retry_partition_name("accessanalyzer")
                            .with_behavior_major_version(behavior_major_version.expect("Invalid client configuration: A behavior major version must be set when sending a request or constructing a client. You must set it during client construction or by enabling the `behavior-version-latest` cargo feature."))
                    ))
                    // user config
                    .with_client_plugin(
                        ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
                            .with_config(config.config.clone())
                .with_runtime_components(config.runtime_components.clone()),
                            .with_runtime_components(config.runtime_components.clone())
                    )
                    // codegen config
                    .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config))
                    .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new());

    for plugin in configured_plugins {
        plugins = plugins.with_client_plugin(plugin);
    }
@@ -1177,6 +1271,8 @@ pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsB

pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;

pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorMajorVersion;

pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;

pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
Loading