aws-sdk-licensemanager 1.95.0

AWS SDK for AWS License Manager
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_license_configuration_rule_statement(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::LicenseConfigurationRuleStatement,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.and_rule_statement {
        #[allow(unused_mut)]
        let mut object_2 = object.key("AndRuleStatement").start_object();
        crate::protocol_serde::shape_and_rule_statement::ser_and_rule_statement(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.or_rule_statement {
        #[allow(unused_mut)]
        let mut object_4 = object.key("OrRuleStatement").start_object();
        crate::protocol_serde::shape_or_rule_statement::ser_or_rule_statement(&mut object_4, var_3)?;
        object_4.finish();
    }
    if let Some(var_5) = &input.matching_rule_statement {
        #[allow(unused_mut)]
        let mut object_6 = object.key("MatchingRuleStatement").start_object();
        crate::protocol_serde::shape_matching_rule_statement::ser_matching_rule_statement(&mut object_6, var_5)?;
        object_6.finish();
    }
    Ok(())
}

pub(crate) fn de_license_configuration_rule_statement<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
) -> ::std::result::Result<Option<crate::types::LicenseConfigurationRuleStatement>, ::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::LicenseConfigurationRuleStatementBuilder::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() {
                        "AndRuleStatement" => {
                            builder = builder.set_and_rule_statement(crate::protocol_serde::shape_and_rule_statement::de_and_rule_statement(tokens)?);
                        }
                        "OrRuleStatement" => {
                            builder = builder.set_or_rule_statement(crate::protocol_serde::shape_or_rule_statement::de_or_rule_statement(tokens)?);
                        }
                        "MatchingRuleStatement" => {
                            builder = builder.set_matching_rule_statement(
                                crate::protocol_serde::shape_matching_rule_statement::de_matching_rule_statement(tokens)?,
                            );
                        }
                        _ => ::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",
        )),
    }
}