aws_sdk_mediapackagev2/protocol_serde/
shape_speke_key_provider.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_speke_key_provider<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::SpekeKeyProvider>, ::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::SpekeKeyProviderBuilder::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                        "EncryptionContractConfiguration" => {
18                            builder = builder.set_encryption_contract_configuration(
19                                crate::protocol_serde::shape_encryption_contract_configuration::de_encryption_contract_configuration(tokens)?,
20                            );
21                        }
22                        "ResourceId" => {
23                            builder = builder.set_resource_id(
24                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
25                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
26                                    .transpose()?,
27                            );
28                        }
29                        "DrmSystems" => {
30                            builder = builder.set_drm_systems(crate::protocol_serde::shape_drm_systems::de_drm_systems(tokens)?);
31                        }
32                        "RoleArn" => {
33                            builder = builder.set_role_arn(
34                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
35                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
36                                    .transpose()?,
37                            );
38                        }
39                        "Url" => {
40                            builder = builder.set_url(
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                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
47                    },
48                    other => {
49                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
50                            "expected object key or end object, found: {other:?}"
51                        )))
52                    }
53                }
54            }
55            Ok(Some(crate::serde_util::speke_key_provider_correct_errors(builder).build().map_err(
56                |err| ::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}
64
65pub fn ser_speke_key_provider(
66    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
67    input: &crate::types::SpekeKeyProvider,
68) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
69    if let Some(var_1) = &input.encryption_contract_configuration {
70        #[allow(unused_mut)]
71        let mut object_2 = object.key("EncryptionContractConfiguration").start_object();
72        crate::protocol_serde::shape_encryption_contract_configuration::ser_encryption_contract_configuration(&mut object_2, var_1)?;
73        object_2.finish();
74    }
75    {
76        object.key("ResourceId").string(input.resource_id.as_str());
77    }
78    {
79        let mut array_3 = object.key("DrmSystems").start_array();
80        for item_4 in &input.drm_systems {
81            {
82                array_3.value().string(item_4.as_str());
83            }
84        }
85        array_3.finish();
86    }
87    {
88        object.key("RoleArn").string(input.role_arn.as_str());
89    }
90    {
91        object.key("Url").string(input.url.as_str());
92    }
93    Ok(())
94}