aws_sdk_chimesdkvoice/protocol_serde/
shape_streaming_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_streaming_configuration<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::StreamingConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::StreamingConfigurationBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "DataRetentionInHours" => {
18                            builder = builder.set_data_retention_in_hours(
19                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
20                                    .map(i32::try_from)
21                                    .transpose()?,
22                            );
23                        }
24                        "Disabled" => {
25                            builder = builder.set_disabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
26                        }
27                        "StreamingNotificationTargets" => {
28                            builder = builder.set_streaming_notification_targets(
29                                crate::protocol_serde::shape_streaming_notification_target_list::de_streaming_notification_target_list(tokens)?,
30                            );
31                        }
32                        "MediaInsightsConfiguration" => {
33                            builder = builder.set_media_insights_configuration(
34                                crate::protocol_serde::shape_media_insights_configuration::de_media_insights_configuration(tokens)?,
35                            );
36                        }
37                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
38                    },
39                    other => {
40                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
41                            "expected object key or end object, found: {other:?}"
42                        )))
43                    }
44                }
45            }
46            Ok(Some(crate::serde_util::streaming_configuration_correct_errors(builder).build().map_err(
47                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
48            )?))
49        }
50        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
51            "expected start object or null",
52        )),
53    }
54}
55
56pub fn ser_streaming_configuration(
57    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
58    input: &crate::types::StreamingConfiguration,
59) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
60    {
61        object.key("DataRetentionInHours").number(
62            #[allow(clippy::useless_conversion)]
63            ::aws_smithy_types::Number::NegInt((input.data_retention_in_hours).into()),
64        );
65    }
66    {
67        object.key("Disabled").boolean(input.disabled);
68    }
69    if let Some(var_1) = &input.streaming_notification_targets {
70        let mut array_2 = object.key("StreamingNotificationTargets").start_array();
71        for item_3 in var_1 {
72            {
73                #[allow(unused_mut)]
74                let mut object_4 = array_2.value().start_object();
75                crate::protocol_serde::shape_streaming_notification_target::ser_streaming_notification_target(&mut object_4, item_3)?;
76                object_4.finish();
77            }
78        }
79        array_2.finish();
80    }
81    if let Some(var_5) = &input.media_insights_configuration {
82        #[allow(unused_mut)]
83        let mut object_6 = object.key("MediaInsightsConfiguration").start_object();
84        crate::protocol_serde::shape_media_insights_configuration::ser_media_insights_configuration(&mut object_6, var_5)?;
85        object_6.finish();
86    }
87    Ok(())
88}