Skip to main content

aws_sdk_licensemanagerlinuxsubscriptions/protocol_serde/
shape_instance.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_instance<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4    _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::Instance>, ::aws_smithy_json::deserialize::error::DeserializeError>
6where
7    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
8{
9    match tokens.next().transpose()? {
10        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
11        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
12            #[allow(unused_mut)]
13            let mut builder = crate::types::builders::InstanceBuilder::default();
14            loop {
15                match tokens.next().transpose()? {
16                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
17                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
18                        "AmiId" => {
19                            builder = builder.set_ami_id(
20                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
21                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
22                                    .transpose()?,
23                            );
24                        }
25                        "InstanceID" => {
26                            builder = builder.set_instance_id(
27                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
28                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
29                                    .transpose()?,
30                            );
31                        }
32                        "InstanceType" => {
33                            builder = builder.set_instance_type(
34                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
35                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
36                                    .transpose()?,
37                            );
38                        }
39                        "AccountID" => {
40                            builder = builder.set_account_id(
41                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43                                    .transpose()?,
44                            );
45                        }
46                        "Status" => {
47                            builder = builder.set_status(
48                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
50                                    .transpose()?,
51                            );
52                        }
53                        "Region" => {
54                            builder = builder.set_region(
55                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
56                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
57                                    .transpose()?,
58                            );
59                        }
60                        "UsageOperation" => {
61                            builder = builder.set_usage_operation(
62                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
63                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
64                                    .transpose()?,
65                            );
66                        }
67                        "ProductCode" => {
68                            builder = builder.set_product_code(crate::protocol_serde::shape_product_code_list::de_product_code_list(tokens, _value)?);
69                        }
70                        "LastUpdatedTime" => {
71                            builder = builder.set_last_updated_time(
72                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
73                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
74                                    .transpose()?,
75                            );
76                        }
77                        "SubscriptionName" => {
78                            builder = builder.set_subscription_name(
79                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
80                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
81                                    .transpose()?,
82                            );
83                        }
84                        "OsVersion" => {
85                            builder = builder.set_os_version(
86                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
87                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
88                                    .transpose()?,
89                            );
90                        }
91                        "SubscriptionProviderCreateTime" => {
92                            builder = builder.set_subscription_provider_create_time(
93                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
94                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
95                                    .transpose()?,
96                            );
97                        }
98                        "SubscriptionProviderUpdateTime" => {
99                            builder = builder.set_subscription_provider_update_time(
100                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
101                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
102                                    .transpose()?,
103                            );
104                        }
105                        "DualSubscription" => {
106                            builder = builder.set_dual_subscription(
107                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
108                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
109                                    .transpose()?,
110                            );
111                        }
112                        "RegisteredWithSubscriptionProvider" => {
113                            builder = builder.set_registered_with_subscription_provider(
114                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
115                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
116                                    .transpose()?,
117                            );
118                        }
119                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
120                    },
121                    other => {
122                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
123                            "expected object key or end object, found: {other:?}"
124                        )))
125                    }
126                }
127            }
128            Ok(Some(builder.build()))
129        }
130        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
131            "expected start object or null",
132        )),
133    }
134}