aws_sdk_sagemaker/protocol_serde/
shape_search.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_search_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::search::SearchOutput, crate::operation::search::SearchError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::search::SearchError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 Err(crate::operation::search::SearchError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_search_http_response(
18 _response_status: u16,
19 _response_headers: &::aws_smithy_runtime_api::http::Headers,
20 _response_body: &[u8],
21) -> std::result::Result<crate::operation::search::SearchOutput, crate::operation::search::SearchError> {
22 Ok({
23 #[allow(unused_mut)]
24 let mut output = crate::operation::search::builders::SearchOutputBuilder::default();
25 output = crate::protocol_serde::shape_search::de_search(_response_body, output).map_err(crate::operation::search::SearchError::unhandled)?;
26 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
27 output.build()
28 })
29}
30
31pub fn ser_search_input(
32 input: &crate::operation::search::SearchInput,
33) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
34 let mut out = String::new();
35 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
36 crate::protocol_serde::shape_search_input::ser_search_input_input(&mut object, input)?;
37 object.finish();
38 Ok(::aws_smithy_types::body::SdkBody::from(out))
39}
40
41pub(crate) fn de_search(
42 value: &[u8],
43 mut builder: crate::operation::search::builders::SearchOutputBuilder,
44) -> ::std::result::Result<crate::operation::search::builders::SearchOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
45 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
46 let tokens = &mut tokens_owned;
47 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
48 loop {
49 match tokens.next().transpose()? {
50 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
51 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
52 "Results" => {
53 builder = builder.set_results(crate::protocol_serde::shape_search_results_list::de_search_results_list(tokens)?);
54 }
55 "NextToken" => {
56 builder = builder.set_next_token(
57 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
58 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
59 .transpose()?,
60 );
61 }
62 "TotalHits" => {
63 builder = builder.set_total_hits(crate::protocol_serde::shape_total_hits::de_total_hits(tokens)?);
64 }
65 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
66 },
67 other => {
68 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
69 "expected object key or end object, found: {:?}",
70 other
71 )))
72 }
73 }
74 }
75 if tokens.next().is_some() {
76 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
77 "found more JSON tokens after completing parsing",
78 ));
79 }
80 Ok(builder)
81}