aws_sdk_greengrass/protocol_serde/
shape_list_device_definitions.rs1#[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.set_definitions(
54 crate::protocol_serde::shape_list_of_definition_information::de_list_of_definition_information(tokens, _value)?,
55 );
56 }
57 "NextToken" => {
58 builder = builder.set_next_token(
59 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
60 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
61 .transpose()?,
62 );
63 }
64 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
65 },
66 other => {
67 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
68 "expected object key or end object, found: {other:?}"
69 )))
70 }
71 }
72 }
73 if tokens.next().is_some() {
74 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
75 "found more JSON tokens after completing parsing",
76 ));
77 }
78 Ok(builder)
79}