aws_sdk_mediapackagev2/protocol_serde/
shape_dash_program_information.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_dash_program_information(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::DashProgramInformation,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.title {
7        object.key("Title").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.source {
10        object.key("Source").string(var_2.as_str());
11    }
12    if let Some(var_3) = &input.copyright {
13        object.key("Copyright").string(var_3.as_str());
14    }
15    if let Some(var_4) = &input.language_code {
16        object.key("LanguageCode").string(var_4.as_str());
17    }
18    if let Some(var_5) = &input.more_information_url {
19        object.key("MoreInformationUrl").string(var_5.as_str());
20    }
21    Ok(())
22}
23
24pub(crate) fn de_dash_program_information<'a, I>(
25    tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::DashProgramInformation>, ::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::DashProgramInformationBuilder::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                        "Title" => {
40                            builder = builder.set_title(
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                        "Source" => {
47                            builder = builder.set_source(
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                        "Copyright" => {
54                            builder = builder.set_copyright(
55                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
56                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
57                                    .transpose()?,
58                            );
59                        }
60                        "LanguageCode" => {
61                            builder = builder.set_language_code(
62                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
63                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
64                                    .transpose()?,
65                            );
66                        }
67                        "MoreInformationUrl" => {
68                            builder = builder.set_more_information_url(
69                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
70                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
71                                    .transpose()?,
72                            );
73                        }
74                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
75                    },
76                    other => {
77                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
78                            "expected object key or end object, found: {:?}",
79                            other
80                        )))
81                    }
82                }
83            }
84            Ok(Some(builder.build()))
85        }
86        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
87            "expected start object or null",
88        )),
89    }
90}