aws_sdk_mediapackagev2/protocol_serde/
shape_input_switch_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_input_switch_configuration<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::InputSwitchConfiguration>, ::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::InputSwitchConfigurationBuilder::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                        "MQCSInputSwitching" => {
18                            builder = builder.set_mqcs_input_switching(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
19                        }
20                        "PreferredInput" => {
21                            builder = builder.set_preferred_input(
22                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
23                                    .map(i32::try_from)
24                                    .transpose()?,
25                            );
26                        }
27                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
28                    },
29                    other => {
30                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
31                            "expected object key or end object, found: {:?}",
32                            other
33                        )))
34                    }
35                }
36            }
37            Ok(Some(builder.build()))
38        }
39        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
40            "expected start object or null",
41        )),
42    }
43}
44
45pub fn ser_input_switch_configuration(
46    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
47    input: &crate::types::InputSwitchConfiguration,
48) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
49    if let Some(var_1) = &input.mqcs_input_switching {
50        object.key("MQCSInputSwitching").boolean(*var_1);
51    }
52    if let Some(var_2) = &input.preferred_input {
53        object.key("PreferredInput").number(
54            #[allow(clippy::useless_conversion)]
55            ::aws_smithy_types::Number::NegInt((*var_2).into()),
56        );
57    }
58    Ok(())
59}