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