aws-sdk-appsync 1.111.0

AWS SDK for AWS AppSync
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_data_source<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::DataSource>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder = crate::types::builders::DataSourceBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
                        "dataSourceArn" => {
                            builder = builder.set_data_source_arn(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "name" => {
                            builder = builder.set_name(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "description" => {
                            builder = builder.set_description(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "type" => {
                            builder = builder.set_type(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::DataSourceType::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "serviceRoleArn" => {
                            builder = builder.set_service_role_arn(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "dynamodbConfig" => {
                            builder = builder.set_dynamodb_config(
                                crate::protocol_serde::shape_dynamodb_data_source_config::de_dynamodb_data_source_config(tokens, _value)?,
                            );
                        }
                        "lambdaConfig" => {
                            builder = builder.set_lambda_config(
                                crate::protocol_serde::shape_lambda_data_source_config::de_lambda_data_source_config(tokens, _value)?,
                            );
                        }
                        "elasticsearchConfig" => {
                            builder = builder.set_elasticsearch_config(
                                crate::protocol_serde::shape_elasticsearch_data_source_config::de_elasticsearch_data_source_config(tokens, _value)?,
                            );
                        }
                        "openSearchServiceConfig" => {
                            builder = builder.set_open_search_service_config(
                                crate::protocol_serde::shape_open_search_service_data_source_config::de_open_search_service_data_source_config(
                                    tokens, _value,
                                )?,
                            );
                        }
                        "httpConfig" => {
                            builder = builder.set_http_config(crate::protocol_serde::shape_http_data_source_config::de_http_data_source_config(
                                tokens, _value,
                            )?);
                        }
                        "relationalDatabaseConfig" => {
                            builder = builder.set_relational_database_config(
                                crate::protocol_serde::shape_relational_database_data_source_config::de_relational_database_data_source_config(
                                    tokens, _value,
                                )?,
                            );
                        }
                        "eventBridgeConfig" => {
                            builder = builder.set_event_bridge_config(
                                crate::protocol_serde::shape_event_bridge_data_source_config::de_event_bridge_data_source_config(tokens, _value)?,
                            );
                        }
                        "metricsConfig" => {
                            builder = builder.set_metrics_config(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::DataSourceLevelMetricsConfig::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
                    },
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
            Ok(Some(builder.build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}