pub fn ser_vector_search_reranking_configuration(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::VectorSearchRerankingConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("type").string(input.r#type.as_str());
}
if let Some(var_1) = &input.bedrock_reranking_configuration {
#[allow(unused_mut)]
let mut object_2 = object.key("bedrockRerankingConfiguration").start_object();
crate::protocol_serde::shape_vector_search_bedrock_reranking_configuration::ser_vector_search_bedrock_reranking_configuration(
&mut object_2,
var_1,
)?;
object_2.finish();
}
Ok(())
}
pub(crate) fn de_vector_search_reranking_configuration<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> ::std::result::Result<Option<crate::types::VectorSearchRerankingConfiguration>, ::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::VectorSearchRerankingConfigurationBuilder::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() {
"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::VectorSearchRerankingConfigurationType::from(u.as_ref()))
})
.transpose()?,
);
}
"bedrockRerankingConfiguration" => {
builder = builder.set_bedrock_reranking_configuration(
crate::protocol_serde::shape_vector_search_bedrock_reranking_configuration::de_vector_search_bedrock_reranking_configuration(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(
crate::serde_util::vector_search_reranking_configuration_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",
)),
}
}