Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_simple_struct_operation_output.rs

@@ -0,1 +0,99 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_simple_struct_operation_output_output_output(
           3  +
    value: &crate::output::SimpleStructOperationOutput,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut encoder = ::aws_smithy_cbor::Encoder::new(::std::vec::Vec::new());
           9  +
    {
          10  +
        let encoder = &mut encoder;
          11  +
        crate::protocol_serde::shape_simple_struct_operation_output::ser_simple_struct_operation_output_output(encoder, value )?;
          12  +
    }
          13  +
    ::std::result::Result::Ok(encoder.into_writer())
          14  +
}
          15  +
          16  +
pub fn ser_simple_struct_operation_output_output(
          17  +
    encoder: &mut ::aws_smithy_cbor::Encoder,
          18  +
    #[allow(unused)] input: &crate::output::SimpleStructOperationOutput,
          19  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          20  +
    encoder.begin_map();
          21  +
    if let Some(var_1) = &input.blob {
          22  +
        encoder.str("blob").blob(var_1);
          23  +
    }
          24  +
    if let Some(var_2) = &input.boolean {
          25  +
        encoder.str("boolean").boolean(*var_2);
          26  +
    }
          27  +
    if let Some(var_3) = &input.string {
          28  +
        encoder.str("string").str(var_3.as_str());
          29  +
    }
          30  +
    if let Some(var_4) = &input.byte {
          31  +
        encoder.str("byte").byte(*var_4);
          32  +
    }
          33  +
    if let Some(var_5) = &input.short {
          34  +
        encoder.str("short").short(*var_5);
          35  +
    }
          36  +
    if let Some(var_6) = &input.integer {
          37  +
        encoder.str("integer").integer(*var_6);
          38  +
    }
          39  +
    if let Some(var_7) = &input.long {
          40  +
        encoder.str("long").long(*var_7);
          41  +
    }
          42  +
    if let Some(var_8) = &input.float {
          43  +
        encoder.str("float").float(*var_8);
          44  +
    }
          45  +
    if let Some(var_9) = &input.double {
          46  +
        encoder.str("double").double(*var_9);
          47  +
    }
          48  +
    if let Some(var_10) = &input.timestamp {
          49  +
        encoder.str("timestamp").timestamp(var_10);
          50  +
    }
          51  +
    if let Some(var_11) = &input.r#enum {
          52  +
        encoder.str("enum").str(var_11.as_str());
          53  +
    }
          54  +
    {
          55  +
        encoder.str("requiredBlob").blob(&input.required_blob);
          56  +
    }
          57  +
    {
          58  +
        encoder
          59  +
            .str("requiredBoolean")
          60  +
            .boolean(input.required_boolean);
          61  +
    }
          62  +
    {
          63  +
        encoder
          64  +
            .str("requiredString")
          65  +
            .str(input.required_string.as_str());
          66  +
    }
          67  +
    {
          68  +
        encoder.str("requiredByte").byte(input.required_byte);
          69  +
    }
          70  +
    {
          71  +
        encoder.str("requiredShort").short(input.required_short);
          72  +
    }
          73  +
    {
          74  +
        encoder
          75  +
            .str("requiredInteger")
          76  +
            .integer(input.required_integer);
          77  +
    }
          78  +
    {
          79  +
        encoder.str("requiredLong").long(input.required_long);
          80  +
    }
          81  +
    {
          82  +
        encoder.str("requiredFloat").float(input.required_float);
          83  +
    }
          84  +
    {
          85  +
        encoder.str("requiredDouble").double(input.required_double);
          86  +
    }
          87  +
    {
          88  +
        encoder
          89  +
            .str("requiredTimestamp")
          90  +
            .timestamp(&input.required_timestamp);
          91  +
    }
          92  +
    {
          93  +
        encoder
          94  +
            .str("requiredEnum")
          95  +
            .str(input.required_enum.as_str());
          96  +
    }
          97  +
    encoder.end();
          98  +
    Ok(())
          99  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_simple_union.rs

@@ -0,1 +0,73 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_simple_union(
           3  +
    decoder: &mut ::aws_smithy_cbor::Decoder,
           4  +
) -> ::std::result::Result<crate::model::SimpleUnion, ::aws_smithy_cbor::decode::DeserializeError> {
           5  +
    fn pair(
           6  +
        decoder: &mut ::aws_smithy_cbor::Decoder,
           7  +
    ) -> ::std::result::Result<crate::model::SimpleUnion, ::aws_smithy_cbor::decode::DeserializeError>
           8  +
    {
           9  +
        Ok(match decoder.str()?.as_ref() {
          10  +
            "blob" => crate::model::SimpleUnion::Blob(decoder.blob()?),
          11  +
            "boolean" => crate::model::SimpleUnion::Boolean(decoder.boolean()?),
          12  +
            "string" => crate::model::SimpleUnion::String(decoder.string()?),
          13  +
            "unit" => {
          14  +
                decoder.skip()?;
          15  +
                crate::model::SimpleUnion::Unit
          16  +
            }
          17  +
            variant => {
          18  +
                return Err(
          19  +
                    ::aws_smithy_cbor::decode::DeserializeError::unknown_union_variant(
          20  +
                        variant,
          21  +
                        decoder.position(),
          22  +
                    ),
          23  +
                )
          24  +
            }
          25  +
        })
          26  +
    }
          27  +
          28  +
    match decoder.map()? {
          29  +
        None => {
          30  +
            let variant = pair(decoder)?;
          31  +
            match decoder.datatype()? {
          32  +
                ::aws_smithy_cbor::data::Type::Break => {
          33  +
                    decoder.skip()?;
          34  +
                    Ok(variant)
          35  +
                }
          36  +
                ty => Err(
          37  +
                    ::aws_smithy_cbor::decode::DeserializeError::unexpected_union_variant(
          38  +
                        ty,
          39  +
                        decoder.position(),
          40  +
                    ),
          41  +
                ),
          42  +
            }
          43  +
        }
          44  +
        Some(1) => pair(decoder),
          45  +
        Some(_) => Err(
          46  +
            ::aws_smithy_cbor::decode::DeserializeError::mixed_union_variants(decoder.position()),
          47  +
        ),
          48  +
    }
          49  +
}
          50  +
          51  +
pub fn ser_simple_union(
          52  +
    encoder: &mut ::aws_smithy_cbor::Encoder,
          53  +
    input: &crate::model::SimpleUnion,
          54  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          55  +
    encoder.map(1);
          56  +
    match input {
          57  +
        crate::model::SimpleUnion::Blob(inner) => {
          58  +
            encoder.str("blob").blob(inner);
          59  +
        }
          60  +
        crate::model::SimpleUnion::Boolean(inner) => {
          61  +
            encoder.str("boolean").boolean(*inner);
          62  +
        }
          63  +
        crate::model::SimpleUnion::String(inner) => {
          64  +
            encoder.str("string").str(inner.as_str());
          65  +
        }
          66  +
        crate::model::SimpleUnion::Unit => {
          67  +
            encoder.str("unit");
          68  +
            encoder.begin_map();
          69  +
            encoder.end();
          70  +
        }
          71  +
    }
          72  +
    ::std::result::Result::Ok(())
          73  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_single_member_struct_operation.rs

@@ -0,1 +0,127 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_single_member_struct_operation_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::SingleMemberStructOperationInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::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::rpc_v2_cbor::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::single_member_struct_operation_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/cbor"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_single_member_struct_operation::de_single_member_struct_operation(bytes.as_ref(), input)?;
          29  +
        }
          30  +
        input.build()
          31  +
    })
          32  +
}
          33  +
          34  +
#[allow(clippy::unnecessary_wraps)]
          35  +
pub fn ser_single_member_struct_operation_http_response(
          36  +
    #[allow(unused_variables)] output: crate::output::SingleMemberStructOperationOutput,
          37  +
) -> std::result::Result<
          38  +
    ::aws_smithy_legacy_http_server::response::Response,
          39  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
          40  +
> {
          41  +
    Ok({
          42  +
        #[allow(unused_mut)]
          43  +
        let mut builder = ::http::Response::builder();
          44  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          45  +
            builder,
          46  +
            ::http::header::CONTENT_TYPE,
          47  +
            "application/cbor",
          48  +
        );
          49  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          50  +
            builder,
          51  +
            ::http::header::HeaderName::from_static("smithy-protocol"),
          52  +
            "rpc-v2-cbor",
          53  +
        );
          54  +
        let http_status: u16 = 200;
          55  +
        builder = builder.status(http_status);
          56  +
        let payload =
          57  +
            crate::protocol_serde::shape_single_member_struct_operation_output::ser_single_member_struct_operation_output_output_output(&output)?
          58  +
        ;
          59  +
        let content_length = payload.len();
          60  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          61  +
            builder,
          62  +
            ::http::header::CONTENT_LENGTH,
          63  +
            content_length,
          64  +
        );
          65  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          66  +
        builder.body(body)?
          67  +
    })
          68  +
}
          69  +
          70  +
pub(crate) fn de_single_member_struct_operation(
          71  +
    value: &[u8],
          72  +
    mut builder: crate::input::single_member_struct_operation_input::Builder,
          73  +
) -> ::std::result::Result<
          74  +
    crate::input::single_member_struct_operation_input::Builder,
          75  +
    ::aws_smithy_cbor::decode::DeserializeError,
          76  +
> {
          77  +
    #[allow(clippy::match_single_binding)]
          78  +
    fn pair(
          79  +
        mut builder: crate::input::single_member_struct_operation_input::Builder,
          80  +
        decoder: &mut ::aws_smithy_cbor::Decoder,
          81  +
    ) -> ::std::result::Result<
          82  +
        crate::input::single_member_struct_operation_input::Builder,
          83  +
        ::aws_smithy_cbor::decode::DeserializeError,
          84  +
    > {
          85  +
        builder = match decoder.str()?.as_ref() {
          86  +
            "message" => {
          87  +
                ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
          88  +
                    Ok(builder.set_message(Some(decoder.string()?)))
          89  +
                })?
          90  +
            }
          91  +
            _ => {
          92  +
                decoder.skip()?;
          93  +
                builder
          94  +
            }
          95  +
        };
          96  +
        Ok(builder)
          97  +
    }
          98  +
          99  +
    let decoder = &mut ::aws_smithy_cbor::Decoder::new(value);
         100  +
         101  +
    match decoder.map()? {
         102  +
        None => loop {
         103  +
            match decoder.datatype()? {
         104  +
                ::aws_smithy_cbor::data::Type::Break => {
         105  +
                    decoder.skip()?;
         106  +
                    break;
         107  +
                }
         108  +
                _ => {
         109  +
                    builder = pair(builder, decoder)?;
         110  +
                }
         111  +
            };
         112  +
        },
         113  +
        Some(n) => {
         114  +
            for _ in 0..n {
         115  +
                builder = pair(builder, decoder)?;
         116  +
            }
         117  +
        }
         118  +
    };
         119  +
         120  +
    if decoder.position() != value.len() {
         121  +
        return Err(
         122  +
            ::aws_smithy_cbor::decode::DeserializeError::expected_end_of_stream(decoder.position()),
         123  +
        );
         124  +
    }
         125  +
         126  +
    Ok(builder)
         127  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_single_member_struct_operation_output.rs

@@ -0,1 +0,26 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_single_member_struct_operation_output_output_output(
           3  +
    value: &crate::output::SingleMemberStructOperationOutput,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut encoder = ::aws_smithy_cbor::Encoder::new(::std::vec::Vec::new());
           9  +
    {
          10  +
        let encoder = &mut encoder;
          11  +
        crate::protocol_serde::shape_single_member_struct_operation_output::ser_single_member_struct_operation_output_output(encoder, value )?;
          12  +
    }
          13  +
    ::std::result::Result::Ok(encoder.into_writer())
          14  +
}
          15  +
          16  +
pub fn ser_single_member_struct_operation_output_output(
          17  +
    encoder: &mut ::aws_smithy_cbor::Encoder,
          18  +
    #[allow(unused)] input: &crate::output::SingleMemberStructOperationOutput,
          19  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          20  +
    encoder.begin_map();
          21  +
    if let Some(var_1) = &input.message {
          22  +
        encoder.str("message").str(var_1.as_str());
          23  +
    }
          24  +
    encoder.end();
          25  +
    Ok(())
          26  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation.rs

@@ -0,1 +0,134 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_streaming_operation_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::StreamingOperationInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::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::rpc_v2_cbor::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::streaming_operation_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  +
            let mut receiver =
          25  +
                crate::protocol_serde::shape_streaming_operation_input::de_events_payload(
          26  +
                    &mut body.into().into_inner(),
          27  +
                )?;
          28  +
            if let Some(_initial_event) = receiver
          29  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          30  +
                                                .await
          31  +
                                                .map_err(
          32  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::ConstraintViolation(
          33  +
                                                        #[allow(clippy::useless_conversion)]
          34  +
                                                        format!("{ev_error}").into()
          35  +
                                                    )
          36  +
                                                )? {
          37  +
                                                
          38  +
                                            }
          39  +
            Some(receiver)
          40  +
        } {
          41  +
            input = input.set_events(value)
          42  +
        }
          43  +
        input.build()?
          44  +
    })
          45  +
}
          46  +
          47  +
#[allow(clippy::unnecessary_wraps)]
          48  +
pub fn ser_streaming_operation_http_response(
          49  +
    #[allow(unused_variables)] output: crate::output::StreamingOperationOutput,
          50  +
) -> std::result::Result<
          51  +
    ::aws_smithy_legacy_http_server::response::Response,
          52  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
          53  +
> {
          54  +
    Ok({
          55  +
        #[allow(unused_mut)]
          56  +
        let mut builder = ::http::Response::builder();
          57  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          58  +
            builder,
          59  +
            ::http::header::CONTENT_TYPE,
          60  +
            "application/vnd.amazon.eventstream",
          61  +
        );
          62  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          63  +
            builder,
          64  +
            ::http::header::HeaderName::from_static("smithy-protocol"),
          65  +
            "rpc-v2-cbor",
          66  +
        );
          67  +
        let http_status: u16 = 200;
          68  +
        builder = builder.status(http_status);
          69  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          70  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          71  +
                let error_marshaller = crate::event_stream_serde::EventsErrorMarshaller::new();
          72  +
                let marshaller = crate::event_stream_serde::EventsMarshaller::new();
          73  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          74  +
                {
          75  +
                    use ::futures_util::StreamExt;
          76  +
                    let payload = ::bytes::Bytes::from(crate::protocol_serde::shape_streaming_operation_output::ser_streaming_operation_output_output_output(&output)?);
          77  +
                    let initial_message =
          78  +
                        crate::event_stream_serde::initial_response_from_payload(payload);
          79  +
                    let mut buffer = ::std::vec::Vec::new();
          80  +
                    ::aws_smithy_eventstream::frame::write_message_to(
          81  +
                        &initial_message,
          82  +
                        &mut buffer,
          83  +
                    )
          84  +
                    .expect("Failed to write initial message");
          85  +
                    let initial_message_stream =
          86  +
                        futures_util::stream::iter(vec![Ok(buffer.into())]);
          87  +
                    let adapter =
          88  +
                        output
          89  +
                            .events
          90  +
                            .into_body_stream(marshaller, error_marshaller, signer);
          91  +
                    initial_message_stream.chain(adapter)
          92  +
                }
          93  +
            }),
          94  +
        );
          95  +
        builder.body(body)?
          96  +
    })
          97  +
}
          98  +
          99  +
#[allow(clippy::unnecessary_wraps)]
         100  +
pub fn ser_streaming_operation_http_error(
         101  +
    error: &crate::error::StreamingOperationError,
         102  +
) -> std::result::Result<
         103  +
    ::aws_smithy_legacy_http_server::response::Response,
         104  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
         105  +
> {
         106  +
    Ok({
         107  +
        match error {
         108  +
            crate::error::StreamingOperationError::ValidationException(output) => {
         109  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                #[allow(unused_mut)]
         111  +
                let mut builder = ::http::Response::builder();
         112  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         113  +
                    builder,
         114  +
                    ::http::header::CONTENT_TYPE,
         115  +
                    "application/vnd.amazon.eventstream",
         116  +
                );
         117  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         118  +
                    builder,
         119  +
                    ::http::header::HeaderName::from_static("smithy-protocol"),
         120  +
                    "rpc-v2-cbor",
         121  +
                );
         122  +
                let content_length = payload.len();
         123  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         124  +
                    builder,
         125  +
                    ::http::header::CONTENT_LENGTH,
         126  +
                    content_length,
         127  +
                );
         128  +
                builder
         129  +
                    .status(400)
         130  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         131  +
            }
         132  +
        }
         133  +
    })
         134  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_input.rs

@@ -0,1 +0,15 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_events_payload(
           3  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           4  +
) -> std::result::Result<
           5  +
    crate::sigv4_event_stream::SigV4Receiver<
           6  +
        crate::model::Events,
           7  +
        ::aws_smithy_legacy_http::event_stream::MessageStreamError,
           8  +
    >,
           9  +
    ::aws_smithy_cbor::decode::DeserializeError,
          10  +
> {
          11  +
    let unmarshaller = crate::event_stream_serde::EventsUnmarshaller::new();
          12  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          13  +
    let receiver = crate::sigv4_event_stream::SigV4Receiver::new(unmarshaller, body);
          14  +
    Ok(receiver)
          15  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_output.rs

@@ -0,1 +0,23 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_streaming_operation_output_output_output(
           3  +
    value: &crate::output::StreamingOperationOutput,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut encoder = ::aws_smithy_cbor::Encoder::new(::std::vec::Vec::new());
           9  +
    {
          10  +
        let encoder = &mut encoder;
          11  +
        crate::protocol_serde::shape_streaming_operation_output::ser_streaming_operation_output_output(encoder, value )?;
          12  +
    }
          13  +
    ::std::result::Result::Ok(encoder.into_writer())
          14  +
}
          15  +
          16  +
pub fn ser_streaming_operation_output_output(
          17  +
    encoder: &mut ::aws_smithy_cbor::Encoder,
          18  +
    #[allow(unused)] input: &crate::output::StreamingOperationOutput,
          19  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          20  +
    encoder.begin_map();
          21  +
    encoder.end();
          22  +
    Ok(())
          23  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_initial_data.rs

@@ -0,1 +0,187 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_streaming_operation_with_initial_data_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::StreamingOperationWithInitialDataInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::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::rpc_v2_cbor::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 =
          19  +
            crate::input::streaming_operation_with_initial_data_input::Builder::default();
          20  +
        #[allow(unused_variables)]
          21  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          22  +
            uri, headers, body, ..
          23  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          24  +
        if let Some(value) = {
          25  +
            let mut receiver = crate::protocol_serde::shape_streaming_operation_with_initial_data_input::de_events_payload(&mut body.into().into_inner())?;
          26  +
            if let Some(_initial_event) = receiver
          27  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          28  +
                                                .await
          29  +
                                                .map_err(
          30  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::ConstraintViolation(
          31  +
                                                        #[allow(clippy::useless_conversion)]
          32  +
                                                        format!("{ev_error}").into()
          33  +
                                                    )
          34  +
                                                )? {
          35  +
                                                input = crate::protocol_serde::shape_streaming_operation_with_initial_data::de_streaming_operation_with_initial_data(_initial_event.payload(), input)?;
          36  +
                                            }
          37  +
            Some(receiver)
          38  +
        } {
          39  +
            input = input.set_events(value)
          40  +
        }
          41  +
        input.build()?
          42  +
    })
          43  +
}
          44  +
          45  +
#[allow(clippy::unnecessary_wraps)]
          46  +
pub fn ser_streaming_operation_with_initial_data_http_response(
          47  +
    #[allow(unused_variables)] output: crate::output::StreamingOperationWithInitialDataOutput,
          48  +
) -> std::result::Result<
          49  +
    ::aws_smithy_legacy_http_server::response::Response,
          50  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
          51  +
> {
          52  +
    Ok({
          53  +
        #[allow(unused_mut)]
          54  +
        let mut builder = ::http::Response::builder();
          55  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          56  +
            builder,
          57  +
            ::http::header::CONTENT_TYPE,
          58  +
            "application/vnd.amazon.eventstream",
          59  +
        );
          60  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          61  +
            builder,
          62  +
            ::http::header::HeaderName::from_static("smithy-protocol"),
          63  +
            "rpc-v2-cbor",
          64  +
        );
          65  +
        let http_status: u16 = 200;
          66  +
        builder = builder.status(http_status);
          67  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          68  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          69  +
                let error_marshaller = crate::event_stream_serde::EventsErrorMarshaller::new();
          70  +
                let marshaller = crate::event_stream_serde::EventsMarshaller::new();
          71  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          72  +
                {
          73  +
                    use ::futures_util::StreamExt;
          74  +
                    let payload = ::bytes::Bytes::from(crate::protocol_serde::shape_streaming_operation_with_initial_data_output::ser_streaming_operation_with_initial_data_output_output_output(&output)?);
          75  +
                    let initial_message =
          76  +
                        crate::event_stream_serde::initial_response_from_payload(payload);
          77  +
                    let mut buffer = ::std::vec::Vec::new();
          78  +
                    ::aws_smithy_eventstream::frame::write_message_to(
          79  +
                        &initial_message,
          80  +
                        &mut buffer,
          81  +
                    )
          82  +
                    .expect("Failed to write initial message");
          83  +
                    let initial_message_stream =
          84  +
                        futures_util::stream::iter(vec![Ok(buffer.into())]);
          85  +
                    let adapter =
          86  +
                        output
          87  +
                            .events
          88  +
                            .into_body_stream(marshaller, error_marshaller, signer);
          89  +
                    initial_message_stream.chain(adapter)
          90  +
                }
          91  +
            }),
          92  +
        );
          93  +
        builder.body(body)?
          94  +
    })
          95  +
}
          96  +
          97  +
#[allow(clippy::unnecessary_wraps)]
          98  +
pub fn ser_streaming_operation_with_initial_data_http_error(
          99  +
    error: &crate::error::StreamingOperationWithInitialDataError,
         100  +
) -> std::result::Result<
         101  +
    ::aws_smithy_legacy_http_server::response::Response,
         102  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
         103  +
> {
         104  +
    Ok({
         105  +
        match error {
         106  +
            crate::error::StreamingOperationWithInitialDataError::ValidationException(output) => {
         107  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         108  +
                #[allow(unused_mut)]
         109  +
                let mut builder = ::http::Response::builder();
         110  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         111  +
                    builder,
         112  +
                    ::http::header::CONTENT_TYPE,
         113  +
                    "application/vnd.amazon.eventstream",
         114  +
                );
         115  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
                    builder,
         117  +
                    ::http::header::HeaderName::from_static("smithy-protocol"),
         118  +
                    "rpc-v2-cbor",
         119  +
                );
         120  +
                let content_length = payload.len();
         121  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         122  +
                    builder,
         123  +
                    ::http::header::CONTENT_LENGTH,
         124  +
                    content_length,
         125  +
                );
         126  +
                builder
         127  +
                    .status(400)
         128  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         129  +
            }
         130  +
        }
         131  +
    })
         132  +
}
         133  +
         134  +
pub(crate) fn de_streaming_operation_with_initial_data(
         135  +
    value: &[u8],
         136  +
    mut builder: crate::input::streaming_operation_with_initial_data_input::Builder,
         137  +
) -> ::std::result::Result<
         138  +
    crate::input::streaming_operation_with_initial_data_input::Builder,
         139  +
    ::aws_smithy_cbor::decode::DeserializeError,
         140  +
> {
         141  +
    #[allow(clippy::match_single_binding)]
         142  +
    fn pair(
         143  +
        mut builder: crate::input::streaming_operation_with_initial_data_input::Builder,
         144  +
        decoder: &mut ::aws_smithy_cbor::Decoder,
         145  +
    ) -> ::std::result::Result<
         146  +
        crate::input::streaming_operation_with_initial_data_input::Builder,
         147  +
        ::aws_smithy_cbor::decode::DeserializeError,
         148  +
    > {
         149  +
        builder = match decoder.str()?.as_ref() {
         150  +
            "initialData" => builder.set_initial_data(decoder.string()?),
         151  +
            _ => {
         152  +
                decoder.skip()?;
         153  +
                builder
         154  +
            }
         155  +
        };
         156  +
        Ok(builder)
         157  +
    }
         158  +
         159  +
    let decoder = &mut ::aws_smithy_cbor::Decoder::new(value);
         160  +
         161  +
    match decoder.map()? {
         162  +
        None => loop {
         163  +
            match decoder.datatype()? {
         164  +
                ::aws_smithy_cbor::data::Type::Break => {
         165  +
                    decoder.skip()?;
         166  +
                    break;
         167  +
                }
         168  +
                _ => {
         169  +
                    builder = pair(builder, decoder)?;
         170  +
                }
         171  +
            };
         172  +
        },
         173  +
        Some(n) => {
         174  +
            for _ in 0..n {
         175  +
                builder = pair(builder, decoder)?;
         176  +
            }
         177  +
        }
         178  +
    };
         179  +
         180  +
    if decoder.position() != value.len() {
         181  +
        return Err(
         182  +
            ::aws_smithy_cbor::decode::DeserializeError::expected_end_of_stream(decoder.position()),
         183  +
        );
         184  +
    }
         185  +
         186  +
    Ok(builder)
         187  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_initial_data_input.rs

@@ -0,1 +0,15 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_events_payload(
           3  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           4  +
) -> std::result::Result<
           5  +
    crate::sigv4_event_stream::SigV4Receiver<
           6  +
        crate::model::Events,
           7  +
        ::aws_smithy_legacy_http::event_stream::MessageStreamError,
           8  +
    >,
           9  +
    ::aws_smithy_cbor::decode::DeserializeError,
          10  +
> {
          11  +
    let unmarshaller = crate::event_stream_serde::EventsUnmarshaller::new();
          12  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          13  +
    let receiver = crate::sigv4_event_stream::SigV4Receiver::new(unmarshaller, body);
          14  +
    Ok(receiver)
          15  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_initial_data_output.rs

@@ -0,1 +0,23 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_streaming_operation_with_initial_data_output_output_output(
           3  +
    value: &crate::output::StreamingOperationWithInitialDataOutput,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut encoder = ::aws_smithy_cbor::Encoder::new(::std::vec::Vec::new());
           9  +
    {
          10  +
        let encoder = &mut encoder;
          11  +
        crate::protocol_serde::shape_streaming_operation_with_initial_data_output::ser_streaming_operation_with_initial_data_output_output(encoder, value )?;
          12  +
    }
          13  +
    ::std::result::Result::Ok(encoder.into_writer())
          14  +
}
          15  +
          16  +
pub fn ser_streaming_operation_with_initial_data_output_output(
          17  +
    encoder: &mut ::aws_smithy_cbor::Encoder,
          18  +
    #[allow(unused)] input: &crate::output::StreamingOperationWithInitialDataOutput,
          19  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          20  +
    encoder.begin_map();
          21  +
    encoder.end();
          22  +
    Ok(())
          23  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_initial_response.rs

@@ -0,1 +0,134 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_streaming_operation_with_initial_response_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::StreamingOperationWithInitialResponseInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::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::rpc_v2_cbor::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 =
          19  +
            crate::input::streaming_operation_with_initial_response_input::Builder::default();
          20  +
        #[allow(unused_variables)]
          21  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          22  +
            uri, headers, body, ..
          23  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          24  +
        if let Some(value) = {
          25  +
            let mut receiver = crate::protocol_serde::shape_streaming_operation_with_initial_response_input::de_events_payload(&mut body.into().into_inner())?;
          26  +
            if let Some(_initial_event) = receiver
          27  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          28  +
                                                .await
          29  +
                                                .map_err(
          30  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::ConstraintViolation(
          31  +
                                                        #[allow(clippy::useless_conversion)]
          32  +
                                                        format!("{ev_error}").into()
          33  +
                                                    )
          34  +
                                                )? {
          35  +
                                                
          36  +
                                            }
          37  +
            Some(receiver)
          38  +
        } {
          39  +
            input = input.set_events(value)
          40  +
        }
          41  +
        input.build()?
          42  +
    })
          43  +
}
          44  +
          45  +
#[allow(clippy::unnecessary_wraps)]
          46  +
pub fn ser_streaming_operation_with_initial_response_http_response(
          47  +
    #[allow(unused_variables)] output: crate::output::StreamingOperationWithInitialResponseOutput,
          48  +
) -> std::result::Result<
          49  +
    ::aws_smithy_legacy_http_server::response::Response,
          50  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
          51  +
> {
          52  +
    Ok({
          53  +
        #[allow(unused_mut)]
          54  +
        let mut builder = ::http::Response::builder();
          55  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          56  +
            builder,
          57  +
            ::http::header::CONTENT_TYPE,
          58  +
            "application/vnd.amazon.eventstream",
          59  +
        );
          60  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          61  +
            builder,
          62  +
            ::http::header::HeaderName::from_static("smithy-protocol"),
          63  +
            "rpc-v2-cbor",
          64  +
        );
          65  +
        let http_status: u16 = 200;
          66  +
        builder = builder.status(http_status);
          67  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          68  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          69  +
                let error_marshaller = crate::event_stream_serde::EventsErrorMarshaller::new();
          70  +
                let marshaller = crate::event_stream_serde::EventsMarshaller::new();
          71  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          72  +
                {
          73  +
                    use ::futures_util::StreamExt;
          74  +
                    let payload = ::bytes::Bytes::from(crate::protocol_serde::shape_streaming_operation_with_initial_response_output::ser_streaming_operation_with_initial_response_output_output_output(&output)?);
          75  +
                    let initial_message =
          76  +
                        crate::event_stream_serde::initial_response_from_payload(payload);
          77  +
                    let mut buffer = ::std::vec::Vec::new();
          78  +
                    ::aws_smithy_eventstream::frame::write_message_to(
          79  +
                        &initial_message,
          80  +
                        &mut buffer,
          81  +
                    )
          82  +
                    .expect("Failed to write initial message");
          83  +
                    let initial_message_stream =
          84  +
                        futures_util::stream::iter(vec![Ok(buffer.into())]);
          85  +
                    let adapter =
          86  +
                        output
          87  +
                            .events
          88  +
                            .into_body_stream(marshaller, error_marshaller, signer);
          89  +
                    initial_message_stream.chain(adapter)
          90  +
                }
          91  +
            }),
          92  +
        );
          93  +
        builder.body(body)?
          94  +
    })
          95  +
}
          96  +
          97  +
#[allow(clippy::unnecessary_wraps)]
          98  +
pub fn ser_streaming_operation_with_initial_response_http_error(
          99  +
    error: &crate::error::StreamingOperationWithInitialResponseError,
         100  +
) -> std::result::Result<
         101  +
    ::aws_smithy_legacy_http_server::response::Response,
         102  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
         103  +
> {
         104  +
    Ok({
         105  +
        match error {
         106  +
            crate::error::StreamingOperationWithInitialResponseError::ValidationException(
         107  +
                output,
         108  +
            ) => {
         109  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                #[allow(unused_mut)]
         111  +
                let mut builder = ::http::Response::builder();
         112  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         113  +
                    builder,
         114  +
                    ::http::header::CONTENT_TYPE,
         115  +
                    "application/vnd.amazon.eventstream",
         116  +
                );
         117  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         118  +
                    builder,
         119  +
                    ::http::header::HeaderName::from_static("smithy-protocol"),
         120  +
                    "rpc-v2-cbor",
         121  +
                );
         122  +
                let content_length = payload.len();
         123  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         124  +
                    builder,
         125  +
                    ::http::header::CONTENT_LENGTH,
         126  +
                    content_length,
         127  +
                );
         128  +
                builder
         129  +
                    .status(400)
         130  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         131  +
            }
         132  +
        }
         133  +
    })
         134  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_initial_response_input.rs

@@ -0,1 +0,15 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_events_payload(
           3  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           4  +
) -> std::result::Result<
           5  +
    crate::sigv4_event_stream::SigV4Receiver<
           6  +
        crate::model::Events,
           7  +
        ::aws_smithy_legacy_http::event_stream::MessageStreamError,
           8  +
    >,
           9  +
    ::aws_smithy_cbor::decode::DeserializeError,
          10  +
> {
          11  +
    let unmarshaller = crate::event_stream_serde::EventsUnmarshaller::new();
          12  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          13  +
    let receiver = crate::sigv4_event_stream::SigV4Receiver::new(unmarshaller, body);
          14  +
    Ok(receiver)
          15  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_initial_response_output.rs

@@ -0,1 +0,28 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_streaming_operation_with_initial_response_output_output_output(
           3  +
    value: &crate::output::StreamingOperationWithInitialResponseOutput,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut encoder = ::aws_smithy_cbor::Encoder::new(::std::vec::Vec::new());
           9  +
    {
          10  +
        let encoder = &mut encoder;
          11  +
        crate::protocol_serde::shape_streaming_operation_with_initial_response_output::ser_streaming_operation_with_initial_response_output_output(encoder, value )?;
          12  +
    }
          13  +
    ::std::result::Result::Ok(encoder.into_writer())
          14  +
}
          15  +
          16  +
pub fn ser_streaming_operation_with_initial_response_output_output(
          17  +
    encoder: &mut ::aws_smithy_cbor::Encoder,
          18  +
    #[allow(unused)] input: &crate::output::StreamingOperationWithInitialResponseOutput,
          19  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          20  +
    encoder.begin_map();
          21  +
    {
          22  +
        encoder
          23  +
            .str("responseData")
          24  +
            .str(input.response_data.as_str());
          25  +
    }
          26  +
    encoder.end();
          27  +
    Ok(())
          28  +
}

tmp-codegen-diff/codegen-server-test/rpcv2Cbor_extras-http0x/rust-server-codegen/src/protocol_serde/shape_streaming_operation_with_optional_data.rs

@@ -0,1 +0,191 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_streaming_operation_with_optional_data_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::StreamingOperationWithOptionalDataInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::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::rpc_v2_cbor::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 =
          19  +
            crate::input::streaming_operation_with_optional_data_input::Builder::default();
          20  +
        #[allow(unused_variables)]
          21  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          22  +
            uri, headers, body, ..
          23  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          24  +
        if let Some(value) = {
          25  +
            let mut receiver = crate::protocol_serde::shape_streaming_operation_with_optional_data_input::de_events_payload(&mut body.into().into_inner())?;
          26  +
            if let Some(_initial_event) = receiver
          27  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          28  +
                                                .await
          29  +
                                                .map_err(
          30  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::ConstraintViolation(
          31  +
                                                        #[allow(clippy::useless_conversion)]
          32  +
                                                        format!("{ev_error}").into()
          33  +
                                                    )
          34  +
                                                )? {
          35  +
                                                input = crate::protocol_serde::shape_streaming_operation_with_optional_data::de_streaming_operation_with_optional_data(_initial_event.payload(), input)?;
          36  +
                                            }
          37  +
            Some(receiver)
          38  +
        } {
          39  +
            input = input.set_events(value)
          40  +
        }
          41  +
        input.build()?
          42  +
    })
          43  +
}
          44  +
          45  +
#[allow(clippy::unnecessary_wraps)]
          46  +
pub fn ser_streaming_operation_with_optional_data_http_response(
          47  +
    #[allow(unused_variables)] output: crate::output::StreamingOperationWithOptionalDataOutput,
          48  +
) -> std::result::Result<
          49  +
    ::aws_smithy_legacy_http_server::response::Response,
          50  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
          51  +
> {
          52  +
    Ok({
          53  +
        #[allow(unused_mut)]
          54  +
        let mut builder = ::http::Response::builder();
          55  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          56  +
            builder,
          57  +
            ::http::header::CONTENT_TYPE,
          58  +
            "application/vnd.amazon.eventstream",
          59  +
        );
          60  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          61  +
            builder,
          62  +
            ::http::header::HeaderName::from_static("smithy-protocol"),
          63  +
            "rpc-v2-cbor",
          64  +
        );
          65  +
        let http_status: u16 = 200;
          66  +
        builder = builder.status(http_status);
          67  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          68  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          69  +
                let error_marshaller = crate::event_stream_serde::EventsErrorMarshaller::new();
          70  +
                let marshaller = crate::event_stream_serde::EventsMarshaller::new();
          71  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          72  +
                {
          73  +
                    use ::futures_util::StreamExt;
          74  +
                    let payload = ::bytes::Bytes::from(crate::protocol_serde::shape_streaming_operation_with_optional_data_output::ser_streaming_operation_with_optional_data_output_output_output(&output)?);
          75  +
                    let initial_message =
          76  +
                        crate::event_stream_serde::initial_response_from_payload(payload);
          77  +
                    let mut buffer = ::std::vec::Vec::new();
          78  +
                    ::aws_smithy_eventstream::frame::write_message_to(
          79  +
                        &initial_message,
          80  +
                        &mut buffer,
          81  +
                    )
          82  +
                    .expect("Failed to write initial message");
          83  +
                    let initial_message_stream =
          84  +
                        futures_util::stream::iter(vec![Ok(buffer.into())]);
          85  +
                    let adapter =
          86  +
                        output
          87  +
                            .events
          88  +
                            .into_body_stream(marshaller, error_marshaller, signer);
          89  +
                    initial_message_stream.chain(adapter)
          90  +
                }
          91  +
            }),
          92  +
        );
          93  +
        builder.body(body)?
          94  +
    })
          95  +
}
          96  +
          97  +
#[allow(clippy::unnecessary_wraps)]
          98  +
pub fn ser_streaming_operation_with_optional_data_http_error(
          99  +
    error: &crate::error::StreamingOperationWithOptionalDataError,
         100  +
) -> std::result::Result<
         101  +
    ::aws_smithy_legacy_http_server::response::Response,
         102  +
    ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
         103  +
> {
         104  +
    Ok({
         105  +
        match error {
         106  +
            crate::error::StreamingOperationWithOptionalDataError::ValidationException(output) => {
         107  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         108  +
                #[allow(unused_mut)]
         109  +
                let mut builder = ::http::Response::builder();
         110  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         111  +
                    builder,
         112  +
                    ::http::header::CONTENT_TYPE,
         113  +
                    "application/vnd.amazon.eventstream",
         114  +
                );
         115  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
                    builder,
         117  +
                    ::http::header::HeaderName::from_static("smithy-protocol"),
         118  +
                    "rpc-v2-cbor",
         119  +
                );
         120  +
                let content_length = payload.len();
         121  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         122  +
                    builder,
         123  +
                    ::http::header::CONTENT_LENGTH,
         124  +
                    content_length,
         125  +
                );
         126  +
                builder
         127  +
                    .status(400)
         128  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         129  +
            }
         130  +
        }
         131  +
    })
         132  +
}
         133  +
         134  +
pub(crate) fn de_streaming_operation_with_optional_data(
         135  +
    value: &[u8],
         136  +
    mut builder: crate::input::streaming_operation_with_optional_data_input::Builder,
         137  +
) -> ::std::result::Result<
         138  +
    crate::input::streaming_operation_with_optional_data_input::Builder,
         139  +
    ::aws_smithy_cbor::decode::DeserializeError,
         140  +
> {
         141  +
    #[allow(clippy::match_single_binding)]
         142  +
    fn pair(
         143  +
        mut builder: crate::input::streaming_operation_with_optional_data_input::Builder,
         144  +
        decoder: &mut ::aws_smithy_cbor::Decoder,
         145  +
    ) -> ::std::result::Result<
         146  +
        crate::input::streaming_operation_with_optional_data_input::Builder,
         147  +
        ::aws_smithy_cbor::decode::DeserializeError,
         148  +
    > {
         149  +
        builder = match decoder.str()?.as_ref() {
         150  +
            "optionalData" => {
         151  +
                ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
         152  +
                    Ok(builder.set_optional_data(Some(decoder.string()?)))
         153  +
                })?
         154  +
            }
         155  +
            _ => {
         156  +
                decoder.skip()?;
         157  +
                builder
         158  +
            }
         159  +
        };
         160  +
        Ok(builder)
         161  +
    }
         162  +
         163  +
    let decoder = &mut ::aws_smithy_cbor::Decoder::new(value);
         164  +
         165  +
    match decoder.map()? {
         166  +
        None => loop {
         167  +
            match decoder.datatype()? {
         168  +
                ::aws_smithy_cbor::data::Type::Break => {
         169  +
                    decoder.skip()?;
         170  +
                    break;
         171  +
                }
         172  +
                _ => {
         173  +
                    builder = pair(builder, decoder)?;
         174  +
                }
         175  +
            };
         176  +
        },
         177  +
        Some(n) => {
         178  +
            for _ in 0..n {
         179  +
                builder = pair(builder, decoder)?;
         180  +
            }
         181  +
        }
         182  +
    };
         183  +
         184  +
    if decoder.position() != value.len() {
         185  +
        return Err(
         186  +
            ::aws_smithy_cbor::decode::DeserializeError::expected_end_of_stream(decoder.position()),
         187  +
        );
         188  +
    }
         189  +
         190  +
    Ok(builder)
         191  +
}