aws_sdk_sagemaker/protocol_serde/
shape_get_search_suggestions.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_search_suggestions_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::get_search_suggestions::GetSearchSuggestionsOutput,
9    crate::operation::get_search_suggestions::GetSearchSuggestionsError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::get_search_suggestions::GetSearchSuggestionsError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    Err(crate::operation::get_search_suggestions::GetSearchSuggestionsError::generic(generic))
17}
18
19#[allow(clippy::unnecessary_wraps)]
20pub fn de_get_search_suggestions_http_response(
21    _response_status: u16,
22    _response_headers: &::aws_smithy_runtime_api::http::Headers,
23    _response_body: &[u8],
24) -> std::result::Result<
25    crate::operation::get_search_suggestions::GetSearchSuggestionsOutput,
26    crate::operation::get_search_suggestions::GetSearchSuggestionsError,
27> {
28    Ok({
29        #[allow(unused_mut)]
30        let mut output = crate::operation::get_search_suggestions::builders::GetSearchSuggestionsOutputBuilder::default();
31        output = crate::protocol_serde::shape_get_search_suggestions::de_get_search_suggestions(_response_body, output)
32            .map_err(crate::operation::get_search_suggestions::GetSearchSuggestionsError::unhandled)?;
33        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
34        output.build()
35    })
36}
37
38pub fn ser_get_search_suggestions_input(
39    input: &crate::operation::get_search_suggestions::GetSearchSuggestionsInput,
40) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
41    let mut out = String::new();
42    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
43    crate::protocol_serde::shape_get_search_suggestions_input::ser_get_search_suggestions_input_input(&mut object, input)?;
44    object.finish();
45    Ok(::aws_smithy_types::body::SdkBody::from(out))
46}
47
48pub(crate) fn de_get_search_suggestions(
49    value: &[u8],
50    mut builder: crate::operation::get_search_suggestions::builders::GetSearchSuggestionsOutputBuilder,
51) -> ::std::result::Result<
52    crate::operation::get_search_suggestions::builders::GetSearchSuggestionsOutputBuilder,
53    ::aws_smithy_json::deserialize::error::DeserializeError,
54> {
55    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
56    let tokens = &mut tokens_owned;
57    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
58    loop {
59        match tokens.next().transpose()? {
60            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
61            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
62                "PropertyNameSuggestions" => {
63                    builder = builder.set_property_name_suggestions(
64                        crate::protocol_serde::shape_property_name_suggestion_list::de_property_name_suggestion_list(tokens)?,
65                    );
66                }
67                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
68            },
69            other => {
70                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
71                    "expected object key or end object, found: {:?}",
72                    other
73                )))
74            }
75        }
76    }
77    if tokens.next().is_some() {
78        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
79            "found more JSON tokens after completing parsing",
80        ));
81    }
82    Ok(builder)
83}