1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | /// Orchestration and serialization glue logic for `DuplexStreamWithInitialMessages`.
|
3 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
4 + | #[non_exhaustive]
|
5 + | pub struct DuplexStreamWithInitialMessages;
|
6 + | impl DuplexStreamWithInitialMessages {
|
7 + | /// Creates a new `DuplexStreamWithInitialMessages`
|
8 + | pub fn new() -> Self {
|
9 + | Self
|
10 + | }
|
11 + | pub(crate) async fn orchestrate(
|
12 + | runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
|
13 + | input: crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
|
14 + | ) -> ::std::result::Result<
|
15 + | crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesOutput,
|
16 + | ::aws_smithy_runtime_api::client::result::SdkError<
|
17 + | crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError,
|
18 + | ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
19 + | >,
|
20 + | > {
|
21 + | let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
|
22 + | ::aws_smithy_runtime_api::client::interceptors::context::Error,
|
23 + | ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
24 + | >| {
|
25 + | err.map_service_error(|err| {
|
26 + | err.downcast::<crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError>()
|
27 + | .expect("correct error type")
|
28 + | })
|
29 + | };
|
30 + | let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
|
31 + | .await
|
32 + | .map_err(map_err)?;
|
33 + | let output = context.finalize().map_err(map_err)?;
|
34 + | ::std::result::Result::Ok(
|
35 + | output
|
36 + | .downcast::<crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesOutput>()
|
37 + | .expect("correct output type"),
|
38 + | )
|
39 + | }
|
40 + |
|
41 + | pub(crate) async fn orchestrate_with_stop_point(
|
42 + | runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
|
43 + | input: crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
|
44 + | stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
|
45 + | ) -> ::std::result::Result<
|
46 + | ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
|
47 + | ::aws_smithy_runtime_api::client::result::SdkError<
|
48 + | ::aws_smithy_runtime_api::client::interceptors::context::Error,
|
49 + | ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
50 + | >,
|
51 + | > {
|
52 + | let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
|
53 + | use ::tracing::Instrument;
|
54 + | ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
|
55 + | "Rest Json Protocol",
|
56 + | "DuplexStreamWithInitialMessages",
|
57 + | input,
|
58 + | runtime_plugins,
|
59 + | stop_point,
|
60 + | )
|
61 + | // Create a parent span for the entire operation. Includes a random, internal-only,
|
62 + | // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
|
63 + | .instrument(::tracing::debug_span!(
|
64 + | "Rest Json Protocol.DuplexStreamWithInitialMessages",
|
65 + | "rpc.service" = "Rest Json Protocol",
|
66 + | "rpc.method" = "DuplexStreamWithInitialMessages",
|
67 + | "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
|
68 + | ))
|
69 + | .await
|
70 + | }
|
71 + |
|
72 + | pub(crate) fn operation_runtime_plugins(
|
73 + | client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
|
74 + | client_config: &crate::config::Config,
|
75 + | config_override: ::std::option::Option<crate::config::Builder>,
|
76 + | ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
|
77 + | let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
|
78 + |
|
79 + | if let ::std::option::Option::Some(config_override) = config_override {
|
80 + | for plugin in config_override.runtime_plugins.iter().cloned() {
|
81 + | runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
|
82 + | }
|
83 + | runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
|
84 + | config_override,
|
85 + | client_config.config.clone(),
|
86 + | &client_config.runtime_components,
|
87 + | ));
|
88 + | }
|
89 + | runtime_plugins
|
90 + | }
|
91 + | }
|
92 + | impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for DuplexStreamWithInitialMessages {
|
93 + | fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
|
94 + | let mut cfg = ::aws_smithy_types::config_bag::Layer::new("DuplexStreamWithInitialMessages");
|
95 + |
|
96 + | cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
|
97 + | DuplexStreamWithInitialMessagesRequestSerializer,
|
98 + | ));
|
99 + | cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
|
100 + | DuplexStreamWithInitialMessagesResponseDeserializer,
|
101 + | ));
|
102 + |
|
103 + | cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
|
104 + | crate::config::auth::Params::builder()
|
105 + | .operation_name("DuplexStreamWithInitialMessages")
|
106 + | .build()
|
107 + | .expect("required fields set"),
|
108 + | ));
|
109 + |
|
110 + | cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
|
111 + | "DuplexStreamWithInitialMessages",
|
112 + | "Rest Json Protocol",
|
113 + | ));
|
114 + |
|
115 + | ::std::option::Option::Some(cfg.freeze())
|
116 + | }
|
117 + |
|
118 + | fn runtime_components(
|
119 + | &self,
|
120 + | _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
|
121 + | ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
|
122 + | #[allow(unused_mut)]
|
123 + | let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("DuplexStreamWithInitialMessages")
|
124 + | .with_interceptor(DuplexStreamWithInitialMessagesEndpointParamsInterceptor)
|
125 + | .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
|
126 + | crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError,
|
127 + | >::new())
|
128 + | .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
|
129 + | crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError,
|
130 + | >::new());
|
131 + |
|
132 + | ::std::borrow::Cow::Owned(rcb)
|
133 + | }
|
134 + | }
|
135 + |
|
136 + | #[derive(Debug)]
|
137 + | struct DuplexStreamWithInitialMessagesResponseDeserializer;
|
138 + | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for DuplexStreamWithInitialMessagesResponseDeserializer {
|
139 + | fn deserialize_streaming(
|
140 + | &self,
|
141 + | response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
142 + | ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
|
143 + | #[allow(unused_mut)]
|
144 + | let mut force_error = false;
|
145 + |
|
146 + | // If this is an error, defer to the non-streaming parser
|
147 + | if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
|
148 + | return ::std::option::Option::None;
|
149 + | }
|
150 + | ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
|
151 + | crate::protocol_serde::shape_duplex_stream_with_initial_messages::de_duplex_stream_with_initial_messages_http_response(response),
|
152 + | ))
|
153 + | }
|
154 + |
|
155 + | fn deserialize_nonstreaming(
|
156 + | &self,
|
157 + | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
158 + | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
159 + | // For streaming operations, we only hit this case if its an error
|
160 + | let body = response.body().bytes().expect("body loaded");
|
161 + | crate::protocol_serde::type_erase_result(
|
162 + | crate::protocol_serde::shape_duplex_stream_with_initial_messages::de_duplex_stream_with_initial_messages_http_error(
|
163 + | response.status().as_u16(),
|
164 + | response.headers(),
|
165 + | body,
|
166 + | ),
|
167 + | )
|
168 + | }
|
169 + | }
|
170 + | #[derive(Debug)]
|
171 + | struct DuplexStreamWithInitialMessagesRequestSerializer;
|
172 + | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DuplexStreamWithInitialMessagesRequestSerializer {
|
173 + | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
174 + | fn serialize_input(
|
175 + | &self,
|
176 + | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
177 + | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
178 + | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
179 + | let input = input
|
180 + | .downcast::<crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput>()
|
181 + | .expect("correct type");
|
182 + | let _header_serialization_settings = _cfg
|
183 + | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
184 + | .cloned()
|
185 + | .unwrap_or_default();
|
186 + | let mut request_builder = {
|
187 + | #[allow(clippy::uninlined_format_args)]
|
188 + | fn uri_base(
|
189 + | _input: &crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
|
190 + | output: &mut ::std::string::String,
|
191 + | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
192 + | use ::std::fmt::Write as _;
|
193 + | ::std::write!(output, "/DuplexStreamWithInitialMessages").expect("formatting should succeed");
|
194 + | ::std::result::Result::Ok(())
|
195 + | }
|
196 + | #[allow(clippy::unnecessary_wraps)]
|
197 + | fn update_http_builder(
|
198 + | input: &crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
|
199 + | builder: ::http_1x::request::Builder,
|
200 + | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
201 + | let mut uri = ::std::string::String::new();
|
202 + | uri_base(input, &mut uri)?;
|
203 + | let builder = crate::protocol_serde::shape_duplex_stream_with_initial_messages::ser_duplex_stream_with_initial_messages_headers(
|
204 + | input, builder,
|
205 + | )?;
|
206 + | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
207 + | }
|
208 + | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
209 + | builder =
|
210 + | _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
|
211 + | builder
|
212 + | };
|
213 + | let body = ::aws_smithy_types::body::SdkBody::from({
|
214 + | let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
|
215 + | let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
|
216 + | let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
|
217 + | _cfg.interceptor_state().store_put(signer_sender);
|
218 + | ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.stream.into_body_stream(
|
219 + | marshaller,
|
220 + | error_marshaller,
|
221 + | signer,
|
222 + | )))
|
223 + | });
|
224 + | if let Some(content_length) = body.content_length() {
|
225 + | let content_length = content_length.to_string();
|
226 + | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
227 + | }
|
228 + | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
229 + | }
|
230 + | }
|
231 + | #[derive(Debug)]
|
232 + | struct DuplexStreamWithInitialMessagesEndpointParamsInterceptor;
|
233 + |
|
234 + | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DuplexStreamWithInitialMessagesEndpointParamsInterceptor {
|
235 + | fn name(&self) -> &'static str {
|
236 + | "DuplexStreamWithInitialMessagesEndpointParamsInterceptor"
|
237 + | }
|
238 + |
|
239 + | fn read_before_execution(
|
240 + | &self,
|
241 + | context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
|
242 + | '_,
|
243 + | ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
244 + | ::aws_smithy_runtime_api::client::interceptors::context::Output,
|
245 + | ::aws_smithy_runtime_api::client::interceptors::context::Error,
|
246 + | >,
|
247 + | cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
248 + | ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
|
249 + | let _input = context
|
250 + | .input()
|
251 + | .downcast_ref::<DuplexStreamWithInitialMessagesInput>()
|
252 + | .ok_or("failed to downcast to DuplexStreamWithInitialMessagesInput")?;
|
253 + |
|
254 + | let params = crate::config::endpoint::Params::builder().build().map_err(|err| {
|
255 + | ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
|
256 + | })?;
|
257 + | cfg.interceptor_state()
|
258 + | .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
|
259 + | ::std::result::Result::Ok(())
|
260 + | }
|
261 + | }
|
262 + |
|
263 + | // The get_* functions below are generated from JMESPath expressions in the
|
264 + | // operationContextParams trait. They target the operation's input shape.
|
265 + |
|
266 + | /// Error type for the `DuplexStreamWithInitialMessagesError` operation.
|
267 + | #[non_exhaustive]
|
268 + | #[derive(::std::fmt::Debug)]
|
269 + | pub enum DuplexStreamWithInitialMessagesError {
|
270 + | #[allow(missing_docs)] // documentation missing in model
|
271 + | ServiceUnavailableError(crate::types::error::ServiceUnavailableError),
|
272 + | #[allow(missing_docs)] // documentation missing in model
|
273 + | ErrorEvent(crate::types::error::ErrorEvent),
|
274 + | /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
|
275 + | #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
|
276 + | variable wildcard pattern and check `.code()`:
|
277 + | \
|
278 + | `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
|
279 + | \
|
280 + | See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-DuplexStreamWithInitialMessagesError) for what information is available for the error.")]
|
281 + | Unhandled(crate::error::sealed_unhandled::Unhandled),
|
282 + | }
|
283 + | impl DuplexStreamWithInitialMessagesError {
|
284 + | /// Creates the `DuplexStreamWithInitialMessagesError::Unhandled` variant from any error type.
|
285 + | pub fn unhandled(
|
286 + | err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
|
287 + | ) -> Self {
|
288 + | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
289 + | source: err.into(),
|
290 + | meta: ::std::default::Default::default(),
|
291 + | })
|
292 + | }
|
293 + |
|
294 + | /// Creates the `DuplexStreamWithInitialMessagesError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
|
295 + | pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
|
296 + | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
297 + | source: err.clone().into(),
|
298 + | meta: err,
|
299 + | })
|
300 + | }
|
301 + | ///
|
302 + | /// Returns error metadata, which includes the error code, message,
|
303 + | /// request ID, and potentially additional information.
|
304 + | ///
|
305 + | pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
|
306 + | match self {
|
307 + | Self::ServiceUnavailableError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
|
308 + | Self::ErrorEvent(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
|
309 + | Self::Unhandled(e) => &e.meta,
|
310 + | }
|
311 + | }
|
312 + | /// Returns `true` if the error kind is `DuplexStreamWithInitialMessagesError::ServiceUnavailableError`.
|
313 + | pub fn is_service_unavailable_error(&self) -> bool {
|
314 + | matches!(self, Self::ServiceUnavailableError(_))
|
315 + | }
|
316 + | /// Returns `true` if the error kind is `DuplexStreamWithInitialMessagesError::ErrorEvent`.
|
317 + | pub fn is_error_event(&self) -> bool {
|
318 + | matches!(self, Self::ErrorEvent(_))
|
319 + | }
|
320 + | }
|
321 + | impl ::std::error::Error for DuplexStreamWithInitialMessagesError {
|
322 + | fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
|
323 + | match self {
|
324 + | Self::ServiceUnavailableError(_inner) => ::std::option::Option::Some(_inner),
|
325 + | Self::ErrorEvent(_inner) => ::std::option::Option::Some(_inner),
|
326 + | Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
|
327 + | }
|
328 + | }
|
329 + | }
|
330 + | impl ::std::fmt::Display for DuplexStreamWithInitialMessagesError {
|
331 + | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
332 + | match self {
|
333 + | Self::ServiceUnavailableError(_inner) => _inner.fmt(f),
|
334 + | Self::ErrorEvent(_inner) => _inner.fmt(f),
|
335 + | Self::Unhandled(_inner) => {
|
336 + | if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
|
337 + | write!(f, "unhandled error ({code})")
|
338 + | } else {
|
339 + | f.write_str("unhandled error")
|
340 + | }
|
341 + | }
|
342 + | }
|
343 + | }
|
344 + | }
|
345 + | impl ::aws_smithy_types::retry::ProvideErrorKind for DuplexStreamWithInitialMessagesError {
|
346 + | fn code(&self) -> ::std::option::Option<&str> {
|
347 + | ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
|
348 + | }
|
349 + | fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
|
350 + | ::std::option::Option::None
|
351 + | }
|
352 + | }
|
353 + | impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for DuplexStreamWithInitialMessagesError {
|
354 + | fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
|
355 + | match self {
|
356 + | Self::ServiceUnavailableError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
|
357 + | Self::ErrorEvent(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
|
358 + | Self::Unhandled(_inner) => &_inner.meta,
|
359 + | }
|
360 + | }
|
361 + | }
|
362 + | impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for DuplexStreamWithInitialMessagesError {
|
363 + | fn create_unhandled_error(
|
364 + | source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
|
365 + | meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
|
366 + | ) -> Self {
|
367 + | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
368 + | source,
|
369 + | meta: meta.unwrap_or_default(),
|
370 + | })
|
371 + | }
|
372 + | }
|
373 + |
|
374 + | pub use crate::operation::duplex_stream_with_initial_messages::_duplex_stream_with_initial_messages_input::DuplexStreamWithInitialMessagesInput;
|
375 + |
|
376 + | pub use crate::operation::duplex_stream_with_initial_messages::_duplex_stream_with_initial_messages_output::DuplexStreamWithInitialMessagesOutput;
|
377 + |
|
378 + | mod _duplex_stream_with_initial_messages_input;
|
379 + |
|
380 + | mod _duplex_stream_with_initial_messages_output;
|
381 + |
|
382 + | /// Builders
|
383 + | pub mod builders;
|