aws_sdk_nimble/protocol_serde/
shape_validation_exception.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_validation_exception_json_err(
3    value: &[u8],
4    mut builder: crate::types::error::builders::ValidationExceptionBuilder,
5) -> Result<crate::types::error::builders::ValidationExceptionBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
6    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
7    let tokens = &mut tokens_owned;
8    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
9    loop {
10        match tokens.next().transpose()? {
11            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
12            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
13                "code" => {
14                    builder = builder.set_code(
15                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
16                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
17                            .transpose()?,
18                    );
19                }
20                "context" => {
21                    builder = builder.set_context(crate::protocol_serde::shape_exception_context::de_exception_context(tokens)?);
22                }
23                "message" => {
24                    builder = builder.set_message(
25                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
26                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
27                            .transpose()?,
28                    );
29                }
30                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
31            },
32            other => {
33                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
34                    "expected object key or end object, found: {:?}",
35                    other
36                )))
37            }
38        }
39    }
40    if tokens.next().is_some() {
41        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
42            "found more JSON tokens after completing parsing",
43        ));
44    }
45    Ok(builder)
46}