aws-sdk-bedrock 1.145.0

AWS SDK for Amazon Bedrock
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_human_evaluation_config(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::HumanEvaluationConfig,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.human_workflow_config {
        #[allow(unused_mut)]
        let mut object_2 = object.key("humanWorkflowConfig").start_object();
        crate::protocol_serde::shape_human_workflow_config::ser_human_workflow_config(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.custom_metrics {
        let mut array_4 = object.key("customMetrics").start_array();
        for item_5 in var_3 {
            {
                #[allow(unused_mut)]
                let mut object_6 = array_4.value().start_object();
                crate::protocol_serde::shape_human_evaluation_custom_metric::ser_human_evaluation_custom_metric(&mut object_6, item_5)?;
                object_6.finish();
            }
        }
        array_4.finish();
    }
    {
        let mut array_7 = object.key("datasetMetricConfigs").start_array();
        for item_8 in &input.dataset_metric_configs {
            {
                #[allow(unused_mut)]
                let mut object_9 = array_7.value().start_object();
                crate::protocol_serde::shape_evaluation_dataset_metric_config::ser_evaluation_dataset_metric_config(&mut object_9, item_8)?;
                object_9.finish();
            }
        }
        array_7.finish();
    }
    Ok(())
}

pub(crate) fn de_human_evaluation_config<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
    depth: u32,
) -> ::std::result::Result<Option<crate::types::HumanEvaluationConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    if depth >= 128u32 {
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "maximum nesting depth exceeded",
        ));
    }
    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::HumanEvaluationConfigBuilder::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() {
                        "humanWorkflowConfig" => {
                            builder = builder.set_human_workflow_config(
                                crate::protocol_serde::shape_human_workflow_config::de_human_workflow_config(tokens, _value, depth + 1)?,
                            );
                        }
                        "customMetrics" => {
                            builder = builder.set_custom_metrics(
                                crate::protocol_serde::shape_human_evaluation_custom_metrics::de_human_evaluation_custom_metrics(
                                    tokens,
                                    _value,
                                    depth + 1,
                                )?,
                            );
                        }
                        "datasetMetricConfigs" => {
                            builder = builder.set_dataset_metric_configs(
                                crate::protocol_serde::shape_evaluation_dataset_metric_configs::de_evaluation_dataset_metric_configs(
                                    tokens,
                                    _value,
                                    depth + 1,
                                )?,
                            );
                        }
                        _ => ::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(crate::serde_util::human_evaluation_config_correct_errors(builder).build().map_err(
                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
            )?))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}