aws_sdk_ivs/protocol_serde/
shape_get_channel.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_channel_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::get_channel::GetChannelOutput, crate::operation::get_channel::GetChannelError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::get_channel::GetChannelError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::get_channel::GetChannelError::AccessDeniedException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "ResourceNotFoundException" => crate::operation::get_channel::GetChannelError::ResourceNotFoundException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
40 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
41 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 "ValidationException" => crate::operation::get_channel::GetChannelError::ValidationException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
55 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
56 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?;
57 let output = output.meta(generic);
58 output.build()
59 };
60 if tmp.message.is_none() {
61 tmp.message = _error_message;
62 }
63 tmp
64 }),
65 _ => crate::operation::get_channel::GetChannelError::generic(generic),
66 })
67}
68
69#[allow(clippy::unnecessary_wraps)]
70pub fn de_get_channel_http_response(
71 _response_status: u16,
72 _response_headers: &::aws_smithy_runtime_api::http::Headers,
73 _response_body: &[u8],
74) -> std::result::Result<crate::operation::get_channel::GetChannelOutput, crate::operation::get_channel::GetChannelError> {
75 Ok({
76 #[allow(unused_mut)]
77 let mut output = crate::operation::get_channel::builders::GetChannelOutputBuilder::default();
78 output = crate::protocol_serde::shape_get_channel::de_get_channel(_response_body, output)
79 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?;
80 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
81 output.build()
82 })
83}
84
85pub fn ser_get_channel_input(
86 input: &crate::operation::get_channel::GetChannelInput,
87) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
88 let mut out = String::new();
89 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
90 crate::protocol_serde::shape_get_channel_input::ser_get_channel_input_input(&mut object, input)?;
91 object.finish();
92 Ok(::aws_smithy_types::body::SdkBody::from(out))
93}
94
95pub(crate) fn de_get_channel(
96 value: &[u8],
97 mut builder: crate::operation::get_channel::builders::GetChannelOutputBuilder,
98) -> ::std::result::Result<crate::operation::get_channel::builders::GetChannelOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError>
99{
100 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
101 let tokens = &mut tokens_owned;
102 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
103 loop {
104 match tokens.next().transpose()? {
105 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
106 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
107 "channel" => {
108 builder = builder.set_channel(crate::protocol_serde::shape_channel::de_channel(tokens)?);
109 }
110 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
111 },
112 other => {
113 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
114 "expected object key or end object, found: {:?}",
115 other
116 )))
117 }
118 }
119 }
120 if tokens.next().is_some() {
121 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
122 "found more JSON tokens after completing parsing",
123 ));
124 }
125 Ok(builder)
126}