aws_sdk_elastictranscoder/protocol_serde/
shape_create_preset.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_preset_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::create_preset::CreatePresetOutput, crate::operation::create_preset::CreatePresetError> {
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::create_preset::CreatePresetError::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::create_preset::CreatePresetError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "AccessDeniedException" => crate::operation::create_preset::CreatePresetError::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::create_preset::CreatePresetError::unhandled)?;
27                let output = output.meta(generic);
28                crate::serde_util::access_denied_exception_correct_errors(output)
29                    .build()
30                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?
31            };
32            tmp
33        }),
34        "IncompatibleVersionException" => crate::operation::create_preset::CreatePresetError::IncompatibleVersionException({
35            #[allow(unused_mut)]
36            let mut tmp = {
37                #[allow(unused_mut)]
38                let mut output = crate::types::error::builders::IncompatibleVersionExceptionBuilder::default();
39                output =
40                    crate::protocol_serde::shape_incompatible_version_exception::de_incompatible_version_exception_json_err(_response_body, output)
41                        .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?;
42                let output = output.meta(generic);
43                crate::serde_util::incompatible_version_exception_correct_errors(output)
44                    .build()
45                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?
46            };
47            tmp
48        }),
49        "InternalServiceException" => crate::operation::create_preset::CreatePresetError::InternalServiceException({
50            #[allow(unused_mut)]
51            let mut tmp = {
52                #[allow(unused_mut)]
53                let mut output = crate::types::error::builders::InternalServiceExceptionBuilder::default();
54                output = crate::protocol_serde::shape_internal_service_exception::de_internal_service_exception_json_err(_response_body, output)
55                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?;
56                let output = output.meta(generic);
57                crate::serde_util::internal_service_exception_correct_errors(output)
58                    .build()
59                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?
60            };
61            tmp
62        }),
63        "LimitExceededException" => crate::operation::create_preset::CreatePresetError::LimitExceededException({
64            #[allow(unused_mut)]
65            let mut tmp = {
66                #[allow(unused_mut)]
67                let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
68                output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
69                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?;
70                let output = output.meta(generic);
71                crate::serde_util::limit_exceeded_exception_correct_errors(output)
72                    .build()
73                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?
74            };
75            tmp
76        }),
77        "ValidationException" => crate::operation::create_preset::CreatePresetError::ValidationException({
78            #[allow(unused_mut)]
79            let mut tmp = {
80                #[allow(unused_mut)]
81                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
82                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
83                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?;
84                let output = output.meta(generic);
85                crate::serde_util::validation_exception_correct_errors(output)
86                    .build()
87                    .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?
88            };
89            tmp
90        }),
91        _ => crate::operation::create_preset::CreatePresetError::generic(generic),
92    })
93}
94
95#[allow(clippy::unnecessary_wraps)]
96pub fn de_create_preset_http_response(
97    _response_status: u16,
98    _response_headers: &::aws_smithy_runtime_api::http::Headers,
99    _response_body: &[u8],
100) -> std::result::Result<crate::operation::create_preset::CreatePresetOutput, crate::operation::create_preset::CreatePresetError> {
101    Ok({
102        #[allow(unused_mut)]
103        let mut output = crate::operation::create_preset::builders::CreatePresetOutputBuilder::default();
104        output = crate::protocol_serde::shape_create_preset::de_create_preset(_response_body, output)
105            .map_err(crate::operation::create_preset::CreatePresetError::unhandled)?;
106        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
107        output.build()
108    })
109}
110
111pub fn ser_create_preset_input(
112    input: &crate::operation::create_preset::CreatePresetInput,
113) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
114    let mut out = String::new();
115    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
116    crate::protocol_serde::shape_create_preset_input::ser_create_preset_input_input(&mut object, input)?;
117    object.finish();
118    Ok(::aws_smithy_types::body::SdkBody::from(out))
119}
120
121pub(crate) fn de_create_preset(
122    value: &[u8],
123    mut builder: crate::operation::create_preset::builders::CreatePresetOutputBuilder,
124) -> ::std::result::Result<
125    crate::operation::create_preset::builders::CreatePresetOutputBuilder,
126    ::aws_smithy_json::deserialize::error::DeserializeError,
127> {
128    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
129    let tokens = &mut tokens_owned;
130    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
131    loop {
132        match tokens.next().transpose()? {
133            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
134            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
135                "Preset" => {
136                    builder = builder.set_preset(crate::protocol_serde::shape_preset::de_preset(tokens)?);
137                }
138                "Warning" => {
139                    builder = builder.set_warning(
140                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
141                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
142                            .transpose()?,
143                    );
144                }
145                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
146            },
147            other => {
148                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
149                    "expected object key or end object, found: {:?}",
150                    other
151                )))
152            }
153        }
154    }
155    if tokens.next().is_some() {
156        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
157            "found more JSON tokens after completing parsing",
158        ));
159    }
160    Ok(builder)
161}