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