Server Test

Server Test

rev. 3c756f73b1f83a0eed4275d9d1e22df0b10b66fb (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_list_changed_blocks_input.rs

@@ -0,1 +0,52 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_second_snapshot_id(
           3  +
    value: &str,
           4  +
) -> std::result::Result<
           5  +
    ::std::string::String,
           6  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           7  +
> {
           8  +
    let value = ::percent_encoding::percent_decode_str(value)
           9  +
        .decode_utf8()?
          10  +
        .into_owned();
          11  +
    Ok(value)
          12  +
}
          13  +
          14  +
pub fn de_first_snapshot_id(
          15  +
    value: &str,
          16  +
) -> std::result::Result<
          17  +
    ::std::option::Option<::std::string::String>,
          18  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          19  +
> {
          20  +
    let value = value.to_owned();
          21  +
    Ok(Some(value))
          22  +
}
          23  +
          24  +
pub fn de_max_results(
          25  +
    value: &str,
          26  +
) -> std::result::Result<
          27  +
    ::std::option::Option<i32>,
          28  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          29  +
> {
          30  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          31  +
    Ok(Some(value))
          32  +
}
          33  +
          34  +
pub fn de_next_token(
          35  +
    value: &str,
          36  +
) -> std::result::Result<
          37  +
    ::std::option::Option<::std::string::String>,
          38  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          39  +
> {
          40  +
    let value = value.to_owned();
          41  +
    Ok(Some(value))
          42  +
}
          43  +
          44  +
pub fn de_starting_block_index(
          45  +
    value: &str,
          46  +
) -> std::result::Result<
          47  +
    ::std::option::Option<i32>,
          48  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          49  +
> {
          50  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          51  +
    Ok(Some(value))
          52  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_list_changed_blocks_output.rs

@@ -0,1 +0,55 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_list_changed_blocks_output_output_output(
           3  +
    value: &crate::output::ListChangedBlocksOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_list_changed_blocks_output::ser_list_changed_blocks_output_output(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_list_changed_blocks_output_output(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::output::ListChangedBlocksOutput,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    if let Some(var_1) = &input.block_size {
          20  +
        object.key("BlockSize").number(
          21  +
            #[allow(clippy::useless_conversion)]
          22  +
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
          23  +
        );
          24  +
    }
          25  +
    if let Some(var_2) = &input.changed_blocks {
          26  +
        let mut array_3 = object.key("ChangedBlocks").start_array();
          27  +
        for item_4 in var_2 {
          28  +
            {
          29  +
                #[allow(unused_mut)]
          30  +
                let mut object_5 = array_3.value().start_object();
          31  +
                crate::protocol_serde::shape_changed_block::ser_changed_block(
          32  +
                    &mut object_5,
          33  +
                    item_4,
          34  +
                )?;
          35  +
                object_5.finish();
          36  +
            }
          37  +
        }
          38  +
        array_3.finish();
          39  +
    }
          40  +
    if let Some(var_6) = &input.expiry_time {
          41  +
        object
          42  +
            .key("ExpiryTime")
          43  +
            .date_time(var_6, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          44  +
    }
          45  +
    if let Some(var_7) = &input.next_token {
          46  +
        object.key("NextToken").string(var_7.as_str());
          47  +
    }
          48  +
    if let Some(var_8) = &input.volume_size {
          49  +
        object.key("VolumeSize").number(
          50  +
            #[allow(clippy::useless_conversion)]
          51  +
            ::aws_smithy_types::Number::NegInt((var_8.0).into()),
          52  +
        );
          53  +
    }
          54  +
    Ok(())
          55  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_list_snapshot_blocks.rs

@@ -0,1 +0,260 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_list_snapshot_blocks_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::ListSnapshotBlocksInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::list_snapshot_blocks_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let input_string = uri.path();
          23  +
        let (input_string, (_, m1, _)) =
          24  +
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
          25  +
                ::nom::sequence::preceded(
          26  +
                    ::nom::bytes::complete::tag("/"),
          27  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("snapshots"),
          28  +
                ),
          29  +
                ::nom::sequence::preceded(
          30  +
                    ::nom::bytes::complete::tag("/"),
          31  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          32  +
                        ::nom::bytes::complete::take_until("/"),
          33  +
                        ::nom::combinator::rest,
          34  +
                    )),
          35  +
                ),
          36  +
                ::nom::sequence::preceded(
          37  +
                    ::nom::bytes::complete::tag("/"),
          38  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("blocks"),
          39  +
                ),
          40  +
            ))(input_string)?;
          41  +
        debug_assert_eq!("", input_string);
          42  +
        input = input.set_snapshot_id(
          43  +
            crate::protocol_serde::shape_list_snapshot_blocks_input::de_snapshot_id(m1)?,
          44  +
        );
          45  +
        let query_string = uri.query().unwrap_or("");
          46  +
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          47  +
        let mut max_results_seen = false;
          48  +
        let mut next_token_seen = false;
          49  +
        let mut starting_block_index_seen = false;
          50  +
        for (k, v) in pairs {
          51  +
            if !max_results_seen && k == "maxResults" {
          52  +
                input = input.set_max_results(
          53  +
                    crate::protocol_serde::shape_list_snapshot_blocks_input::de_max_results(&v)?,
          54  +
                );
          55  +
                max_results_seen = true;
          56  +
            }
          57  +
            if !next_token_seen && k == "pageToken" {
          58  +
                input = input.set_next_token(
          59  +
                    crate::protocol_serde::shape_list_snapshot_blocks_input::de_next_token(&v)?,
          60  +
                );
          61  +
                next_token_seen = true;
          62  +
            }
          63  +
            if !starting_block_index_seen && k == "startingBlockIndex" {
          64  +
                input = input.set_starting_block_index(
          65  +
                    crate::protocol_serde::shape_list_snapshot_blocks_input::de_starting_block_index(&v)?
          66  +
                );
          67  +
                starting_block_index_seen = true;
          68  +
            }
          69  +
        }
          70  +
        input.build()?
          71  +
    })
          72  +
}
          73  +
          74  +
#[allow(clippy::unnecessary_wraps)]
          75  +
pub fn ser_list_snapshot_blocks_http_response(
          76  +
    #[allow(unused_variables)] output: crate::output::ListSnapshotBlocksOutput,
          77  +
) -> std::result::Result<
          78  +
    ::aws_smithy_legacy_http_server::response::Response,
          79  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          80  +
> {
          81  +
    Ok({
          82  +
        #[allow(unused_mut)]
          83  +
        let mut builder = ::http::Response::builder();
          84  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
            builder,
          86  +
            ::http::header::CONTENT_TYPE,
          87  +
            "application/json",
          88  +
        );
          89  +
        let http_status: u16 = 200;
          90  +
        builder = builder.status(http_status);
          91  +
        let payload =
          92  +
            crate::protocol_serde::shape_list_snapshot_blocks_output::ser_list_snapshot_blocks_output_output_output(&output)?
          93  +
        ;
          94  +
        let content_length = payload.len();
          95  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          96  +
            builder,
          97  +
            ::http::header::CONTENT_LENGTH,
          98  +
            content_length,
          99  +
        );
         100  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         101  +
        builder.body(body)?
         102  +
    })
         103  +
}
         104  +
         105  +
#[allow(clippy::unnecessary_wraps)]
         106  +
pub fn ser_list_snapshot_blocks_http_error(
         107  +
    error: &crate::error::ListSnapshotBlocksError,
         108  +
) -> std::result::Result<
         109  +
    ::aws_smithy_legacy_http_server::response::Response,
         110  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         111  +
> {
         112  +
    Ok({
         113  +
        match error {
         114  +
            crate::error::ListSnapshotBlocksError::InternalServerException(output) => {
         115  +
                let payload = crate::protocol_serde::shape_internal_server_exception::ser_internal_server_exception_error(output)?;
         116  +
                #[allow(unused_mut)]
         117  +
                let mut builder = ::http::Response::builder();
         118  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         119  +
                    builder,
         120  +
                    ::http::header::CONTENT_TYPE,
         121  +
                    "application/json",
         122  +
                );
         123  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         124  +
                    builder,
         125  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         126  +
                    "InternalServerException",
         127  +
                );
         128  +
                let content_length = payload.len();
         129  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         130  +
                    builder,
         131  +
                    ::http::header::CONTENT_LENGTH,
         132  +
                    content_length,
         133  +
                );
         134  +
                builder
         135  +
                    .status(500)
         136  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         137  +
            }
         138  +
            crate::error::ListSnapshotBlocksError::ResourceNotFoundException(output) => {
         139  +
                let payload = crate::protocol_serde::shape_resource_not_found_exception::ser_resource_not_found_exception_error(output)?;
         140  +
                #[allow(unused_mut)]
         141  +
                let mut builder = ::http::Response::builder();
         142  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         143  +
                    builder,
         144  +
                    ::http::header::CONTENT_TYPE,
         145  +
                    "application/json",
         146  +
                );
         147  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         148  +
                    builder,
         149  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         150  +
                    "ResourceNotFoundException",
         151  +
                );
         152  +
                let content_length = payload.len();
         153  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         154  +
                    builder,
         155  +
                    ::http::header::CONTENT_LENGTH,
         156  +
                    content_length,
         157  +
                );
         158  +
                builder
         159  +
                    .status(404)
         160  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         161  +
            }
         162  +
            crate::error::ListSnapshotBlocksError::AccessDeniedException(output) => {
         163  +
                let payload = crate::protocol_serde::shape_access_denied_exception::ser_access_denied_exception_error(output)?;
         164  +
                #[allow(unused_mut)]
         165  +
                let mut builder = ::http::Response::builder();
         166  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         167  +
                    builder,
         168  +
                    ::http::header::CONTENT_TYPE,
         169  +
                    "application/json",
         170  +
                );
         171  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         172  +
                    builder,
         173  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         174  +
                    "AccessDeniedException",
         175  +
                );
         176  +
                let content_length = payload.len();
         177  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         178  +
                    builder,
         179  +
                    ::http::header::CONTENT_LENGTH,
         180  +
                    content_length,
         181  +
                );
         182  +
                builder
         183  +
                    .status(403)
         184  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         185  +
            }
         186  +
            crate::error::ListSnapshotBlocksError::RequestThrottledException(output) => {
         187  +
                let payload = crate::protocol_serde::shape_request_throttled_exception::ser_request_throttled_exception_error(output)?;
         188  +
                #[allow(unused_mut)]
         189  +
                let mut builder = ::http::Response::builder();
         190  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         191  +
                    builder,
         192  +
                    ::http::header::CONTENT_TYPE,
         193  +
                    "application/json",
         194  +
                );
         195  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         196  +
                    builder,
         197  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         198  +
                    "RequestThrottledException",
         199  +
                );
         200  +
                let content_length = payload.len();
         201  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         202  +
                    builder,
         203  +
                    ::http::header::CONTENT_LENGTH,
         204  +
                    content_length,
         205  +
                );
         206  +
                builder
         207  +
                    .status(400)
         208  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         209  +
            }
         210  +
            crate::error::ListSnapshotBlocksError::ServiceQuotaExceededException(output) => {
         211  +
                let payload = crate::protocol_serde::shape_service_quota_exceeded_exception::ser_service_quota_exceeded_exception_error(output)?;
         212  +
                #[allow(unused_mut)]
         213  +
                let mut builder = ::http::Response::builder();
         214  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         215  +
                    builder,
         216  +
                    ::http::header::CONTENT_TYPE,
         217  +
                    "application/json",
         218  +
                );
         219  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         220  +
                    builder,
         221  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         222  +
                    "ServiceQuotaExceededException",
         223  +
                );
         224  +
                let content_length = payload.len();
         225  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         226  +
                    builder,
         227  +
                    ::http::header::CONTENT_LENGTH,
         228  +
                    content_length,
         229  +
                );
         230  +
                builder
         231  +
                    .status(402)
         232  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         233  +
            }
         234  +
            crate::error::ListSnapshotBlocksError::ValidationException(output) => {
         235  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         236  +
                #[allow(unused_mut)]
         237  +
                let mut builder = ::http::Response::builder();
         238  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         239  +
                    builder,
         240  +
                    ::http::header::CONTENT_TYPE,
         241  +
                    "application/json",
         242  +
                );
         243  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         244  +
                    builder,
         245  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         246  +
                    "ValidationException",
         247  +
                );
         248  +
                let content_length = payload.len();
         249  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         250  +
                    builder,
         251  +
                    ::http::header::CONTENT_LENGTH,
         252  +
                    content_length,
         253  +
                );
         254  +
                builder
         255  +
                    .status(400)
         256  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         257  +
            }
         258  +
        }
         259  +
    })
         260  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_list_snapshot_blocks_input.rs

@@ -0,1 +0,42 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_snapshot_id(
           3  +
    value: &str,
           4  +
) -> std::result::Result<
           5  +
    ::std::string::String,
           6  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           7  +
> {
           8  +
    let value = ::percent_encoding::percent_decode_str(value)
           9  +
        .decode_utf8()?
          10  +
        .into_owned();
          11  +
    Ok(value)
          12  +
}
          13  +
          14  +
pub fn de_max_results(
          15  +
    value: &str,
          16  +
) -> std::result::Result<
          17  +
    ::std::option::Option<i32>,
          18  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          19  +
> {
          20  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          21  +
    Ok(Some(value))
          22  +
}
          23  +
          24  +
pub fn de_next_token(
          25  +
    value: &str,
          26  +
) -> std::result::Result<
          27  +
    ::std::option::Option<::std::string::String>,
          28  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          29  +
> {
          30  +
    let value = value.to_owned();
          31  +
    Ok(Some(value))
          32  +
}
          33  +
          34  +
pub fn de_starting_block_index(
          35  +
    value: &str,
          36  +
) -> std::result::Result<
          37  +
    ::std::option::Option<i32>,
          38  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          39  +
> {
          40  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          41  +
    Ok(Some(value))
          42  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_list_snapshot_blocks_output.rs

@@ -0,1 +0,49 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_list_snapshot_blocks_output_output_output(
           3  +
    value: &crate::output::ListSnapshotBlocksOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_list_snapshot_blocks_output::ser_list_snapshot_blocks_output_output(&mut object, value)?;
           8  +
    object.finish();
           9  +
    Ok(out)
          10  +
}
          11  +
          12  +
pub fn ser_list_snapshot_blocks_output_output(
          13  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          14  +
    input: &crate::output::ListSnapshotBlocksOutput,
          15  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          16  +
    if let Some(var_1) = &input.block_size {
          17  +
        object.key("BlockSize").number(
          18  +
            #[allow(clippy::useless_conversion)]
          19  +
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
          20  +
        );
          21  +
    }
          22  +
    if let Some(var_2) = &input.blocks {
          23  +
        let mut array_3 = object.key("Blocks").start_array();
          24  +
        for item_4 in var_2 {
          25  +
            {
          26  +
                #[allow(unused_mut)]
          27  +
                let mut object_5 = array_3.value().start_object();
          28  +
                crate::protocol_serde::shape_block::ser_block(&mut object_5, item_4)?;
          29  +
                object_5.finish();
          30  +
            }
          31  +
        }
          32  +
        array_3.finish();
          33  +
    }
          34  +
    if let Some(var_6) = &input.expiry_time {
          35  +
        object
          36  +
            .key("ExpiryTime")
          37  +
            .date_time(var_6, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          38  +
    }
          39  +
    if let Some(var_7) = &input.next_token {
          40  +
        object.key("NextToken").string(var_7.as_str());
          41  +
    }
          42  +
    if let Some(var_8) = &input.volume_size {
          43  +
        object.key("VolumeSize").number(
          44  +
            #[allow(clippy::useless_conversion)]
          45  +
            ::aws_smithy_types::Number::NegInt((var_8.0).into()),
          46  +
        );
          47  +
    }
          48  +
    Ok(())
          49  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_put_snapshot_block.rs

@@ -0,1 +0,320 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_put_snapshot_block_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::PutSnapshotBlockInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
          12  +
    B::Data: Send,
          13  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          14  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          15  +
{
          16  +
    Ok({
          17  +
        #[allow(unused_mut)]
          18  +
        let mut input = crate::input::put_snapshot_block_input::Builder::default();
          19  +
        #[allow(unused_variables)]
          20  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          21  +
            uri, headers, body, ..
          22  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          23  +
        if let Some(value) = {
          24  +
            Some(
          25  +
                crate::protocol_serde::shape_put_snapshot_block_input::de_block_data_payload(
          26  +
                    &mut body.into().into_inner(),
          27  +
                )?,
          28  +
            )
          29  +
        } {
          30  +
            input = input.set_block_data(value)
          31  +
        }
          32  +
        if let Some(value) =
          33  +
            crate::protocol_serde::shape_put_snapshot_block_input::de_checksum_header(&headers)?
          34  +
        {
          35  +
            input = input.set_checksum(value)
          36  +
        }
          37  +
        if let Some(value) =
          38  +
            crate::protocol_serde::shape_put_snapshot_block_input::de_checksum_algorithm_header(
          39  +
                &headers,
          40  +
            )?
          41  +
        {
          42  +
            input = input.set_checksum_algorithm(value)
          43  +
        }
          44  +
        if let Some(value) =
          45  +
            crate::protocol_serde::shape_put_snapshot_block_input::de_data_length_header(&headers)?
          46  +
        {
          47  +
            input = input.set_data_length(value)
          48  +
        }
          49  +
        if let Some(value) =
          50  +
            crate::protocol_serde::shape_put_snapshot_block_input::de_progress_header(&headers)?
          51  +
        {
          52  +
            input = input.set_progress(Some(value))
          53  +
        }
          54  +
        let input_string = uri.path();
          55  +
        let (input_string, (_, m1, _, m3)) =
          56  +
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
          57  +
                ::nom::sequence::preceded(
          58  +
                    ::nom::bytes::complete::tag("/"),
          59  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("snapshots"),
          60  +
                ),
          61  +
                ::nom::sequence::preceded(
          62  +
                    ::nom::bytes::complete::tag("/"),
          63  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          64  +
                        ::nom::bytes::complete::take_until("/"),
          65  +
                        ::nom::combinator::rest,
          66  +
                    )),
          67  +
                ),
          68  +
                ::nom::sequence::preceded(
          69  +
                    ::nom::bytes::complete::tag("/"),
          70  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("blocks"),
          71  +
                ),
          72  +
                ::nom::sequence::preceded(
          73  +
                    ::nom::bytes::complete::tag("/"),
          74  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          75  +
                        ::nom::bytes::complete::take_until("/"),
          76  +
                        ::nom::combinator::rest,
          77  +
                    )),
          78  +
                ),
          79  +
            ))(input_string)?;
          80  +
        debug_assert_eq!("", input_string);
          81  +
        input = input.set_snapshot_id(
          82  +
            crate::protocol_serde::shape_put_snapshot_block_input::de_snapshot_id(m1)?,
          83  +
        );
          84  +
        input = input.set_block_index(
          85  +
            crate::protocol_serde::shape_put_snapshot_block_input::de_block_index(m3)?,
          86  +
        );
          87  +
        input.build()?
          88  +
    })
          89  +
}
          90  +
          91  +
#[allow(clippy::unnecessary_wraps)]
          92  +
pub fn ser_put_snapshot_block_http_response(
          93  +
    #[allow(unused_variables)] output: crate::output::PutSnapshotBlockOutput,
          94  +
) -> std::result::Result<
          95  +
    ::aws_smithy_legacy_http_server::response::Response,
          96  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          97  +
> {
          98  +
    Ok({
          99  +
        #[allow(unused_mut)]
         100  +
        let mut builder = ::http::Response::builder();
         101  +
        builder = crate::protocol_serde::shape_put_snapshot_block::ser_put_snapshot_block_headers(
         102  +
            &output, builder,
         103  +
        )?;
         104  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         105  +
            builder,
         106  +
            ::http::header::CONTENT_TYPE,
         107  +
            "application/json",
         108  +
        );
         109  +
        let http_status: u16 = 201;
         110  +
        builder = builder.status(http_status);
         111  +
        let payload =
         112  +
            crate::protocol_serde::shape_put_snapshot_block_output::ser_put_snapshot_block_output_output_output(&output)?
         113  +
        ;
         114  +
        let content_length = payload.len();
         115  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
            builder,
         117  +
            ::http::header::CONTENT_LENGTH,
         118  +
            content_length,
         119  +
        );
         120  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         121  +
        builder.body(body)?
         122  +
    })
         123  +
}
         124  +
         125  +
#[allow(clippy::unnecessary_wraps)]
         126  +
pub fn ser_put_snapshot_block_http_error(
         127  +
    error: &crate::error::PutSnapshotBlockError,
         128  +
) -> std::result::Result<
         129  +
    ::aws_smithy_legacy_http_server::response::Response,
         130  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         131  +
> {
         132  +
    Ok({
         133  +
        match error {
         134  +
            crate::error::PutSnapshotBlockError::InternalServerException(output) => {
         135  +
                let payload = crate::protocol_serde::shape_internal_server_exception::ser_internal_server_exception_error(output)?;
         136  +
                #[allow(unused_mut)]
         137  +
                let mut builder = ::http::Response::builder();
         138  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         139  +
                    builder,
         140  +
                    ::http::header::CONTENT_TYPE,
         141  +
                    "application/json",
         142  +
                );
         143  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         144  +
                    builder,
         145  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         146  +
                    "InternalServerException",
         147  +
                );
         148  +
                let content_length = payload.len();
         149  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         150  +
                    builder,
         151  +
                    ::http::header::CONTENT_LENGTH,
         152  +
                    content_length,
         153  +
                );
         154  +
                builder
         155  +
                    .status(500)
         156  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         157  +
            }
         158  +
            crate::error::PutSnapshotBlockError::ResourceNotFoundException(output) => {
         159  +
                let payload = crate::protocol_serde::shape_resource_not_found_exception::ser_resource_not_found_exception_error(output)?;
         160  +
                #[allow(unused_mut)]
         161  +
                let mut builder = ::http::Response::builder();
         162  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         163  +
                    builder,
         164  +
                    ::http::header::CONTENT_TYPE,
         165  +
                    "application/json",
         166  +
                );
         167  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         168  +
                    builder,
         169  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         170  +
                    "ResourceNotFoundException",
         171  +
                );
         172  +
                let content_length = payload.len();
         173  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         174  +
                    builder,
         175  +
                    ::http::header::CONTENT_LENGTH,
         176  +
                    content_length,
         177  +
                );
         178  +
                builder
         179  +
                    .status(404)
         180  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         181  +
            }
         182  +
            crate::error::PutSnapshotBlockError::AccessDeniedException(output) => {
         183  +
                let payload = crate::protocol_serde::shape_access_denied_exception::ser_access_denied_exception_error(output)?;
         184  +
                #[allow(unused_mut)]
         185  +
                let mut builder = ::http::Response::builder();
         186  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         187  +
                    builder,
         188  +
                    ::http::header::CONTENT_TYPE,
         189  +
                    "application/json",
         190  +
                );
         191  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         192  +
                    builder,
         193  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         194  +
                    "AccessDeniedException",
         195  +
                );
         196  +
                let content_length = payload.len();
         197  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         198  +
                    builder,
         199  +
                    ::http::header::CONTENT_LENGTH,
         200  +
                    content_length,
         201  +
                );
         202  +
                builder
         203  +
                    .status(403)
         204  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         205  +
            }
         206  +
            crate::error::PutSnapshotBlockError::RequestThrottledException(output) => {
         207  +
                let payload = crate::protocol_serde::shape_request_throttled_exception::ser_request_throttled_exception_error(output)?;
         208  +
                #[allow(unused_mut)]
         209  +
                let mut builder = ::http::Response::builder();
         210  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         211  +
                    builder,
         212  +
                    ::http::header::CONTENT_TYPE,
         213  +
                    "application/json",
         214  +
                );
         215  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         216  +
                    builder,
         217  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         218  +
                    "RequestThrottledException",
         219  +
                );
         220  +
                let content_length = payload.len();
         221  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         222  +
                    builder,
         223  +
                    ::http::header::CONTENT_LENGTH,
         224  +
                    content_length,
         225  +
                );
         226  +
                builder
         227  +
                    .status(400)
         228  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         229  +
            }
         230  +
            crate::error::PutSnapshotBlockError::ServiceQuotaExceededException(output) => {
         231  +
                let payload = crate::protocol_serde::shape_service_quota_exceeded_exception::ser_service_quota_exceeded_exception_error(output)?;
         232  +
                #[allow(unused_mut)]
         233  +
                let mut builder = ::http::Response::builder();
         234  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         235  +
                    builder,
         236  +
                    ::http::header::CONTENT_TYPE,
         237  +
                    "application/json",
         238  +
                );
         239  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         240  +
                    builder,
         241  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         242  +
                    "ServiceQuotaExceededException",
         243  +
                );
         244  +
                let content_length = payload.len();
         245  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         246  +
                    builder,
         247  +
                    ::http::header::CONTENT_LENGTH,
         248  +
                    content_length,
         249  +
                );
         250  +
                builder
         251  +
                    .status(402)
         252  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         253  +
            }
         254  +
            crate::error::PutSnapshotBlockError::ValidationException(output) => {
         255  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         256  +
                #[allow(unused_mut)]
         257  +
                let mut builder = ::http::Response::builder();
         258  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         259  +
                    builder,
         260  +
                    ::http::header::CONTENT_TYPE,
         261  +
                    "application/json",
         262  +
                );
         263  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         264  +
                    builder,
         265  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         266  +
                    "ValidationException",
         267  +
                );
         268  +
                let content_length = payload.len();
         269  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         270  +
                    builder,
         271  +
                    ::http::header::CONTENT_LENGTH,
         272  +
                    content_length,
         273  +
                );
         274  +
                builder
         275  +
                    .status(400)
         276  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         277  +
            }
         278  +
        }
         279  +
    })
         280  +
}
         281  +
         282  +
pub fn ser_put_snapshot_block_headers(
         283  +
    input: &crate::output::PutSnapshotBlockOutput,
         284  +
    mut builder: ::http::response::Builder,
         285  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         286  +
{
         287  +
    if let ::std::option::Option::Some(inner_1) = &input.checksum_algorithm {
         288  +
        let formatted_2 = inner_1.as_str();
         289  +
        if !formatted_2.is_empty() {
         290  +
            let header_value = formatted_2;
         291  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         292  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         293  +
                    "checksum_algorithm",
         294  +
                    format!(
         295  +
                        "`{}` cannot be used as a header value: {}",
         296  +
                        &header_value, err
         297  +
                    ),
         298  +
                )
         299  +
            })?;
         300  +
            builder = builder.header("x-amz-Checksum-Algorithm", header_value);
         301  +
        }
         302  +
    }
         303  +
    if let ::std::option::Option::Some(inner_3) = &input.checksum {
         304  +
        let formatted_4 = inner_3.as_str();
         305  +
        if !formatted_4.is_empty() {
         306  +
            let header_value = formatted_4;
         307  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         308  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         309  +
                    "checksum",
         310  +
                    format!(
         311  +
                        "`{}` cannot be used as a header value: {}",
         312  +
                        &header_value, err
         313  +
                    ),
         314  +
                )
         315  +
            })?;
         316  +
            builder = builder.header("x-amz-Checksum", header_value);
         317  +
        }
         318  +
    }
         319  +
    Ok(builder)
         320  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_put_snapshot_block_input.rs

@@ -0,1 +0,87 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_block_data_payload(
           3  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           4  +
) -> std::result::Result<
           5  +
    ::aws_smithy_types::byte_stream::ByteStream,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
> {
           8  +
    // replace the body with an empty body
           9  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          10  +
    Ok(::aws_smithy_types::byte_stream::ByteStream::new(body))
          11  +
}
          12  +
          13  +
pub(crate) fn de_checksum_header(
          14  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          15  +
) -> ::std::result::Result<
          16  +
    ::std::option::Option<::std::string::String>,
          17  +
    ::aws_smithy_legacy_http::header::ParseError,
          18  +
> {
          19  +
    let headers = header_map.get_all("x-amz-Checksum");
          20  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          21  +
}
          22  +
          23  +
pub(crate) fn de_checksum_algorithm_header(
          24  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          25  +
) -> ::std::result::Result<
          26  +
    ::std::option::Option<::std::string::String>,
          27  +
    ::aws_smithy_legacy_http::header::ParseError,
          28  +
> {
          29  +
    let headers = header_map.get_all("x-amz-Checksum-Algorithm");
          30  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          31  +
}
          32  +
          33  +
pub(crate) fn de_data_length_header(
          34  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          35  +
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_legacy_http::header::ParseError>
          36  +
{
          37  +
    let headers = header_map.get_all("x-amz-Data-Length");
          38  +
    let var_1 = ::aws_smithy_legacy_http::header::read_many_primitive::<i32>(headers)?;
          39  +
    if var_1.len() > 1 {
          40  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          41  +
            "expected one item but found {}",
          42  +
            var_1.len()
          43  +
        )))
          44  +
    } else {
          45  +
        let mut var_1 = var_1;
          46  +
        Ok(var_1.pop())
          47  +
    }
          48  +
}
          49  +
          50  +
pub(crate) fn de_progress_header(
          51  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          52  +
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_legacy_http::header::ParseError>
          53  +
{
          54  +
    let headers = header_map.get_all("x-amz-Progress");
          55  +
    let var_2 = ::aws_smithy_legacy_http::header::read_many_primitive::<i32>(headers)?;
          56  +
    if var_2.len() > 1 {
          57  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          58  +
            "expected one item but found {}",
          59  +
            var_2.len()
          60  +
        )))
          61  +
    } else {
          62  +
        let mut var_2 = var_2;
          63  +
        Ok(var_2.pop())
          64  +
    }
          65  +
}
          66  +
          67  +
pub fn de_snapshot_id(
          68  +
    value: &str,
          69  +
) -> std::result::Result<
          70  +
    ::std::string::String,
          71  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          72  +
> {
          73  +
    let value = ::percent_encoding::percent_decode_str(value)
          74  +
        .decode_utf8()?
          75  +
        .into_owned();
          76  +
    Ok(value)
          77  +
}
          78  +
          79  +
pub fn de_block_index(
          80  +
    value: &str,
          81  +
) -> std::result::Result<
          82  +
    i32,
          83  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          84  +
> {
          85  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          86  +
    Ok(value)
          87  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_put_snapshot_block_output.rs

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_put_snapshot_block_output_output_output(
           3  +
    value: &crate::output::PutSnapshotBlockOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_put_snapshot_block_output::ser_put_snapshot_block_output_output(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_put_snapshot_block_output_output(
          16  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    #[allow(unused_variables)] input: &crate::output::PutSnapshotBlockOutput,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    Ok(())
          20  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_request_throttled_exception.rs

@@ -0,1 +0,26 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_request_throttled_exception_error(
           3  +
    value: &crate::error::RequestThrottledException,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_request_throttled_exception::ser_request_throttled_exception(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_request_throttled_exception(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::error::RequestThrottledException,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    if let Some(var_1) = &input.message {
          20  +
        object.key("Message").string(var_1.as_str());
          21  +
    }
          22  +
    if let Some(var_2) = &input.reason {
          23  +
        object.key("Reason").string(var_2.as_str());
          24  +
    }
          25  +
    Ok(())
          26  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_resource_not_found_exception.rs

@@ -0,1 +0,26 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_resource_not_found_exception_error(
           3  +
    value: &crate::error::ResourceNotFoundException,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_resource_not_found_exception::ser_resource_not_found_exception(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_resource_not_found_exception(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::error::ResourceNotFoundException,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    if let Some(var_1) = &input.message {
          20  +
        object.key("Message").string(var_1.as_str());
          21  +
    }
          22  +
    if let Some(var_2) = &input.reason {
          23  +
        object.key("Reason").string(var_2.as_str());
          24  +
    }
          25  +
    Ok(())
          26  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_service_quota_exceeded_exception.rs

@@ -0,1 +0,23 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_service_quota_exceeded_exception_error(
           3  +
    value: &crate::error::ServiceQuotaExceededException,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_service_quota_exceeded_exception::ser_service_quota_exceeded_exception(&mut object, value)?;
           8  +
    object.finish();
           9  +
    Ok(out)
          10  +
}
          11  +
          12  +
pub fn ser_service_quota_exceeded_exception(
          13  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          14  +
    input: &crate::error::ServiceQuotaExceededException,
          15  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          16  +
    if let Some(var_1) = &input.message {
          17  +
        object.key("Message").string(var_1.as_str());
          18  +
    }
          19  +
    if let Some(var_2) = &input.reason {
          20  +
        object.key("Reason").string(var_2.as_str());
          21  +
    }
          22  +
    Ok(())
          23  +
}

tmp-codegen-diff/codegen-server-test/ebs-http0x/rust-server-codegen/src/protocol_serde/shape_start_snapshot.rs

@@ -0,1 +0,380 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_start_snapshot_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::StartSnapshotInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::start_snapshot_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          23  +
        if !bytes.is_empty() {
          24  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          25  +
                &headers,
          26  +
                Some("application/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_start_snapshot::de_start_snapshot(
          29  +
                bytes.as_ref(),
          30  +
                input,
          31  +
            )?;
          32  +
        }
          33  +
        input.build()?
          34  +
    })
          35  +
}
          36  +
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
pub fn ser_start_snapshot_http_response(
          39  +
    #[allow(unused_variables)] output: crate::output::StartSnapshotOutput,
          40  +
) -> std::result::Result<
          41  +
    ::aws_smithy_legacy_http_server::response::Response,
          42  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          43  +
> {
          44  +
    Ok({
          45  +
        #[allow(unused_mut)]
          46  +
        let mut builder = ::http::Response::builder();
          47  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          48  +
            builder,
          49  +
            ::http::header::CONTENT_TYPE,
          50  +
            "application/json",
          51  +
        );
          52  +
        let http_status: u16 = 201;
          53  +
        builder = builder.status(http_status);
          54  +
        let payload =
          55  +
            crate::protocol_serde::shape_start_snapshot_output::ser_start_snapshot_output_output_output(&output)?
          56  +
        ;
          57  +
        let content_length = payload.len();
          58  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          59  +
            builder,
          60  +
            ::http::header::CONTENT_LENGTH,
          61  +
            content_length,
          62  +
        );
          63  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          64  +
        builder.body(body)?
          65  +
    })
          66  +
}
          67  +
          68  +
#[allow(clippy::unnecessary_wraps)]
          69  +
pub fn ser_start_snapshot_http_error(
          70  +
    error: &crate::error::StartSnapshotError,
          71  +
) -> std::result::Result<
          72  +
    ::aws_smithy_legacy_http_server::response::Response,
          73  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          74  +
> {
          75  +
    Ok({
          76  +
        match error {
          77  +
            crate::error::StartSnapshotError::InternalServerException(output) => {
          78  +
                let payload = crate::protocol_serde::shape_internal_server_exception::ser_internal_server_exception_error(output)?;
          79  +
                #[allow(unused_mut)]
          80  +
                let mut builder = ::http::Response::builder();
          81  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
                    builder,
          83  +
                    ::http::header::CONTENT_TYPE,
          84  +
                    "application/json",
          85  +
                );
          86  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          87  +
                    builder,
          88  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          89  +
                    "InternalServerException",
          90  +
                );
          91  +
                let content_length = payload.len();
          92  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          93  +
                    builder,
          94  +
                    ::http::header::CONTENT_LENGTH,
          95  +
                    content_length,
          96  +
                );
          97  +
                builder
          98  +
                    .status(500)
          99  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         100  +
            }
         101  +
            crate::error::StartSnapshotError::ResourceNotFoundException(output) => {
         102  +
                let payload = crate::protocol_serde::shape_resource_not_found_exception::ser_resource_not_found_exception_error(output)?;
         103  +
                #[allow(unused_mut)]
         104  +
                let mut builder = ::http::Response::builder();
         105  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         106  +
                    builder,
         107  +
                    ::http::header::CONTENT_TYPE,
         108  +
                    "application/json",
         109  +
                );
         110  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         111  +
                    builder,
         112  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         113  +
                    "ResourceNotFoundException",
         114  +
                );
         115  +
                let content_length = payload.len();
         116  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         117  +
                    builder,
         118  +
                    ::http::header::CONTENT_LENGTH,
         119  +
                    content_length,
         120  +
                );
         121  +
                builder
         122  +
                    .status(404)
         123  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         124  +
            }
         125  +
            crate::error::StartSnapshotError::AccessDeniedException(output) => {
         126  +
                let payload = crate::protocol_serde::shape_access_denied_exception::ser_access_denied_exception_error(output)?;
         127  +
                #[allow(unused_mut)]
         128  +
                let mut builder = ::http::Response::builder();
         129  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         130  +
                    builder,
         131  +
                    ::http::header::CONTENT_TYPE,
         132  +
                    "application/json",
         133  +
                );
         134  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         135  +
                    builder,
         136  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         137  +
                    "AccessDeniedException",
         138  +
                );
         139  +
                let content_length = payload.len();
         140  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         141  +
                    builder,
         142  +
                    ::http::header::CONTENT_LENGTH,
         143  +
                    content_length,
         144  +
                );
         145  +
                builder
         146  +
                    .status(403)
         147  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         148  +
            }
         149  +
            crate::error::StartSnapshotError::ConflictException(output) => {
         150  +
                let payload =
         151  +
                    crate::protocol_serde::shape_conflict_exception::ser_conflict_exception_error(
         152  +
                        output,
         153  +
                    )?;
         154  +
                #[allow(unused_mut)]
         155  +
                let mut builder = ::http::Response::builder();
         156  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         157  +
                    builder,
         158  +
                    ::http::header::CONTENT_TYPE,
         159  +
                    "application/json",
         160  +
                );
         161  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         162  +
                    builder,
         163  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         164  +
                    "ConflictException",
         165  +
                );
         166  +
                let content_length = payload.len();
         167  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         168  +
                    builder,
         169  +
                    ::http::header::CONTENT_LENGTH,
         170  +
                    content_length,
         171  +
                );
         172  +
                builder
         173  +
                    .status(503)
         174  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         175  +
            }
         176  +
            crate::error::StartSnapshotError::RequestThrottledException(output) => {
         177  +
                let payload = crate::protocol_serde::shape_request_throttled_exception::ser_request_throttled_exception_error(output)?;
         178  +
                #[allow(unused_mut)]
         179  +
                let mut builder = ::http::Response::builder();
         180  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         181  +
                    builder,
         182  +
                    ::http::header::CONTENT_TYPE,
         183  +
                    "application/json",
         184  +
                );
         185  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         186  +
                    builder,
         187  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         188  +
                    "RequestThrottledException",
         189  +
                );
         190  +
                let content_length = payload.len();
         191  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         192  +
                    builder,
         193  +
                    ::http::header::CONTENT_LENGTH,
         194  +
                    content_length,
         195  +
                );
         196  +
                builder
         197  +
                    .status(400)
         198  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         199  +
            }
         200  +
            crate::error::StartSnapshotError::ServiceQuotaExceededException(output) => {
         201  +
                let payload = crate::protocol_serde::shape_service_quota_exceeded_exception::ser_service_quota_exceeded_exception_error(output)?;
         202  +
                #[allow(unused_mut)]
         203  +
                let mut builder = ::http::Response::builder();
         204  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         205  +
                    builder,
         206  +
                    ::http::header::CONTENT_TYPE,
         207  +
                    "application/json",
         208  +
                );
         209  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         210  +
                    builder,
         211  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         212  +
                    "ServiceQuotaExceededException",
         213  +
                );
         214  +
                let content_length = payload.len();
         215  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         216  +
                    builder,
         217  +
                    ::http::header::CONTENT_LENGTH,
         218  +
                    content_length,
         219  +
                );
         220  +
                builder
         221  +
                    .status(402)
         222  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         223  +
            }
         224  +
            crate::error::StartSnapshotError::ConcurrentLimitExceededException(output) => {
         225  +
                let payload = crate::protocol_serde::shape_concurrent_limit_exceeded_exception::ser_concurrent_limit_exceeded_exception_error(output)?;
         226  +
                #[allow(unused_mut)]
         227  +
                let mut builder = ::http::Response::builder();
         228  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         229  +
                    builder,
         230  +
                    ::http::header::CONTENT_TYPE,
         231  +
                    "application/json",
         232  +
                );
         233  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         234  +
                    builder,
         235  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         236  +
                    "ConcurrentLimitExceededException",
         237  +
                );
         238  +
                let content_length = payload.len();
         239  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         240  +
                    builder,
         241  +
                    ::http::header::CONTENT_LENGTH,
         242  +
                    content_length,
         243  +
                );
         244  +
                builder
         245  +
                    .status(400)
         246  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         247  +
            }
         248  +
            crate::error::StartSnapshotError::ValidationException(output) => {
         249  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         250  +
                #[allow(unused_mut)]
         251  +
                let mut builder = ::http::Response::builder();
         252  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         253  +
                    builder,
         254  +
                    ::http::header::CONTENT_TYPE,
         255  +
                    "application/json",
         256  +
                );
         257  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         258  +
                    builder,
         259  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         260  +
                    "ValidationException",
         261  +
                );
         262  +
                let content_length = payload.len();
         263  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         264  +
                    builder,
         265  +
                    ::http::header::CONTENT_LENGTH,
         266  +
                    content_length,
         267  +
                );
         268  +
                builder
         269  +
                    .status(400)
         270  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         271  +
            }
         272  +
        }
         273  +
    })
         274  +
}
         275  +
         276  +
pub(crate) fn de_start_snapshot(
         277  +
    value: &[u8],
         278  +
    mut builder: crate::input::start_snapshot_input::Builder,
         279  +
) -> ::std::result::Result<
         280  +
    crate::input::start_snapshot_input::Builder,
         281  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         282  +
> {
         283  +
    let mut tokens_owned =
         284  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         285  +
            .peekable();
         286  +
    let tokens = &mut tokens_owned;
         287  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         288  +
    loop {
         289  +
        match tokens.next().transpose()? {
         290  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         291  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         292  +
                match key.to_unescaped()?.as_ref() {
         293  +
                    "ClientToken" => {
         294  +
                        builder = builder.set_client_token(
         295  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         296  +
                                tokens.next(),
         297  +
                            )?
         298  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         299  +
                            .transpose()?,
         300  +
                        );
         301  +
                    }
         302  +
                    "Description" => {
         303  +
                        builder = builder.set_description(
         304  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         305  +
                                tokens.next(),
         306  +
                            )?
         307  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         308  +
                            .transpose()?,
         309  +
                        );
         310  +
                    }
         311  +
                    "Encrypted" => {
         312  +
                        builder = builder.set_encrypted(
         313  +
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
         314  +
                                tokens.next(),
         315  +
                            )?,
         316  +
                        );
         317  +
                    }
         318  +
                    "KmsKeyArn" => {
         319  +
                        builder = builder.set_kms_key_arn(
         320  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         321  +
                                tokens.next(),
         322  +
                            )?
         323  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         324  +
                            .transpose()?,
         325  +
                        );
         326  +
                    }
         327  +
                    "ParentSnapshotId" => {
         328  +
                        builder = builder.set_parent_snapshot_id(
         329  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         330  +
                                tokens.next(),
         331  +
                            )?
         332  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         333  +
                            .transpose()?,
         334  +
                        );
         335  +
                    }
         336  +
                    "Tags" => {
         337  +
                        builder =
         338  +
                            builder.set_tags(crate::protocol_serde::shape_tags::de_tags(tokens)?);
         339  +
                    }
         340  +
                    "Timeout" => {
         341  +
                        builder = builder.set_timeout(
         342  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         343  +
                                tokens.next(),
         344  +
                            )?
         345  +
                            .map(i32::try_from)
         346  +
                            .transpose()?,
         347  +
                        );
         348  +
                    }
         349  +
                    "VolumeSize" => {
         350  +
                        if let Some(v) =
         351  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         352  +
                                tokens.next(),
         353  +
                            )?
         354  +
                            .map(i64::try_from)
         355  +
                            .transpose()?
         356  +
                        {
         357  +
                            builder = builder.set_volume_size(v);
         358  +
                        }
         359  +
                    }
         360  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         361  +
                }
         362  +
            }
         363  +
            other => {
         364  +
                return Err(
         365  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         366  +
                        "expected object key or end object, found: {other:?}"
         367  +
                    )),
         368  +
                )
         369  +
            }
         370  +
        }
         371  +
    }
         372  +
    if tokens.next().is_some() {
         373  +
        return Err(
         374  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         375  +
                "found more JSON tokens after completing parsing",
         376  +
            ),
         377  +
        );
         378  +
    }
         379  +
    Ok(builder)
         380  +
}