aws_sdk_sagemaker/protocol_serde/
shape_describe_workforce.rs

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