aws_sdk_appstream/protocol_serde/
shape_script_details.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_script_details(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::ScriptDetails,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.script_s3_location {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("ScriptS3Location").start_object();
9        crate::protocol_serde::shape_s3_location::ser_s3_location(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.executable_path {
13        object.key("ExecutablePath").string(var_3.as_str());
14    }
15    if let Some(var_4) = &input.executable_parameters {
16        object.key("ExecutableParameters").string(var_4.as_str());
17    }
18    if let Some(var_5) = &input.timeout_in_seconds {
19        object.key("TimeoutInSeconds").number(
20            #[allow(clippy::useless_conversion)]
21            ::aws_smithy_types::Number::NegInt((*var_5).into()),
22        );
23    }
24    Ok(())
25}
26
27pub(crate) fn de_script_details<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::ScriptDetails>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33    match tokens.next().transpose()? {
34        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36            #[allow(unused_mut)]
37            let mut builder = crate::types::builders::ScriptDetailsBuilder::default();
38            loop {
39                match tokens.next().transpose()? {
40                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42                        "ScriptS3Location" => {
43                            builder = builder.set_script_s3_location(crate::protocol_serde::shape_s3_location::de_s3_location(tokens)?);
44                        }
45                        "ExecutablePath" => {
46                            builder = builder.set_executable_path(
47                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
49                                    .transpose()?,
50                            );
51                        }
52                        "ExecutableParameters" => {
53                            builder = builder.set_executable_parameters(
54                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
55                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
56                                    .transpose()?,
57                            );
58                        }
59                        "TimeoutInSeconds" => {
60                            builder = builder.set_timeout_in_seconds(
61                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
62                                    .map(i32::try_from)
63                                    .transpose()?,
64                            );
65                        }
66                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
67                    },
68                    other => {
69                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
70                            "expected object key or end object, found: {:?}",
71                            other
72                        )))
73                    }
74                }
75            }
76            Ok(Some(crate::serde_util::script_details_correct_errors(builder).build()))
77        }
78        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
79            "expected start object or null",
80        )),
81    }
82}