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