aws_sdk_datasync/protocol_serde/
shape_create_location_smb.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_location_smb_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_location_smb::CreateLocationSmbOutput, crate::operation::create_location_smb::CreateLocationSmbError>
8{
9    #[allow(unused_mut)]
10    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11        .map_err(crate::operation::create_location_smb::CreateLocationSmbError::unhandled)?;
12    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13    let generic = generic_builder.build();
14    let error_code = match generic.code() {
15        Some(code) => code,
16        None => return Err(crate::operation::create_location_smb::CreateLocationSmbError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "InternalException" => crate::operation::create_location_smb::CreateLocationSmbError::InternalException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::InternalExceptionBuilder::default();
26                output = crate::protocol_serde::shape_internal_exception::de_internal_exception_json_err(_response_body, output)
27                    .map_err(crate::operation::create_location_smb::CreateLocationSmbError::unhandled)?;
28                let output = output.meta(generic);
29                output.build()
30            };
31            if tmp.message.is_none() {
32                tmp.message = _error_message;
33            }
34            tmp
35        }),
36        "InvalidRequestException" => crate::operation::create_location_smb::CreateLocationSmbError::InvalidRequestException({
37            #[allow(unused_mut)]
38            let mut tmp = {
39                #[allow(unused_mut)]
40                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
41                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
42                    .map_err(crate::operation::create_location_smb::CreateLocationSmbError::unhandled)?;
43                let output = output.meta(generic);
44                output.build()
45            };
46            if tmp.message.is_none() {
47                tmp.message = _error_message;
48            }
49            tmp
50        }),
51        _ => crate::operation::create_location_smb::CreateLocationSmbError::generic(generic),
52    })
53}
54
55#[allow(clippy::unnecessary_wraps)]
56pub fn de_create_location_smb_http_response(
57    _response_status: u16,
58    _response_headers: &::aws_smithy_runtime_api::http::Headers,
59    _response_body: &[u8],
60) -> std::result::Result<crate::operation::create_location_smb::CreateLocationSmbOutput, crate::operation::create_location_smb::CreateLocationSmbError>
61{
62    Ok({
63        #[allow(unused_mut)]
64        let mut output = crate::operation::create_location_smb::builders::CreateLocationSmbOutputBuilder::default();
65        output = crate::protocol_serde::shape_create_location_smb::de_create_location_smb(_response_body, output)
66            .map_err(crate::operation::create_location_smb::CreateLocationSmbError::unhandled)?;
67        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
68        output.build()
69    })
70}
71
72pub fn ser_create_location_smb_input(
73    input: &crate::operation::create_location_smb::CreateLocationSmbInput,
74) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
75    let mut out = String::new();
76    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
77    crate::protocol_serde::shape_create_location_smb_input::ser_create_location_smb_input_input(&mut object, input)?;
78    object.finish();
79    Ok(::aws_smithy_types::body::SdkBody::from(out))
80}
81
82pub(crate) fn de_create_location_smb(
83    value: &[u8],
84    mut builder: crate::operation::create_location_smb::builders::CreateLocationSmbOutputBuilder,
85) -> ::std::result::Result<
86    crate::operation::create_location_smb::builders::CreateLocationSmbOutputBuilder,
87    ::aws_smithy_json::deserialize::error::DeserializeError,
88> {
89    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
90    let tokens = &mut tokens_owned;
91    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
92    loop {
93        match tokens.next().transpose()? {
94            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
95            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
96                "LocationArn" => {
97                    builder = builder.set_location_arn(
98                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
99                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
100                            .transpose()?,
101                    );
102                }
103                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
104            },
105            other => {
106                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
107                    "expected object key or end object, found: {:?}",
108                    other
109                )))
110            }
111        }
112    }
113    if tokens.next().is_some() {
114        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
115            "found more JSON tokens after completing parsing",
116        ));
117    }
118    Ok(builder)
119}