aws_sdk_licensemanager/protocol_serde/
shape_borrow_configuration.rs1pub fn ser_borrow_configuration(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::BorrowConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("AllowEarlyCheckIn").boolean(input.allow_early_check_in);
8 }
9 {
10 object.key("MaxTimeToLiveInMinutes").number(
11 #[allow(clippy::useless_conversion)]
12 ::aws_smithy_types::Number::NegInt((input.max_time_to_live_in_minutes).into()),
13 );
14 }
15 Ok(())
16}
17
18pub(crate) fn de_borrow_configuration<'a, I>(
19 tokens: &mut ::std::iter::Peekable<I>,
20) -> ::std::result::Result<Option<crate::types::BorrowConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
21where
22 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
23{
24 match tokens.next().transpose()? {
25 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
26 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
27 #[allow(unused_mut)]
28 let mut builder = crate::types::builders::BorrowConfigurationBuilder::default();
29 loop {
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
32 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
33 "AllowEarlyCheckIn" => {
34 builder = builder.set_allow_early_check_in(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
35 }
36 "MaxTimeToLiveInMinutes" => {
37 builder = builder.set_max_time_to_live_in_minutes(
38 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
39 .map(i32::try_from)
40 .transpose()?,
41 );
42 }
43 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
44 },
45 other => {
46 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
47 "expected object key or end object, found: {:?}",
48 other
49 )))
50 }
51 }
52 }
53 Ok(Some(crate::serde_util::borrow_configuration_correct_errors(builder).build().map_err(
54 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
55 )?))
56 }
57 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
58 "expected start object or null",
59 )),
60 }
61}