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