Skip to main content

aws_sdk_directconnect/protocol_serde/
shape_bgp_peer.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_bgp_peer<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4    _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::BgpPeer>, ::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::BgpPeerBuilder::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                        "bgpPeerId" => {
19                            builder = builder.set_bgp_peer_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                        "asn" => {
26                            builder = builder.set_asn(
27                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
28                                    .map(i32::try_from)
29                                    .transpose()?,
30                            );
31                        }
32                        "asnLong" => {
33                            builder = builder.set_asn_long(
34                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
35                                    .map(i64::try_from)
36                                    .transpose()?,
37                            );
38                        }
39                        "authKey" => {
40                            builder = builder.set_auth_key(
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                        "addressFamily" => {
47                            builder = builder.set_address_family(
48                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49                                    .map(|s| s.to_unescaped().map(|u| crate::types::AddressFamily::from(u.as_ref())))
50                                    .transpose()?,
51                            );
52                        }
53                        "amazonAddress" => {
54                            builder = builder.set_amazon_address(
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                        "customerAddress" => {
61                            builder = builder.set_customer_address(
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                        "bgpPeerState" => {
68                            builder = builder.set_bgp_peer_state(
69                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
70                                    .map(|s| s.to_unescaped().map(|u| crate::types::BgpPeerState::from(u.as_ref())))
71                                    .transpose()?,
72                            );
73                        }
74                        "bgpStatus" => {
75                            builder = builder.set_bgp_status(
76                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
77                                    .map(|s| s.to_unescaped().map(|u| crate::types::BgpStatus::from(u.as_ref())))
78                                    .transpose()?,
79                            );
80                        }
81                        "awsDeviceV2" => {
82                            builder = builder.set_aws_device_v2(
83                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
84                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
85                                    .transpose()?,
86                            );
87                        }
88                        "awsLogicalDeviceId" => {
89                            builder = builder.set_aws_logical_device_id(
90                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
91                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
92                                    .transpose()?,
93                            );
94                        }
95                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
96                    },
97                    other => {
98                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
99                            "expected object key or end object, found: {other:?}"
100                        )))
101                    }
102                }
103            }
104            Ok(Some(builder.build()))
105        }
106        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
107            "expected start object or null",
108        )),
109    }
110}