pub fn ser_web_crawler_configuration(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::WebCrawlerConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
if let Some(var_1) = &input.urls {
#[allow(unused_mut)]
let mut object_2 = object.key("Urls").start_object();
crate::protocol_serde::shape_urls::ser_urls(&mut object_2, var_1)?;
object_2.finish();
}
if let Some(var_3) = &input.crawl_depth {
object.key("CrawlDepth").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_3).into()),
);
}
if let Some(var_4) = &input.max_links_per_page {
object.key("MaxLinksPerPage").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_4).into()),
);
}
if let Some(var_5) = &input.max_content_size_per_page_in_mega_bytes {
object.key("MaxContentSizePerPageInMegaBytes").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::Float((*var_5).into()),
);
}
if let Some(var_6) = &input.max_urls_per_minute_crawl_rate {
object.key("MaxUrlsPerMinuteCrawlRate").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_6).into()),
);
}
if let Some(var_7) = &input.url_inclusion_patterns {
let mut array_8 = object.key("UrlInclusionPatterns").start_array();
for item_9 in var_7 {
{
array_8.value().string(item_9.as_str());
}
}
array_8.finish();
}
if let Some(var_10) = &input.url_exclusion_patterns {
let mut array_11 = object.key("UrlExclusionPatterns").start_array();
for item_12 in var_10 {
{
array_11.value().string(item_12.as_str());
}
}
array_11.finish();
}
if let Some(var_13) = &input.proxy_configuration {
#[allow(unused_mut)]
let mut object_14 = object.key("ProxyConfiguration").start_object();
crate::protocol_serde::shape_proxy_configuration::ser_proxy_configuration(&mut object_14, var_13)?;
object_14.finish();
}
if let Some(var_15) = &input.authentication_configuration {
#[allow(unused_mut)]
let mut object_16 = object.key("AuthenticationConfiguration").start_object();
crate::protocol_serde::shape_authentication_configuration::ser_authentication_configuration(&mut object_16, var_15)?;
object_16.finish();
}
Ok(())
}
pub(crate) fn de_web_crawler_configuration<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
depth: u32,
) -> ::std::result::Result<Option<crate::types::WebCrawlerConfiguration>, ::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::WebCrawlerConfigurationBuilder::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() {
"Urls" => {
builder = builder.set_urls(crate::protocol_serde::shape_urls::de_urls(tokens, _value, depth + 1)?);
}
"CrawlDepth" => {
builder = builder.set_crawl_depth(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"MaxLinksPerPage" => {
builder = builder.set_max_links_per_page(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"MaxContentSizePerPageInMegaBytes" => {
builder = builder.set_max_content_size_per_page_in_mega_bytes(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f32_lossy()),
);
}
"MaxUrlsPerMinuteCrawlRate" => {
builder = builder.set_max_urls_per_minute_crawl_rate(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"UrlInclusionPatterns" => {
builder = builder.set_url_inclusion_patterns(
crate::protocol_serde::shape_data_source_inclusions_exclusions_strings::de_data_source_inclusions_exclusions_strings(tokens, _value, depth + 1)?
);
}
"UrlExclusionPatterns" => {
builder = builder.set_url_exclusion_patterns(
crate::protocol_serde::shape_data_source_inclusions_exclusions_strings::de_data_source_inclusions_exclusions_strings(tokens, _value, depth + 1)?
);
}
"ProxyConfiguration" => {
builder = builder.set_proxy_configuration(crate::protocol_serde::shape_proxy_configuration::de_proxy_configuration(
tokens,
_value,
depth + 1,
)?);
}
"AuthenticationConfiguration" => {
builder = builder.set_authentication_configuration(
crate::protocol_serde::shape_authentication_configuration::de_authentication_configuration(
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::web_crawler_configuration_correct_errors(builder).build()))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}