6 6 | match input {
|
7 7 | crate::types::ContentBlock::Text(inner) => {
|
8 8 | object_3.key("text").string(inner.as_str());
|
9 9 | }
|
10 10 | crate::types::ContentBlock::Image(inner) => {
|
11 11 | #[allow(unused_mut)]
|
12 12 | let mut object_1 = object_3.key("image").start_object();
|
13 13 | crate::protocol_serde::shape_image_block::ser_image_block(&mut object_1, inner)?;
|
14 14 | object_1.finish();
|
15 15 | }
|
16 - | crate::types::ContentBlock::Document(inner) => {
|
17 - | #[allow(unused_mut)]
|
18 - | let mut object_2 = object_3.key("document").start_object();
|
19 - | crate::protocol_serde::shape_document_block::ser_document_block(&mut object_2, inner)?;
|
20 - | object_2.finish();
|
21 - | }
|
22 - | crate::types::ContentBlock::Video(inner) => {
|
23 - | #[allow(unused_mut)]
|
24 - | let mut object_3 = object_3.key("video").start_object();
|
25 - | crate::protocol_serde::shape_video_block::ser_video_block(&mut object_3, inner)?;
|
26 - | object_3.finish();
|
27 - | }
|
28 16 | crate::types::ContentBlock::ToolUse(inner) => {
|
29 17 | #[allow(unused_mut)]
|
30 - | let mut object_4 = object_3.key("toolUse").start_object();
|
31 - | crate::protocol_serde::shape_tool_use_block::ser_tool_use_block(&mut object_4, inner)?;
|
32 - | object_4.finish();
|
18 + | let mut object_2 = object_3.key("toolUse").start_object();
|
19 + | crate::protocol_serde::shape_tool_use_block::ser_tool_use_block(&mut object_2, inner)?;
|
20 + | object_2.finish();
|
33 21 | }
|
34 22 | crate::types::ContentBlock::ToolResult(inner) => {
|
35 23 | #[allow(unused_mut)]
|
36 - | let mut object_5 = object_3.key("toolResult").start_object();
|
37 - | crate::protocol_serde::shape_tool_result_block::ser_tool_result_block(&mut object_5, inner)?;
|
38 - | object_5.finish();
|
39 - | }
|
40 - | crate::types::ContentBlock::GuardContent(inner) => {
|
41 - | #[allow(unused_mut)]
|
42 - | let mut object_6 = object_3.key("guardContent").start_object();
|
43 - | crate::protocol_serde::shape_guardrail_converse_content_block::ser_guardrail_converse_content_block(&mut object_6, inner)?;
|
44 - | object_6.finish();
|
45 - | }
|
46 - | crate::types::ContentBlock::CachePoint(inner) => {
|
47 - | #[allow(unused_mut)]
|
48 - | let mut object_7 = object_3.key("cachePoint").start_object();
|
49 - | crate::protocol_serde::shape_cache_point_block::ser_cache_point_block(&mut object_7, inner)?;
|
50 - | object_7.finish();
|
51 - | }
|
52 - | crate::types::ContentBlock::ReasoningContent(inner) => {
|
53 - | #[allow(unused_mut)]
|
54 - | let mut object_8 = object_3.key("reasoningContent").start_object();
|
55 - | crate::protocol_serde::shape_reasoning_content_block::ser_reasoning_content_block(&mut object_8, inner)?;
|
56 - | object_8.finish();
|
57 - | }
|
58 - | crate::types::ContentBlock::CitationsContent(inner) => {
|
59 - | #[allow(unused_mut)]
|
60 - | let mut object_9 = object_3.key("citationsContent").start_object();
|
61 - | crate::protocol_serde::shape_citations_content_block::ser_citations_content_block(&mut object_9, inner)?;
|
62 - | object_9.finish();
|
24 + | let mut object_3 = object_3.key("toolResult").start_object();
|
25 + | crate::protocol_serde::shape_tool_result_block::ser_tool_result_block(&mut object_3, inner)?;
|
26 + | object_3.finish();
|
63 27 | }
|
64 28 | crate::types::ContentBlock::Unknown => return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("ContentBlock")),
|
65 29 | }
|
66 30 | Ok(())
|
67 31 | }
|
68 32 |
|
69 33 | pub(crate) fn de_content_block<'a, I>(
|
70 34 | tokens: &mut ::std::iter::Peekable<I>,
|
71 35 | ) -> ::std::result::Result<Option<crate::types::ContentBlock>, ::aws_smithy_json::deserialize::error::DeserializeError>
|
72 36 | where
|
73 37 | I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
|
74 38 | {
|
75 39 | let mut variant = None;
|
76 40 | match tokens.next().transpose()? {
|
77 41 | Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
|
78 42 | Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
|
79 43 | match tokens.next().transpose()? {
|
80 44 | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
81 45 | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
82 46 | if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
|
83 47 | tokens.peek()
|
84 48 | {
|
85 49 | let _ = tokens.next().expect("peek returned a token")?;
|
86 50 | continue;
|
87 51 | }
|
88 52 | let key = key.to_unescaped()?;
|
89 53 | if key == "__type" {
|
90 54 | ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
|
91 55 | continue;
|
92 56 | }
|
93 57 | if variant.is_some() {
|
94 58 | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
95 59 | "encountered mixed variants in union",
|
96 60 | ));
|
97 61 | }
|
98 62 | variant = match key.as_ref() {
|
99 63 | "text" => Some(crate::types::ContentBlock::Text(
|
100 64 | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
101 65 | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
102 66 | .transpose()?
|
103 67 | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'text' cannot be null"))?,
|
104 68 | )),
|
105 69 | "image" => Some(crate::types::ContentBlock::Image(
|
106 70 | crate::protocol_serde::shape_image_block::de_image_block(tokens)?
|
107 71 | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'image' cannot be null"))?,
|
108 72 | )),
|
109 - | "document" => Some(crate::types::ContentBlock::Document(
|
110 - | crate::protocol_serde::shape_document_block::de_document_block(tokens)?.ok_or_else(|| {
|
111 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'document' cannot be null")
|
112 - | })?,
|
113 - | )),
|
114 - | "video" => Some(crate::types::ContentBlock::Video(
|
115 - | crate::protocol_serde::shape_video_block::de_video_block(tokens)?
|
116 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'video' cannot be null"))?,
|
117 - | )),
|
118 73 | "toolUse" => Some(crate::types::ContentBlock::ToolUse(
|
119 74 | crate::protocol_serde::shape_tool_use_block::de_tool_use_block(tokens)?.ok_or_else(|| {
|
120 75 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'toolUse' cannot be null")
|
121 76 | })?,
|
122 77 | )),
|
123 78 | "toolResult" => Some(crate::types::ContentBlock::ToolResult(
|
124 79 | crate::protocol_serde::shape_tool_result_block::de_tool_result_block(tokens)?.ok_or_else(|| {
|
125 80 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'toolResult' cannot be null")
|
126 81 | })?,
|
127 82 | )),
|
128 - | "guardContent" => Some(crate::types::ContentBlock::GuardContent(
|
129 - | crate::protocol_serde::shape_guardrail_converse_content_block::de_guardrail_converse_content_block(tokens)?.ok_or_else(
|
130 - | || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'guardContent' cannot be null"),
|
131 - | )?,
|
132 - | )),
|
133 - | "cachePoint" => Some(crate::types::ContentBlock::CachePoint(
|
134 - | crate::protocol_serde::shape_cache_point_block::de_cache_point_block(tokens)?.ok_or_else(|| {
|
135 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'cachePoint' cannot be null")
|
136 - | })?,
|
137 - | )),
|
138 - | "reasoningContent" => Some(crate::types::ContentBlock::ReasoningContent(
|
139 - | crate::protocol_serde::shape_reasoning_content_block::de_reasoning_content_block(tokens)?.ok_or_else(|| {
|
140 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'reasoningContent' cannot be null")
|
141 - | })?,
|
142 - | )),
|
143 - | "citationsContent" => Some(crate::types::ContentBlock::CitationsContent(
|
144 - | crate::protocol_serde::shape_citations_content_block::de_citations_content_block(tokens)?.ok_or_else(|| {
|
145 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'citationsContent' cannot be null")
|
146 - | })?,
|
147 - | )),
|
148 83 | _ => {
|
149 84 | ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
|
150 85 | Some(crate::types::ContentBlock::Unknown)
|
151 86 | }
|
152 87 | };
|
153 88 | }
|
154 89 | other => {
|
155 90 | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
156 91 | "expected object key or end object, found: {:?}",
|
157 92 | other
|