aws_sdk_kms/client/
customize.rs1pub struct CustomizableOperation<T, E, B> {
5 customizable_send: B,
6 config_override: ::std::option::Option<crate::config::Builder>,
7 interceptors: Vec<::aws_smithy_runtime_api::client::interceptors::SharedInterceptor>,
8 runtime_plugins: Vec<::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin>,
9 _output: ::std::marker::PhantomData<T>,
10 _error: ::std::marker::PhantomData<E>,
11}
12
13impl<T, E, B> CustomizableOperation<T, E, B> {
14 #[allow(dead_code)] pub(crate) fn new(customizable_send: B) -> Self {
17 Self {
18 customizable_send,
19 config_override: ::std::option::Option::None,
20 interceptors: vec![],
21 runtime_plugins: vec![],
22 _output: ::std::marker::PhantomData,
23 _error: ::std::marker::PhantomData,
24 }
25 }
26
27 pub(crate) fn execute<U>(self, f: impl ::std::ops::FnOnce(B, crate::config::Builder) -> U) -> U {
28 let mut config_override = self.config_override.unwrap_or_default();
29 self.interceptors.into_iter().for_each(|interceptor| {
30 config_override.push_interceptor(interceptor);
31 });
32 self.runtime_plugins.into_iter().for_each(|plugin| {
33 config_override.push_runtime_plugin(plugin);
34 });
35 f(self.customizable_send, config_override)
36 }
37
38 pub fn interceptor(mut self, interceptor: impl ::aws_smithy_runtime_api::client::interceptors::Intercept + 'static) -> Self {
45 self.interceptors
46 .push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(interceptor));
47 self
48 }
49
50 #[allow(unused)]
52 pub(crate) fn runtime_plugin(mut self, runtime_plugin: impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin + 'static) -> Self {
53 self.runtime_plugins
54 .push(::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin::new(runtime_plugin));
55 self
56 }
57
58 pub fn map_request<F, MapE>(mut self, f: F) -> Self
60 where
61 F: ::std::ops::Fn(
62 ::aws_smithy_runtime_api::client::orchestrator::HttpRequest,
63 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, MapE>
64 + ::std::marker::Send
65 + ::std::marker::Sync
66 + 'static,
67 MapE: ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
68 {
69 self.interceptors
70 .push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(
71 ::aws_smithy_runtime::client::interceptors::MapRequestInterceptor::new(f),
72 ));
73 self
74 }
75
76 pub fn mutate_request<F>(mut self, f: F) -> Self
78 where
79 F: ::std::ops::Fn(&mut ::aws_smithy_runtime_api::client::orchestrator::HttpRequest) + ::std::marker::Send + ::std::marker::Sync + 'static,
80 {
81 self.interceptors
82 .push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(
83 ::aws_smithy_runtime::client::interceptors::MutateRequestInterceptor::new(f),
84 ));
85 self
86 }
87
88 pub fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
100 self.config_override = Some(config_override.into());
101 self
102 }
103
104 pub async fn send(self) -> crate::client::customize::internal::SendResult<T, E>
106 where
107 E: std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
108 B: crate::client::customize::internal::CustomizableSend<T, E>,
109 {
110 self.execute(|sender, config| sender.send(config)).await
111 }
112}
113
114pub(crate) mod internal;