aws_sdk_sts/client/
customize.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3
4
5
6
7
8
9
10
11/// `CustomizableOperation` allows for configuring a single operation invocation before it is sent.
12                pub struct CustomizableOperation<T, E, B> {
13                    customizable_send: B,
14                    config_override: ::std::option::Option<crate::config::Builder>,
15                    interceptors: Vec<::aws_smithy_runtime_api::client::interceptors::SharedInterceptor>,
16                    runtime_plugins: Vec<::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin>,
17                    _output: ::std::marker::PhantomData<T>,
18                    _error: ::std::marker::PhantomData<E>,
19                }
20
21                    impl<T, E, B> CustomizableOperation<T, E, B> {
22                        /// Creates a new `CustomizableOperation` from `customizable_send`.
23                        #[allow(dead_code)] // unused when a service does not provide any operations
24                        pub(crate) fn new(customizable_send: B) -> Self {
25                            Self {
26                                customizable_send,
27                                config_override: ::std::option::Option::None,
28                                interceptors: vec![],
29                                runtime_plugins: vec![],
30                                _output: ::std::marker::PhantomData,
31                                _error: ::std::marker::PhantomData
32                            }
33                        }
34
35                        pub(crate) fn execute<U>(self, f: impl ::std::ops::FnOnce(B, crate::config::Builder) -> U) -> U {
36                            let mut config_override = self.config_override.unwrap_or_default();
37                            self.interceptors.into_iter().for_each(|interceptor| {
38                                config_override.push_interceptor(interceptor);
39                            });
40                            self.runtime_plugins.into_iter().for_each(|plugin| {
41                                config_override.push_runtime_plugin(plugin);
42                            });
43                            f(self.customizable_send, config_override)
44                        }
45
46                    /// Adds an [interceptor](::aws_smithy_runtime_api::client::interceptors::Intercept) that runs at specific stages of the request execution pipeline.
47                    ///
48                    /// Note that interceptors can also be added to `CustomizableOperation` by `config_override`,
49                    /// `map_request`, and `mutate_request` (the last two are implemented via interceptors under the hood).
50                    /// The order in which those user-specified operation interceptors are invoked should not be relied upon
51                    /// as it is an implementation detail.
52                    pub fn interceptor(mut self, interceptor: impl ::aws_smithy_runtime_api::client::interceptors::Intercept + 'static) -> Self {
53                        self.interceptors.push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(interceptor));
54                        self
55                    }
56
57                    /// Adds a runtime plugin.
58                    #[allow(unused)]
59                    pub(crate) fn runtime_plugin(mut self, runtime_plugin: impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin + 'static) -> Self {
60                        self.runtime_plugins.push(::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin::new(runtime_plugin));
61                        self
62                    }
63
64                    /// Allows for customizing the operation's request.
65                    pub fn map_request<F, MapE>(mut self, f: F) -> Self
66                    where
67                        F: ::std::ops::Fn(::aws_smithy_runtime_api::client::orchestrator::HttpRequest) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, MapE>
68                            + ::std::marker::Send
69                            + ::std::marker::Sync
70                            + 'static,
71                        MapE: ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
72                    {
73                        self.interceptors.push(
74                            ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(
75                                ::aws_smithy_runtime::client::interceptors::MapRequestInterceptor::new(f),
76                            ),
77                        );
78                        self
79                    }
80
81                        /// Convenience for `map_request` where infallible direct mutation of request is acceptable.
82                        pub fn mutate_request<F>(mut self, f: F) -> Self
83                        where
84                            F: ::std::ops::Fn(&mut ::aws_smithy_runtime_api::client::orchestrator::HttpRequest) + ::std::marker::Send + ::std::marker::Sync + 'static,
85                        {
86                            self.interceptors.push(
87                                ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(
88                                    ::aws_smithy_runtime::client::interceptors::MutateRequestInterceptor::new(f),
89                                ),
90                            );
91                            self
92                        }
93
94                    /// Overrides config for a single operation invocation.
95                    ///
96                    /// `config_override` is applied to the operation configuration level.
97                    /// The fields in the builder that are `Some` override those applied to the service
98                    /// configuration level. For instance,
99                    ///
100                    /// | Config A           | overridden by Config B | = Config C         |
101                    /// |--------------------|------------------------|--------------------|
102                    /// | field_1: None,     | field_1: Some(v2),     | field_1: Some(v2), |
103                    /// | field_2: Some(v1), | field_2: Some(v2),     | field_2: Some(v2), |
104                    /// | field_3: Some(v1), | field_3: None,         | field_3: Some(v1), |
105                    pub fn config_override(
106                        mut self,
107                        config_override: impl ::std::convert::Into<crate::config::Builder>,
108                    ) -> Self {
109                        self.config_override = Some(config_override.into());
110                        self
111                    }
112
113                    /// Sends the request and returns the response.
114                    pub async fn send(
115                        self,
116                    ) -> crate::client::customize::internal::SendResult<T, E>
117                    where
118                        E: std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
119                        B: crate::client::customize::internal::CustomizableSend<T, E>,
120                    {
121                        self.execute(|sender, config|sender.send(config)).await
122                    }
123
124                    
125                }
126
127pub(crate) mod internal;
128