Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_input_and_output_with_headers_input.rs

@@ -0,1 +0,364 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_header_boolean_list_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<
           6  +
    ::std::option::Option<::std::vec::Vec<bool>>,
           7  +
    ::aws_smithy_legacy_http::header::ParseError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
          10  +
    let headers = header_map.get_all("X-BooleanList");
          11  +
    /* HttpBindingGenerator.kt:427 */
          12  +
    let var_1 = ::aws_smithy_legacy_http::header::read_many_primitive::<bool>(headers)?;
          13  +
    /* HttpBindingGenerator.kt:453 */
          14  +
    Ok(if !var_1.is_empty() { Some(var_1) } else { None })
          15  +
    /* HttpBindingGenerator.kt:159 */
          16  +
}
          17  +
          18  +
/* HttpBindingGenerator.kt:159 */
          19  +
pub(crate) fn de_header_byte_header(
          20  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          21  +
) -> ::std::result::Result<::std::option::Option<i8>, ::aws_smithy_legacy_http::header::ParseError>
          22  +
{
          23  +
    /* HttpBindingGenerator.kt:166 */
          24  +
    let headers = header_map.get_all("X-Byte");
          25  +
    /* HttpBindingGenerator.kt:427 */
          26  +
    let var_2 = ::aws_smithy_legacy_http::header::read_many_primitive::<i8>(headers)?;
          27  +
    /* HttpBindingGenerator.kt:491 */
          28  +
    if var_2.len() > 1 {
          29  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          30  +
            "expected one item but found {}",
          31  +
            var_2.len()
          32  +
        )))
          33  +
    } else {
          34  +
        let mut var_2 = var_2;
          35  +
        Ok(var_2.pop())
          36  +
    }
          37  +
    /* HttpBindingGenerator.kt:159 */
          38  +
}
          39  +
          40  +
/* HttpBindingGenerator.kt:159 */
          41  +
pub(crate) fn de_header_double_header(
          42  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          43  +
) -> ::std::result::Result<::std::option::Option<f64>, ::aws_smithy_legacy_http::header::ParseError>
          44  +
{
          45  +
    /* HttpBindingGenerator.kt:166 */
          46  +
    let headers = header_map.get_all("X-Double");
          47  +
    /* HttpBindingGenerator.kt:427 */
          48  +
    let var_3 = ::aws_smithy_legacy_http::header::read_many_primitive::<f64>(headers)?;
          49  +
    /* HttpBindingGenerator.kt:491 */
          50  +
    if var_3.len() > 1 {
          51  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          52  +
            "expected one item but found {}",
          53  +
            var_3.len()
          54  +
        )))
          55  +
    } else {
          56  +
        let mut var_3 = var_3;
          57  +
        Ok(var_3.pop())
          58  +
    }
          59  +
    /* HttpBindingGenerator.kt:159 */
          60  +
}
          61  +
          62  +
/* HttpBindingGenerator.kt:159 */
          63  +
pub(crate) fn de_header_enum_header(
          64  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          65  +
) -> ::std::result::Result<
          66  +
    ::std::option::Option<::std::string::String>,
          67  +
    ::aws_smithy_legacy_http::header::ParseError,
          68  +
> {
          69  +
    /* HttpBindingGenerator.kt:166 */
          70  +
    let headers = header_map.get_all("X-Enum");
          71  +
    /* HttpBindingGenerator.kt:398 */
          72  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          73  +
    /* HttpBindingGenerator.kt:159 */
          74  +
}
          75  +
          76  +
/* HttpBindingGenerator.kt:159 */
          77  +
pub(crate) fn de_header_enum_list_header(
          78  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          79  +
) -> ::std::result::Result<
          80  +
    ::std::option::Option<
          81  +
        crate::unconstrained::foo_enum_list_unconstrained::FooEnumListUnconstrained,
          82  +
    >,
          83  +
    ::aws_smithy_legacy_http::header::ParseError,
          84  +
> {
          85  +
    /* HttpBindingGenerator.kt:166 */
          86  +
    let headers = header_map.get_all("X-EnumList");
          87  +
    /* HttpBindingGenerator.kt:432 */
          88  +
    let var_4: Vec<::std::string::String> =
          89  +
        ::aws_smithy_legacy_http::header::read_many_from_str(headers)?;
          90  +
    /* HttpBindingGenerator.kt:479 */
          91  +
    Ok(if !var_4.is_empty() {
          92  +
        Some(crate::unconstrained::foo_enum_list_unconstrained::FooEnumListUnconstrained(var_4))
          93  +
    } else {
          94  +
        None
          95  +
    })
          96  +
    /* HttpBindingGenerator.kt:159 */
          97  +
}
          98  +
          99  +
/* HttpBindingGenerator.kt:159 */
         100  +
pub(crate) fn de_header_false_bool_header(
         101  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         102  +
) -> ::std::result::Result<::std::option::Option<bool>, ::aws_smithy_legacy_http::header::ParseError>
         103  +
{
         104  +
    /* HttpBindingGenerator.kt:166 */
         105  +
    let headers = header_map.get_all("X-Boolean2");
         106  +
    /* HttpBindingGenerator.kt:427 */
         107  +
    let var_5 = ::aws_smithy_legacy_http::header::read_many_primitive::<bool>(headers)?;
         108  +
    /* HttpBindingGenerator.kt:491 */
         109  +
    if var_5.len() > 1 {
         110  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         111  +
            "expected one item but found {}",
         112  +
            var_5.len()
         113  +
        )))
         114  +
    } else {
         115  +
        let mut var_5 = var_5;
         116  +
        Ok(var_5.pop())
         117  +
    }
         118  +
    /* HttpBindingGenerator.kt:159 */
         119  +
}
         120  +
         121  +
/* HttpBindingGenerator.kt:159 */
         122  +
pub(crate) fn de_header_float_header(
         123  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         124  +
) -> ::std::result::Result<::std::option::Option<f32>, ::aws_smithy_legacy_http::header::ParseError>
         125  +
{
         126  +
    /* HttpBindingGenerator.kt:166 */
         127  +
    let headers = header_map.get_all("X-Float");
         128  +
    /* HttpBindingGenerator.kt:427 */
         129  +
    let var_6 = ::aws_smithy_legacy_http::header::read_many_primitive::<f32>(headers)?;
         130  +
    /* HttpBindingGenerator.kt:491 */
         131  +
    if var_6.len() > 1 {
         132  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         133  +
            "expected one item but found {}",
         134  +
            var_6.len()
         135  +
        )))
         136  +
    } else {
         137  +
        let mut var_6 = var_6;
         138  +
        Ok(var_6.pop())
         139  +
    }
         140  +
    /* HttpBindingGenerator.kt:159 */
         141  +
}
         142  +
         143  +
/* HttpBindingGenerator.kt:159 */
         144  +
pub(crate) fn de_header_integer_header(
         145  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         146  +
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_legacy_http::header::ParseError>
         147  +
{
         148  +
    /* HttpBindingGenerator.kt:166 */
         149  +
    let headers = header_map.get_all("X-Integer");
         150  +
    /* HttpBindingGenerator.kt:427 */
         151  +
    let var_7 = ::aws_smithy_legacy_http::header::read_many_primitive::<i32>(headers)?;
         152  +
    /* HttpBindingGenerator.kt:491 */
         153  +
    if var_7.len() > 1 {
         154  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         155  +
            "expected one item but found {}",
         156  +
            var_7.len()
         157  +
        )))
         158  +
    } else {
         159  +
        let mut var_7 = var_7;
         160  +
        Ok(var_7.pop())
         161  +
    }
         162  +
    /* HttpBindingGenerator.kt:159 */
         163  +
}
         164  +
         165  +
/* HttpBindingGenerator.kt:159 */
         166  +
pub(crate) fn de_header_integer_enum_header(
         167  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         168  +
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_legacy_http::header::ParseError>
         169  +
{
         170  +
    /* HttpBindingGenerator.kt:166 */
         171  +
    let headers = header_map.get_all("X-IntegerEnum");
         172  +
    /* HttpBindingGenerator.kt:427 */
         173  +
    let var_8 = ::aws_smithy_legacy_http::header::read_many_primitive::<i32>(headers)?;
         174  +
    /* HttpBindingGenerator.kt:491 */
         175  +
    if var_8.len() > 1 {
         176  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         177  +
            "expected one item but found {}",
         178  +
            var_8.len()
         179  +
        )))
         180  +
    } else {
         181  +
        let mut var_8 = var_8;
         182  +
        Ok(var_8.pop())
         183  +
    }
         184  +
    /* HttpBindingGenerator.kt:159 */
         185  +
}
         186  +
         187  +
/* HttpBindingGenerator.kt:159 */
         188  +
pub(crate) fn de_header_integer_enum_list_header(
         189  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         190  +
) -> ::std::result::Result<
         191  +
    ::std::option::Option<::std::vec::Vec<i32>>,
         192  +
    ::aws_smithy_legacy_http::header::ParseError,
         193  +
> {
         194  +
    /* HttpBindingGenerator.kt:166 */
         195  +
    let headers = header_map.get_all("X-IntegerEnumList");
         196  +
    /* HttpBindingGenerator.kt:427 */
         197  +
    let var_9 = ::aws_smithy_legacy_http::header::read_many_primitive::<i32>(headers)?;
         198  +
    /* HttpBindingGenerator.kt:453 */
         199  +
    Ok(if !var_9.is_empty() { Some(var_9) } else { None })
         200  +
    /* HttpBindingGenerator.kt:159 */
         201  +
}
         202  +
         203  +
/* HttpBindingGenerator.kt:159 */
         204  +
pub(crate) fn de_header_integer_list_header(
         205  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         206  +
) -> ::std::result::Result<
         207  +
    ::std::option::Option<::std::vec::Vec<i32>>,
         208  +
    ::aws_smithy_legacy_http::header::ParseError,
         209  +
> {
         210  +
    /* HttpBindingGenerator.kt:166 */
         211  +
    let headers = header_map.get_all("X-IntegerList");
         212  +
    /* HttpBindingGenerator.kt:427 */
         213  +
    let var_10 = ::aws_smithy_legacy_http::header::read_many_primitive::<i32>(headers)?;
         214  +
    /* HttpBindingGenerator.kt:453 */
         215  +
    Ok(if !var_10.is_empty() {
         216  +
        Some(var_10)
         217  +
    } else {
         218  +
        None
         219  +
    })
         220  +
    /* HttpBindingGenerator.kt:159 */
         221  +
}
         222  +
         223  +
/* HttpBindingGenerator.kt:159 */
         224  +
pub(crate) fn de_header_long_header(
         225  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         226  +
) -> ::std::result::Result<::std::option::Option<i64>, ::aws_smithy_legacy_http::header::ParseError>
         227  +
{
         228  +
    /* HttpBindingGenerator.kt:166 */
         229  +
    let headers = header_map.get_all("X-Long");
         230  +
    /* HttpBindingGenerator.kt:427 */
         231  +
    let var_11 = ::aws_smithy_legacy_http::header::read_many_primitive::<i64>(headers)?;
         232  +
    /* HttpBindingGenerator.kt:491 */
         233  +
    if var_11.len() > 1 {
         234  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         235  +
            "expected one item but found {}",
         236  +
            var_11.len()
         237  +
        )))
         238  +
    } else {
         239  +
        let mut var_11 = var_11;
         240  +
        Ok(var_11.pop())
         241  +
    }
         242  +
    /* HttpBindingGenerator.kt:159 */
         243  +
}
         244  +
         245  +
/* HttpBindingGenerator.kt:159 */
         246  +
pub(crate) fn de_header_short_header(
         247  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         248  +
) -> ::std::result::Result<::std::option::Option<i16>, ::aws_smithy_legacy_http::header::ParseError>
         249  +
{
         250  +
    /* HttpBindingGenerator.kt:166 */
         251  +
    let headers = header_map.get_all("X-Short");
         252  +
    /* HttpBindingGenerator.kt:427 */
         253  +
    let var_12 = ::aws_smithy_legacy_http::header::read_many_primitive::<i16>(headers)?;
         254  +
    /* HttpBindingGenerator.kt:491 */
         255  +
    if var_12.len() > 1 {
         256  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         257  +
            "expected one item but found {}",
         258  +
            var_12.len()
         259  +
        )))
         260  +
    } else {
         261  +
        let mut var_12 = var_12;
         262  +
        Ok(var_12.pop())
         263  +
    }
         264  +
    /* HttpBindingGenerator.kt:159 */
         265  +
}
         266  +
         267  +
/* HttpBindingGenerator.kt:159 */
         268  +
pub(crate) fn de_header_string_header(
         269  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         270  +
) -> ::std::result::Result<
         271  +
    ::std::option::Option<::std::string::String>,
         272  +
    ::aws_smithy_legacy_http::header::ParseError,
         273  +
> {
         274  +
    /* HttpBindingGenerator.kt:166 */
         275  +
    let headers = header_map.get_all("X-String");
         276  +
    /* HttpBindingGenerator.kt:398 */
         277  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
         278  +
    /* HttpBindingGenerator.kt:159 */
         279  +
}
         280  +
         281  +
/* HttpBindingGenerator.kt:159 */
         282  +
pub(crate) fn de_header_string_list_header(
         283  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         284  +
) -> ::std::result::Result<
         285  +
    ::std::option::Option<::std::vec::Vec<::std::string::String>>,
         286  +
    ::aws_smithy_legacy_http::header::ParseError,
         287  +
> {
         288  +
    /* HttpBindingGenerator.kt:166 */
         289  +
    let headers = header_map.get_all("X-StringList");
         290  +
    /* HttpBindingGenerator.kt:432 */
         291  +
    let var_13: Vec<::std::string::String> =
         292  +
        ::aws_smithy_legacy_http::header::read_many_from_str(headers)?;
         293  +
    /* HttpBindingGenerator.kt:453 */
         294  +
    Ok(if !var_13.is_empty() {
         295  +
        Some(var_13)
         296  +
    } else {
         297  +
        None
         298  +
    })
         299  +
    /* HttpBindingGenerator.kt:159 */
         300  +
}
         301  +
         302  +
/* HttpBindingGenerator.kt:159 */
         303  +
pub(crate) fn de_header_string_set_header(
         304  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         305  +
) -> ::std::result::Result<
         306  +
    ::std::option::Option<crate::unconstrained::string_set_unconstrained::StringSetUnconstrained>,
         307  +
    ::aws_smithy_legacy_http::header::ParseError,
         308  +
> {
         309  +
    /* HttpBindingGenerator.kt:166 */
         310  +
    let headers = header_map.get_all("X-StringSet");
         311  +
    /* HttpBindingGenerator.kt:432 */
         312  +
    let var_14: Vec<::std::string::String> =
         313  +
        ::aws_smithy_legacy_http::header::read_many_from_str(headers)?;
         314  +
    /* HttpBindingGenerator.kt:479 */
         315  +
    Ok(if !var_14.is_empty() {
         316  +
        Some(crate::unconstrained::string_set_unconstrained::StringSetUnconstrained(var_14))
         317  +
    } else {
         318  +
        None
         319  +
    })
         320  +
    /* HttpBindingGenerator.kt:159 */
         321  +
}
         322  +
         323  +
/* HttpBindingGenerator.kt:159 */
         324  +
pub(crate) fn de_header_timestamp_list_header(
         325  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         326  +
) -> ::std::result::Result<
         327  +
    ::std::option::Option<::std::vec::Vec<::aws_smithy_types::DateTime>>,
         328  +
    ::aws_smithy_legacy_http::header::ParseError,
         329  +
> {
         330  +
    /* HttpBindingGenerator.kt:166 */
         331  +
    let headers = header_map.get_all("X-TimestampList");
         332  +
    /* HttpBindingGenerator.kt:417 */
         333  +
    let var_15: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::HttpDate)?
         334  +
    /* HttpBindingGenerator.kt:425 */;
         335  +
    /* HttpBindingGenerator.kt:453 */
         336  +
    Ok(if !var_15.is_empty() {
         337  +
        Some(var_15)
         338  +
    } else {
         339  +
        None
         340  +
    })
         341  +
    /* HttpBindingGenerator.kt:159 */
         342  +
}
         343  +
         344  +
/* HttpBindingGenerator.kt:159 */
         345  +
pub(crate) fn de_header_true_bool_header(
         346  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         347  +
) -> ::std::result::Result<::std::option::Option<bool>, ::aws_smithy_legacy_http::header::ParseError>
         348  +
{
         349  +
    /* HttpBindingGenerator.kt:166 */
         350  +
    let headers = header_map.get_all("X-Boolean1");
         351  +
    /* HttpBindingGenerator.kt:427 */
         352  +
    let var_16 = ::aws_smithy_legacy_http::header::read_many_primitive::<bool>(headers)?;
         353  +
    /* HttpBindingGenerator.kt:491 */
         354  +
    if var_16.len() > 1 {
         355  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         356  +
            "expected one item but found {}",
         357  +
            var_16.len()
         358  +
        )))
         359  +
    } else {
         360  +
        let mut var_16 = var_16;
         361  +
        Ok(var_16.pop())
         362  +
    }
         363  +
    /* HttpBindingGenerator.kt:159 */
         364  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_input_and_output_with_headers_output.rs

@@ -0,1 +0,25 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_input_and_output_with_headers_output_output_output(
           4  +
    value: &crate::output::InputAndOutputWithHeadersOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_input_and_output_with_headers_output::ser_input_and_output_with_headers_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:358 */
          18  +
pub fn ser_input_and_output_with_headers_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::InputAndOutputWithHeadersOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:372 */
          23  +
    Ok(())
          24  +
    /* JsonSerializerGenerator.kt:358 */
          25  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_integer_enum_list.rs

@@ -0,1 +0,76 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
           3  +
pub(crate) fn de_integer_enum_list<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::vec::Vec<i32>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
          23  +
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
          27  +
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
          29  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
          31  +
                        tokens.next().transpose().unwrap();
          32  +
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
          34  +
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
          36  +
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          40  +
                                                .map(i32::try_from)
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:419 */;
          43  +
                        /* JsonParserGenerator.kt:422 */
          44  +
                        if let Some(value) = value {
          45  +
                            items.push(value);
          46  +
                        }
          47  +
                        /* JsonParserGenerator.kt:430 */
          48  +
                        else {
          49  +
                            return Err(
          50  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                                    "dense list cannot contain null values",
          52  +
                                ),
          53  +
                            );
          54  +
                        }
          55  +
                        /* JsonParserGenerator.kt:413 */
          56  +
                    } /* JsonParserGenerator.kt:409 */
          57  +
                }
          58  +
                /* JsonParserGenerator.kt:408 */
          59  +
            }
          60  +
            /* JsonParserGenerator.kt:446 */
          61  +
            Ok(Some(items))
          62  +
            /* JsonParserGenerator.kt:713 */
          63  +
        }
          64  +
        /* JsonParserGenerator.kt:722 */
          65  +
        _ => {
          66  +
            /* JsonParserGenerator.kt:723 */
          67  +
            Err(
          68  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          69  +
                    "expected start array or null",
          70  +
                ),
          71  +
            )
          72  +
            /* JsonParserGenerator.kt:722 */
          73  +
        } /* JsonParserGenerator.kt:712 */
          74  +
    }
          75  +
    /* JsonParserGenerator.kt:398 */
          76  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_integer_enum_map.rs

@@ -0,1 +0,85 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_integer_enum_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::collections::HashMap<::std::string::String, i32>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          40  +
                                                .map(i32::try_from)
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:474 */;
          43  +
                        /* JsonParserGenerator.kt:481 */
          44  +
                        match value {
          45  +
                            Some(value) => {
          46  +
                                map.insert(key, value);
          47  +
                            }
          48  +
                            None => {
          49  +
                                return Err(
          50  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                                        "dense map cannot contain null values",
          52  +
                                    ),
          53  +
                                )
          54  +
                            }
          55  +
                        }
          56  +
                        /* JsonParserGenerator.kt:686 */
          57  +
                    }
          58  +
                    /* JsonParserGenerator.kt:695 */
          59  +
                    other => {
          60  +
                        return Err(
          61  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          62  +
                                format!("expected object key or end object, found: {other:?}"),
          63  +
                            ),
          64  +
                        )
          65  +
                    } /* JsonParserGenerator.kt:685 */
          66  +
                }
          67  +
                /* JsonParserGenerator.kt:684 */
          68  +
            }
          69  +
            /* JsonParserGenerator.kt:504 */
          70  +
            Ok(Some(map))
          71  +
            /* JsonParserGenerator.kt:713 */
          72  +
        }
          73  +
        /* JsonParserGenerator.kt:722 */
          74  +
        _ => {
          75  +
            /* JsonParserGenerator.kt:723 */
          76  +
            Err(
          77  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          78  +
                    "expected start object or null",
          79  +
                ),
          80  +
            )
          81  +
            /* JsonParserGenerator.kt:722 */
          82  +
        } /* JsonParserGenerator.kt:712 */
          83  +
    }
          84  +
    /* JsonParserGenerator.kt:460 */
          85  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_integer_enum_set.rs

@@ -0,1 +0,80 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
           3  +
pub(crate) fn de_integer_enum_set<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
          23  +
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
          27  +
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
          29  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
          31  +
                        tokens.next().transpose().unwrap();
          32  +
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
          34  +
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
          36  +
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          40  +
                                                .map(i32::try_from)
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:419 */;
          43  +
                        /* JsonParserGenerator.kt:422 */
          44  +
                        if let Some(value) = value {
          45  +
                            items.push(value);
          46  +
                        }
          47  +
                        /* JsonParserGenerator.kt:430 */
          48  +
                        else {
          49  +
                            return Err(
          50  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                                    "dense list cannot contain null values",
          52  +
                                ),
          53  +
                            );
          54  +
                        }
          55  +
                        /* JsonParserGenerator.kt:413 */
          56  +
                    } /* JsonParserGenerator.kt:409 */
          57  +
                }
          58  +
                /* JsonParserGenerator.kt:408 */
          59  +
            }
          60  +
            /* JsonParserGenerator.kt:444 */
          61  +
            Ok(Some(
          62  +
                crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained(
          63  +
                    items,
          64  +
                ),
          65  +
            ))
          66  +
            /* JsonParserGenerator.kt:713 */
          67  +
        }
          68  +
        /* JsonParserGenerator.kt:722 */
          69  +
        _ => {
          70  +
            /* JsonParserGenerator.kt:723 */
          71  +
            Err(
          72  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          73  +
                    "expected start array or null",
          74  +
                ),
          75  +
            )
          76  +
            /* JsonParserGenerator.kt:722 */
          77  +
        } /* JsonParserGenerator.kt:712 */
          78  +
    }
          79  +
    /* JsonParserGenerator.kt:398 */
          80  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_integer_list.rs

@@ -0,1 +0,76 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
           3  +
pub(crate) fn de_integer_list<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::vec::Vec<i32>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
          23  +
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
          27  +
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
          29  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
          31  +
                        tokens.next().transpose().unwrap();
          32  +
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
          34  +
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
          36  +
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          40  +
                                                .map(i32::try_from)
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:419 */;
          43  +
                        /* JsonParserGenerator.kt:422 */
          44  +
                        if let Some(value) = value {
          45  +
                            items.push(value);
          46  +
                        }
          47  +
                        /* JsonParserGenerator.kt:430 */
          48  +
                        else {
          49  +
                            return Err(
          50  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                                    "dense list cannot contain null values",
          52  +
                                ),
          53  +
                            );
          54  +
                        }
          55  +
                        /* JsonParserGenerator.kt:413 */
          56  +
                    } /* JsonParserGenerator.kt:409 */
          57  +
                }
          58  +
                /* JsonParserGenerator.kt:408 */
          59  +
            }
          60  +
            /* JsonParserGenerator.kt:446 */
          61  +
            Ok(Some(items))
          62  +
            /* JsonParserGenerator.kt:713 */
          63  +
        }
          64  +
        /* JsonParserGenerator.kt:722 */
          65  +
        _ => {
          66  +
            /* JsonParserGenerator.kt:723 */
          67  +
            Err(
          68  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          69  +
                    "expected start array or null",
          70  +
                ),
          71  +
            )
          72  +
            /* JsonParserGenerator.kt:722 */
          73  +
        } /* JsonParserGenerator.kt:712 */
          74  +
    }
          75  +
    /* JsonParserGenerator.kt:398 */
          76  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_invalid_greeting.rs

@@ -0,1 +0,31 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_invalid_greeting_error(
           4  +
    value: &crate::error::InvalidGreeting,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:358 */
          18  +
pub fn ser_invalid_greeting(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::error::InvalidGreeting,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
          23  +
    if let Some(var_1) = &input.message {
          24  +
        /* JsonSerializerGenerator.kt:423 */
          25  +
        object.key("Message").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:382 */
          27  +
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
          29  +
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
          31  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_json_blobs.rs

@@ -0,1 +0,155 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_json_blobs_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::JsonBlobsInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::json_blobs_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:801 */
          30  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
          32  +
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
          34  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          35  +
                &headers,
          36  +
                Some("application/json"),
          37  +
            )?;
          38  +
            input = crate::protocol_serde::shape_json_blobs::de_json_blobs(bytes.as_ref(), input)?;
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          40  +
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          42  +
        input.build()
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          44  +
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          46  +
}
          47  +
          48  +
/* RustType.kt:534 */
          49  +
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          51  +
pub fn ser_json_blobs_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::JsonBlobsOutput,
          53  +
) -> std::result::Result<
          54  +
    ::aws_smithy_legacy_http_server::response::Response,
          55  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          56  +
> {
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          58  +
    Ok({
          59  +
        /* RustType.kt:534 */
          60  +
        #[allow(unused_mut)]
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          62  +
        let mut builder = ::http::Response::builder();
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          64  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          65  +
            builder,
          66  +
            ::http::header::CONTENT_TYPE,
          67  +
            "application/json",
          68  +
        );
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          70  +
        let http_status: u16 = 200;
          71  +
        builder = builder.status(http_status);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          73  +
        let payload =
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_json_blobs_output::ser_json_blobs_output_output_output(&output)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          77  +
        let content_length = payload.len();
          78  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          79  +
            builder,
          80  +
            ::http::header::CONTENT_LENGTH,
          81  +
            content_length,
          82  +
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          84  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          86  +
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          88  +
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          90  +
}
          91  +
          92  +
/* JsonParserGenerator.kt:148 */
          93  +
pub(crate) fn de_json_blobs(
          94  +
    value: &[u8],
          95  +
    mut builder: crate::input::json_blobs_input::Builder,
          96  +
) -> ::std::result::Result<
          97  +
    crate::input::json_blobs_input::Builder,
          98  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          99  +
> {
         100  +
    /* JsonParserGenerator.kt:153 */
         101  +
    let mut tokens_owned =
         102  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         103  +
            .peekable();
         104  +
    let tokens = &mut tokens_owned;
         105  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         106  +
    /* JsonParserGenerator.kt:684 */
         107  +
    loop {
         108  +
        /* JsonParserGenerator.kt:685 */
         109  +
        match tokens.next().transpose()? {
         110  +
            /* JsonParserGenerator.kt:686 */
         111  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         112  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         113  +
                /* JsonParserGenerator.kt:260 */
         114  +
                match key.to_unescaped()?.as_ref() {
         115  +
                    /* JsonParserGenerator.kt:262 */
         116  +
                    "data" => {
         117  +
                        /* JsonParserGenerator.kt:272 */
         118  +
                        builder = builder.set_data(
         119  +
                            /* JsonParserGenerator.kt:326 */
         120  +
                            ::aws_smithy_json::deserialize::token::expect_blob_or_null(
         121  +
                                tokens.next(),
         122  +
                            )?, /* JsonParserGenerator.kt:272 */
         123  +
                        );
         124  +
                        /* JsonParserGenerator.kt:262 */
         125  +
                    }
         126  +
                    /* JsonParserGenerator.kt:290 */
         127  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         128  +
                }
         129  +
                /* JsonParserGenerator.kt:686 */
         130  +
            }
         131  +
            /* JsonParserGenerator.kt:695 */
         132  +
            other => {
         133  +
                return Err(
         134  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         135  +
                        "expected object key or end object, found: {other:?}"
         136  +
                    )),
         137  +
                )
         138  +
            } /* JsonParserGenerator.kt:685 */
         139  +
        }
         140  +
        /* JsonParserGenerator.kt:684 */
         141  +
    }
         142  +
    /* JsonParserGenerator.kt:250 */
         143  +
    if tokens.next().is_some() {
         144  +
        /* JsonParserGenerator.kt:251 */
         145  +
        return Err(
         146  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         147  +
                "found more JSON tokens after completing parsing",
         148  +
            ),
         149  +
        );
         150  +
        /* JsonParserGenerator.kt:250 */
         151  +
    }
         152  +
    /* JsonParserGenerator.kt:163 */
         153  +
    Ok(builder)
         154  +
    /* JsonParserGenerator.kt:148 */
         155  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_json_blobs_output.rs

@@ -0,1 +0,36 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_json_blobs_output_output_output(
           4  +
    value: &crate::output::JsonBlobsOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_json_blobs_output::ser_json_blobs_output_output(
          11  +
        &mut object,
          12  +
        value,
          13  +
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
          15  +
    object.finish();
          16  +
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
          18  +
}
          19  +
          20  +
/* JsonSerializerGenerator.kt:358 */
          21  +
pub fn ser_json_blobs_output_output(
          22  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    input: &crate::output::JsonBlobsOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
          26  +
    if let Some(var_1) = &input.data {
          27  +
        /* JsonSerializerGenerator.kt:439 */
          28  +
        object
          29  +
            .key("data")
          30  +
            .string_unchecked(&::aws_smithy_types::base64::encode(var_1));
          31  +
        /* JsonSerializerGenerator.kt:382 */
          32  +
    }
          33  +
    /* JsonSerializerGenerator.kt:372 */
          34  +
    Ok(())
          35  +
    /* JsonSerializerGenerator.kt:358 */
          36  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_json_enums.rs

@@ -0,1 +0,272 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_json_enums_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::JsonEnumsInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::json_enums_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:801 */
          30  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
          32  +
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
          34  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          35  +
                &headers,
          36  +
                Some("application/json"),
          37  +
            )?;
          38  +
            input = crate::protocol_serde::shape_json_enums::de_json_enums(bytes.as_ref(), input)?;
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          40  +
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          42  +
        input.build()?
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          44  +
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          46  +
}
          47  +
          48  +
/* RustType.kt:534 */
          49  +
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          51  +
pub fn ser_json_enums_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::JsonEnumsOutput,
          53  +
) -> std::result::Result<
          54  +
    ::aws_smithy_legacy_http_server::response::Response,
          55  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          56  +
> {
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          58  +
    Ok({
          59  +
        /* RustType.kt:534 */
          60  +
        #[allow(unused_mut)]
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          62  +
        let mut builder = ::http::Response::builder();
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          64  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          65  +
            builder,
          66  +
            ::http::header::CONTENT_TYPE,
          67  +
            "application/json",
          68  +
        );
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          70  +
        let http_status: u16 = 200;
          71  +
        builder = builder.status(http_status);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          73  +
        let payload =
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_json_enums_output::ser_json_enums_output_output_output(&output)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          77  +
        let content_length = payload.len();
          78  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          79  +
            builder,
          80  +
            ::http::header::CONTENT_LENGTH,
          81  +
            content_length,
          82  +
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          84  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          86  +
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          88  +
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          90  +
}
          91  +
          92  +
/* RustType.kt:534 */
          93  +
#[allow(clippy::unnecessary_wraps)]
          94  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          95  +
pub fn ser_json_enums_http_error(
          96  +
    error: &crate::error::JsonEnumsError,
          97  +
) -> std::result::Result<
          98  +
    ::aws_smithy_legacy_http_server::response::Response,
          99  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         100  +
> {
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         102  +
    Ok({
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         104  +
        match error {
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         106  +
            crate::error::JsonEnumsError::ValidationException(output) => {
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         108  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         109  +
                /* RustType.kt:534 */
         110  +
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         112  +
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         114  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         115  +
                    builder,
         116  +
                    ::http::header::CONTENT_TYPE,
         117  +
                    "application/json",
         118  +
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         120  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         121  +
                    builder,
         122  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         123  +
                    "ValidationException",
         124  +
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         126  +
                let content_length = payload.len();
         127  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         128  +
                    builder,
         129  +
                    ::http::header::CONTENT_LENGTH,
         130  +
                    content_length,
         131  +
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         133  +
                builder
         134  +
                    .status(400)
         135  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         137  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         138  +
        }
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         142  +
}
         143  +
         144  +
/* JsonParserGenerator.kt:148 */
         145  +
pub(crate) fn de_json_enums(
         146  +
    value: &[u8],
         147  +
    mut builder: crate::input::json_enums_input::Builder,
         148  +
) -> ::std::result::Result<
         149  +
    crate::input::json_enums_input::Builder,
         150  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         151  +
> {
         152  +
    /* JsonParserGenerator.kt:153 */
         153  +
    let mut tokens_owned =
         154  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         155  +
            .peekable();
         156  +
    let tokens = &mut tokens_owned;
         157  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         158  +
    /* JsonParserGenerator.kt:684 */
         159  +
    loop {
         160  +
        /* JsonParserGenerator.kt:685 */
         161  +
        match tokens.next().transpose()? {
         162  +
            /* JsonParserGenerator.kt:686 */
         163  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         164  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         165  +
                /* JsonParserGenerator.kt:260 */
         166  +
                match key.to_unescaped()?.as_ref() {
         167  +
                    /* JsonParserGenerator.kt:262 */
         168  +
                    "fooEnum1" => {
         169  +
                        /* JsonParserGenerator.kt:272 */
         170  +
                        builder = builder.set_foo_enum1(
         171  +
                            /* JsonParserGenerator.kt:354 */
         172  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         173  +
                                tokens.next(),
         174  +
                            )?
         175  +
                            .map(|s|
         176  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         177  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
         178  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         179  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         180  +
                        );
         181  +
                        /* JsonParserGenerator.kt:262 */
         182  +
                    }
         183  +
                    /* JsonParserGenerator.kt:262 */
         184  +
                    "fooEnum2" => {
         185  +
                        /* JsonParserGenerator.kt:272 */
         186  +
                        builder = builder.set_foo_enum2(
         187  +
                            /* JsonParserGenerator.kt:354 */
         188  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         189  +
                                tokens.next(),
         190  +
                            )?
         191  +
                            .map(|s|
         192  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         193  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
         194  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         195  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         196  +
                        );
         197  +
                        /* JsonParserGenerator.kt:262 */
         198  +
                    }
         199  +
                    /* JsonParserGenerator.kt:262 */
         200  +
                    "fooEnum3" => {
         201  +
                        /* JsonParserGenerator.kt:272 */
         202  +
                        builder = builder.set_foo_enum3(
         203  +
                            /* JsonParserGenerator.kt:354 */
         204  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         205  +
                                tokens.next(),
         206  +
                            )?
         207  +
                            .map(|s|
         208  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         209  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
         210  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         211  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         212  +
                        );
         213  +
                        /* JsonParserGenerator.kt:262 */
         214  +
                    }
         215  +
                    /* JsonParserGenerator.kt:262 */
         216  +
                    "fooEnumList" => {
         217  +
                        /* JsonParserGenerator.kt:272 */
         218  +
                        builder =
         219  +
                            builder.set_foo_enum_list(
         220  +
                                /* JsonParserGenerator.kt:451 */
         221  +
                                crate::protocol_serde::shape_foo_enum_list::de_foo_enum_list(
         222  +
                                    tokens,
         223  +
                                )?, /* JsonParserGenerator.kt:272 */
         224  +
                            );
         225  +
                        /* JsonParserGenerator.kt:262 */
         226  +
                    }
         227  +
                    /* JsonParserGenerator.kt:262 */
         228  +
                    "fooEnumMap" => {
         229  +
                        /* JsonParserGenerator.kt:272 */
         230  +
                        builder = builder.set_foo_enum_map(
         231  +
                            /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_foo_enum_map::de_foo_enum_map(tokens)?
         232  +
                        /* JsonParserGenerator.kt:272 */);
         233  +
                        /* JsonParserGenerator.kt:262 */
         234  +
                    }
         235  +
                    /* JsonParserGenerator.kt:262 */
         236  +
                    "fooEnumSet" => {
         237  +
                        /* JsonParserGenerator.kt:272 */
         238  +
                        builder = builder.set_foo_enum_set(
         239  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_foo_enum_set::de_foo_enum_set(tokens)?
         240  +
                        /* JsonParserGenerator.kt:272 */);
         241  +
                        /* JsonParserGenerator.kt:262 */
         242  +
                    }
         243  +
                    /* JsonParserGenerator.kt:290 */
         244  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         245  +
                }
         246  +
                /* JsonParserGenerator.kt:686 */
         247  +
            }
         248  +
            /* JsonParserGenerator.kt:695 */
         249  +
            other => {
         250  +
                return Err(
         251  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         252  +
                        "expected object key or end object, found: {other:?}"
         253  +
                    )),
         254  +
                )
         255  +
            } /* JsonParserGenerator.kt:685 */
         256  +
        }
         257  +
        /* JsonParserGenerator.kt:684 */
         258  +
    }
         259  +
    /* JsonParserGenerator.kt:250 */
         260  +
    if tokens.next().is_some() {
         261  +
        /* JsonParserGenerator.kt:251 */
         262  +
        return Err(
         263  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         264  +
                "found more JSON tokens after completing parsing",
         265  +
            ),
         266  +
        );
         267  +
        /* JsonParserGenerator.kt:250 */
         268  +
    }
         269  +
    /* JsonParserGenerator.kt:163 */
         270  +
    Ok(builder)
         271  +
    /* JsonParserGenerator.kt:148 */
         272  +
}