aws_sdk_ecs/protocol_serde/
shape_device.rs1pub fn ser_device(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::Device,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("hostPath").string(input.host_path.as_str());
8 }
9 if let Some(var_1) = &input.container_path {
10 object.key("containerPath").string(var_1.as_str());
11 }
12 if let Some(var_2) = &input.permissions {
13 let mut array_3 = object.key("permissions").start_array();
14 for item_4 in var_2 {
15 {
16 array_3.value().string(item_4.as_str());
17 }
18 }
19 array_3.finish();
20 }
21 Ok(())
22}
23
24pub(crate) fn de_device<'a, I>(
25 tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::Device>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33 #[allow(unused_mut)]
34 let mut builder = crate::types::builders::DeviceBuilder::default();
35 loop {
36 match tokens.next().transpose()? {
37 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39 "hostPath" => {
40 builder = builder.set_host_path(
41 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43 .transpose()?,
44 );
45 }
46 "containerPath" => {
47 builder = builder.set_container_path(
48 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
50 .transpose()?,
51 );
52 }
53 "permissions" => {
54 builder = builder.set_permissions(crate::protocol_serde::shape_device_cgroup_permissions::de_device_cgroup_permissions(
55 tokens,
56 )?);
57 }
58 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
59 },
60 other => {
61 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
62 "expected object key or end object, found: {:?}",
63 other
64 )))
65 }
66 }
67 }
68 Ok(Some(crate::serde_util::device_correct_errors(builder).build().map_err(|err| {
69 ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
70 })?))
71 }
72 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
73 "expected start object or null",
74 )),
75 }
76}