aws-sdk-bedrock 1.129.0

AWS SDK for Amazon Bedrock
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_external_sources_generation_configuration(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::ExternalSourcesGenerationConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.prompt_template {
        #[allow(unused_mut)]
        let mut object_2 = object.key("promptTemplate").start_object();
        crate::protocol_serde::shape_prompt_template::ser_prompt_template(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.guardrail_configuration {
        #[allow(unused_mut)]
        let mut object_4 = object.key("guardrailConfiguration").start_object();
        crate::protocol_serde::shape_guardrail_configuration::ser_guardrail_configuration(&mut object_4, var_3)?;
        object_4.finish();
    }
    if let Some(var_5) = &input.kb_inference_config {
        #[allow(unused_mut)]
        let mut object_6 = object.key("kbInferenceConfig").start_object();
        crate::protocol_serde::shape_kb_inference_config::ser_kb_inference_config(&mut object_6, var_5)?;
        object_6.finish();
    }
    if let Some(var_7) = &input.additional_model_request_fields {
        #[allow(unused_mut)]
        let mut object_8 = object.key("additionalModelRequestFields").start_object();
        for (key_9, value_10) in var_7 {
            {
                object_8.key(key_9.as_str()).document(value_10);
            }
        }
        object_8.finish();
    }
    Ok(())
}

pub(crate) fn de_external_sources_generation_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
) -> ::std::result::Result<Option<crate::types::ExternalSourcesGenerationConfiguration>, ::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::ExternalSourcesGenerationConfigurationBuilder::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() {
                        "promptTemplate" => {
                            builder = builder.set_prompt_template(crate::protocol_serde::shape_prompt_template::de_prompt_template(tokens)?);
                        }
                        "guardrailConfiguration" => {
                            builder = builder.set_guardrail_configuration(
                                crate::protocol_serde::shape_guardrail_configuration::de_guardrail_configuration(tokens)?,
                            );
                        }
                        "kbInferenceConfig" => {
                            builder =
                                builder.set_kb_inference_config(crate::protocol_serde::shape_kb_inference_config::de_kb_inference_config(tokens)?);
                        }
                        "additionalModelRequestFields" => {
                            builder = builder.set_additional_model_request_fields(
                                crate::protocol_serde::shape_additional_model_request_fields::de_additional_model_request_fields(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",
        )),
    }
}