aws_sdk_wafv2/protocol_serde/
shape_regex_match_statement.rs1pub fn ser_regex_match_statement(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::RegexMatchStatement,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("RegexString").string(input.regex_string.as_str());
8 }
9 if let Some(var_1) = &input.field_to_match {
10 #[allow(unused_mut)]
11 let mut object_2 = object.key("FieldToMatch").start_object();
12 crate::protocol_serde::shape_field_to_match::ser_field_to_match(&mut object_2, var_1)?;
13 object_2.finish();
14 }
15 {
16 let mut array_3 = object.key("TextTransformations").start_array();
17 for item_4 in &input.text_transformations {
18 {
19 #[allow(unused_mut)]
20 let mut object_5 = array_3.value().start_object();
21 crate::protocol_serde::shape_text_transformation::ser_text_transformation(&mut object_5, item_4)?;
22 object_5.finish();
23 }
24 }
25 array_3.finish();
26 }
27 Ok(())
28}
29
30pub(crate) fn de_regex_match_statement<'a, I>(
31 tokens: &mut ::std::iter::Peekable<I>,
32) -> ::std::result::Result<Option<crate::types::RegexMatchStatement>, ::aws_smithy_json::deserialize::error::DeserializeError>
33where
34 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
35{
36 match tokens.next().transpose()? {
37 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
38 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
39 #[allow(unused_mut)]
40 let mut builder = crate::types::builders::RegexMatchStatementBuilder::default();
41 loop {
42 match tokens.next().transpose()? {
43 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
44 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
45 "RegexString" => {
46 builder = builder.set_regex_string(
47 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
49 .transpose()?,
50 );
51 }
52 "FieldToMatch" => {
53 builder = builder.set_field_to_match(crate::protocol_serde::shape_field_to_match::de_field_to_match(tokens)?);
54 }
55 "TextTransformations" => {
56 builder =
57 builder.set_text_transformations(crate::protocol_serde::shape_text_transformations::de_text_transformations(tokens)?);
58 }
59 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
60 },
61 other => {
62 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
63 "expected object key or end object, found: {:?}",
64 other
65 )))
66 }
67 }
68 }
69 Ok(Some(crate::serde_util::regex_match_statement_correct_errors(builder).build().map_err(
70 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
71 )?))
72 }
73 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
74 "expected start object or null",
75 )),
76 }
77}