1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | pub fn ser_guardrail_converse_text_block(
|
3 + | object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
|
4 + | input: &crate::types::GuardrailConverseTextBlock,
|
5 + | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
|
6 + | {
|
7 + | object.key("text").string(input.text.as_str());
|
8 + | }
|
9 + | if let Some(var_1) = &input.qualifiers {
|
10 + | let mut array_2 = object.key("qualifiers").start_array();
|
11 + | for item_3 in var_1 {
|
12 + | {
|
13 + | array_2.value().string(item_3.as_str());
|
14 + | }
|
15 + | }
|
16 + | array_2.finish();
|
17 + | }
|
18 + | Ok(())
|
19 + | }
|
20 + |
|
21 + | pub(crate) fn de_guardrail_converse_text_block<'a, I>(
|
22 + | tokens: &mut ::std::iter::Peekable<I>,
|
23 + | ) -> ::std::result::Result<Option<crate::types::GuardrailConverseTextBlock>, ::aws_smithy_json::deserialize::error::DeserializeError>
|
24 + | where
|
25 + | I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
|
26 + | {
|
27 + | match tokens.next().transpose()? {
|
28 + | Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
|
29 + | Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
|
30 + | #[allow(unused_mut)]
|
31 + | let mut builder = crate::types::builders::GuardrailConverseTextBlockBuilder::default();
|
32 + | loop {
|
33 + | match tokens.next().transpose()? {
|
34 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
35 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
36 + | match key.to_unescaped()?.as_ref() {
|
37 + | "text" => {
|
38 + | builder = builder.set_text(
|
39 + | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
40 + | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
41 + | .transpose()?,
|
42 + | );
|
43 + | }
|
44 + | "qualifiers" => {
|
45 + | builder = builder.set_qualifiers(
|
46 + | crate::protocol_serde::shape_guardrail_converse_content_qualifier_list::de_guardrail_converse_content_qualifier_list(tokens)?
|
47 + | );
|
48 + | }
|
49 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
50 + | }
|
51 + | }
|
52 + | other => {
|
53 + | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
54 + | "expected object key or end object, found: {:?}",
|
55 + | other
|
56 + | )))
|
57 + | }
|
58 + | }
|
59 + | }
|
60 + | Ok(Some(
|
61 + | crate::serde_util::guardrail_converse_text_block_correct_errors(builder)
|
62 + | .build()
|
63 + | .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
|
64 + | ))
|
65 + | }
|
66 + | _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
67 + | "expected start object or null",
|
68 + | )),
|
69 + | }
|
70 + | }
|