aws_sdk_backup/protocol_serde/
shape_copy_action.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_copy_action(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::CopyAction,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.lifecycle {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("Lifecycle").start_object();
9        crate::protocol_serde::shape_lifecycle::ser_lifecycle(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    {
13        object
14            .key("DestinationBackupVaultArn")
15            .string(input.destination_backup_vault_arn.as_str());
16    }
17    Ok(())
18}
19
20pub(crate) fn de_copy_action<'a, I>(
21    tokens: &mut ::std::iter::Peekable<I>,
22) -> ::std::result::Result<Option<crate::types::CopyAction>, ::aws_smithy_json::deserialize::error::DeserializeError>
23where
24    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
25{
26    match tokens.next().transpose()? {
27        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
28        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
29            #[allow(unused_mut)]
30            let mut builder = crate::types::builders::CopyActionBuilder::default();
31            loop {
32                match tokens.next().transpose()? {
33                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
34                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
35                        "Lifecycle" => {
36                            builder = builder.set_lifecycle(crate::protocol_serde::shape_lifecycle::de_lifecycle(tokens)?);
37                        }
38                        "DestinationBackupVaultArn" => {
39                            builder = builder.set_destination_backup_vault_arn(
40                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
41                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
42                                    .transpose()?,
43                            );
44                        }
45                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
46                    },
47                    other => {
48                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
49                            "expected object key or end object, found: {:?}",
50                            other
51                        )))
52                    }
53                }
54            }
55            Ok(Some(crate::serde_util::copy_action_correct_errors(builder).build().map_err(|err| {
56                ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
57            })?))
58        }
59        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
60            "expected start object or null",
61        )),
62    }
63}