aws_sdk_greengrass/protocol_serde/
shape_list_device_definitions.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_device_definitions_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::list_device_definitions::ListDeviceDefinitionsOutput,
9    crate::operation::list_device_definitions::ListDeviceDefinitionsError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::list_device_definitions::ListDeviceDefinitionsError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    Err(crate::operation::list_device_definitions::ListDeviceDefinitionsError::generic(generic))
17}
18
19#[allow(clippy::unnecessary_wraps)]
20pub fn de_list_device_definitions_http_response(
21    _response_status: u16,
22    _response_headers: &::aws_smithy_runtime_api::http::Headers,
23    _response_body: &[u8],
24) -> std::result::Result<
25    crate::operation::list_device_definitions::ListDeviceDefinitionsOutput,
26    crate::operation::list_device_definitions::ListDeviceDefinitionsError,
27> {
28    Ok({
29        #[allow(unused_mut)]
30        let mut output = crate::operation::list_device_definitions::builders::ListDeviceDefinitionsOutputBuilder::default();
31        output = crate::protocol_serde::shape_list_device_definitions::de_list_device_definitions(_response_body, output)
32            .map_err(crate::operation::list_device_definitions::ListDeviceDefinitionsError::unhandled)?;
33        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
34        output.build()
35    })
36}
37
38pub(crate) fn de_list_device_definitions(
39    value: &[u8],
40    mut builder: crate::operation::list_device_definitions::builders::ListDeviceDefinitionsOutputBuilder,
41) -> ::std::result::Result<
42    crate::operation::list_device_definitions::builders::ListDeviceDefinitionsOutputBuilder,
43    ::aws_smithy_json::deserialize::error::DeserializeError,
44> {
45    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
46    let tokens = &mut tokens_owned;
47    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
48    loop {
49        match tokens.next().transpose()? {
50            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
51            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
52                "Definitions" => {
53                    builder = builder
54                        .set_definitions(crate::protocol_serde::shape_list_of_definition_information::de_list_of_definition_information(tokens)?);
55                }
56                "NextToken" => {
57                    builder = builder.set_next_token(
58                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
60                            .transpose()?,
61                    );
62                }
63                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
64            },
65            other => {
66                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
67                    "expected object key or end object, found: {other:?}"
68                )))
69            }
70        }
71    }
72    if tokens.next().is_some() {
73        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
74            "found more JSON tokens after completing parsing",
75        ));
76    }
77    Ok(builder)
78}