aws_sdk_grafana/protocol_serde/
shape_update_instruction.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_update_instruction(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::UpdateInstruction,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("action").string(input.action.as_str());
8    }
9    {
10        object.key("role").string(input.role.as_str());
11    }
12    {
13        let mut array_1 = object.key("users").start_array();
14        for item_2 in &input.users {
15            {
16                #[allow(unused_mut)]
17                let mut object_3 = array_1.value().start_object();
18                crate::protocol_serde::shape_user::ser_user(&mut object_3, item_2)?;
19                object_3.finish();
20            }
21        }
22        array_1.finish();
23    }
24    Ok(())
25}
26
27pub(crate) fn de_update_instruction<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::UpdateInstruction>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33    match tokens.next().transpose()? {
34        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36            #[allow(unused_mut)]
37            let mut builder = crate::types::builders::UpdateInstructionBuilder::default();
38            loop {
39                match tokens.next().transpose()? {
40                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42                        "action" => {
43                            builder = builder.set_action(
44                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45                                    .map(|s| s.to_unescaped().map(|u| crate::types::UpdateAction::from(u.as_ref())))
46                                    .transpose()?,
47                            );
48                        }
49                        "role" => {
50                            builder = builder.set_role(
51                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52                                    .map(|s| s.to_unescaped().map(|u| crate::types::Role::from(u.as_ref())))
53                                    .transpose()?,
54                            );
55                        }
56                        "users" => {
57                            builder = builder.set_users(crate::protocol_serde::shape_user_list::de_user_list(tokens)?);
58                        }
59                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
60                    },
61                    other => {
62                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
63                            "expected object key or end object, found: {:?}",
64                            other
65                        )))
66                    }
67                }
68            }
69            Ok(Some(crate::serde_util::update_instruction_correct_errors(builder).build().map_err(
70                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
71            )?))
72        }
73        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
74            "expected start object or null",
75        )),
76    }
77}