Server Test Python

Server Test Python

rev. 7254d43655ed63111c94f599437f2b0d3f55446e

Files changed:

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_input_stream_with_initial_request.rs

@@ -0,1 +0,161 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_input_stream_with_initial_request_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::InputStreamWithInitialRequestInput,
           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 =
          19  +
            crate::input::input_stream_with_initial_request_input_internal::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) = crate::protocol_serde::shape_input_stream_with_initial_request_input::de_initial_request_member_header(&headers)? {
          25  +
                                input = input.set_initial_request_member(value)
          26  +
                            }
          27  +
        if let Some(value) = {
          28  +
            let mut receiver = crate::protocol_serde::shape_input_stream_with_initial_request_input::de_stream_payload(&mut body.into().into_inner())?;
          29  +
            if let Some(_initial_event) = receiver
          30  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          31  +
                                                .await
          32  +
                                                .map_err(
          33  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          34  +
                                                        #[allow(clippy::useless_conversion)]
          35  +
                                                        format!("{ev_error}").into()
          36  +
                                                    )
          37  +
                                                )? {
          38  +
                                                
          39  +
                                            }
          40  +
            Some(receiver)
          41  +
        } {
          42  +
            input = input.set_stream(value)
          43  +
        }
          44  +
        input.build()?
          45  +
    })
          46  +
}
          47  +
          48  +
#[allow(clippy::unnecessary_wraps)]
          49  +
pub fn ser_input_stream_with_initial_request_http_response(
          50  +
    #[allow(unused_variables)] output: crate::output::InputStreamWithInitialRequestOutput,
          51  +
) -> std::result::Result<
          52  +
    ::aws_smithy_legacy_http_server::response::Response,
          53  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          54  +
> {
          55  +
    Ok({
          56  +
        #[allow(unused_mut)]
          57  +
        let mut builder = ::http::Response::builder();
          58  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          59  +
            builder,
          60  +
            ::http::header::CONTENT_TYPE,
          61  +
            "application/json",
          62  +
        );
          63  +
        let http_status: u16 = 200;
          64  +
        builder = builder.status(http_status);
          65  +
        let payload = "";
          66  +
        let content_length = payload.len();
          67  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          68  +
            builder,
          69  +
            ::http::header::CONTENT_LENGTH,
          70  +
            content_length,
          71  +
        );
          72  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          73  +
        builder.body(body)?
          74  +
    })
          75  +
}
          76  +
          77  +
#[allow(clippy::unnecessary_wraps)]
          78  +
pub fn ser_input_stream_with_initial_request_http_error(
          79  +
    error: &crate::error::InputStreamWithInitialRequestError,
          80  +
) -> std::result::Result<
          81  +
    ::aws_smithy_legacy_http_server::response::Response,
          82  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          83  +
> {
          84  +
    Ok({
          85  +
        match error {
          86  +
            crate::error::InputStreamWithInitialRequestError::ValidationException(output) => {
          87  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          88  +
                #[allow(unused_mut)]
          89  +
                let mut builder = ::http::Response::builder();
          90  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          91  +
                    builder,
          92  +
                    ::http::header::CONTENT_TYPE,
          93  +
                    "application/json",
          94  +
                );
          95  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          96  +
                    builder,
          97  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          98  +
                    "ValidationException",
          99  +
                );
         100  +
                let content_length = payload.len();
         101  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         102  +
                    builder,
         103  +
                    ::http::header::CONTENT_LENGTH,
         104  +
                    content_length,
         105  +
                );
         106  +
                builder
         107  +
                    .status(400)
         108  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         109  +
            }
         110  +
            crate::error::InputStreamWithInitialRequestError::ErrorEvent(output) => {
         111  +
                let payload =
         112  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         113  +
                #[allow(unused_mut)]
         114  +
                let mut builder = ::http::Response::builder();
         115  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
                    builder,
         117  +
                    ::http::header::CONTENT_TYPE,
         118  +
                    "application/json",
         119  +
                );
         120  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         121  +
                    builder,
         122  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         123  +
                    "ErrorEvent",
         124  +
                );
         125  +
                let content_length = payload.len();
         126  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         127  +
                    builder,
         128  +
                    ::http::header::CONTENT_LENGTH,
         129  +
                    content_length,
         130  +
                );
         131  +
                builder
         132  +
                    .status(400)
         133  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         134  +
            }
         135  +
            crate::error::InputStreamWithInitialRequestError::InternalServerError(output) => {
         136  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         137  +
                #[allow(unused_mut)]
         138  +
                let mut builder = ::http::Response::builder();
         139  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         140  +
                    builder,
         141  +
                    ::http::header::CONTENT_TYPE,
         142  +
                    "application/json",
         143  +
                );
         144  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         145  +
                    builder,
         146  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         147  +
                    "InternalServerError",
         148  +
                );
         149  +
                let content_length = payload.len();
         150  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         151  +
                    builder,
         152  +
                    ::http::header::CONTENT_LENGTH,
         153  +
                    content_length,
         154  +
                );
         155  +
                builder
         156  +
                    .status(500)
         157  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         158  +
            }
         159  +
        }
         160  +
    })
         161  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_input_stream_with_initial_request_input.rs

@@ -0,1 +0,26 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_initial_request_member_header(
           3  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::option::Option<::std::string::String>,
           6  +
    ::aws_smithy_legacy_http::header::ParseError,
           7  +
> {
           8  +
    let headers = header_map.get_all("initial-request-member");
           9  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          10  +
}
          11  +
          12  +
pub fn de_stream_payload(
          13  +
    body: &mut ::aws_smithy_types::body::SdkBody,
          14  +
) -> std::result::Result<
          15  +
    crate::python_event_stream::InputStreamWithInitialRequestInputStreamReceiver,
          16  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          17  +
> {
          18  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
          19  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          20  +
    let receiver =
          21  +
        crate::python_event_stream::InputStreamWithInitialRequestInputStreamReceiver::new(
          22  +
            unmarshaller,
          23  +
            body,
          24  +
        );
          25  +
    Ok(receiver)
          26  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_output_stream.rs

@@ -0,1 +0,144 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_output_stream_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::OutputStreamInput,
           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::output_stream_input_internal::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  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          23  +
            &headers, None,
          24  +
        )?;
          25  +
        input.build()
          26  +
    })
          27  +
}
          28  +
          29  +
#[allow(clippy::unnecessary_wraps)]
          30  +
pub fn ser_output_stream_http_response(
          31  +
    #[allow(unused_variables)] output: crate::output::OutputStreamOutput,
          32  +
) -> std::result::Result<
          33  +
    ::aws_smithy_legacy_http_server::response::Response,
          34  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          35  +
> {
          36  +
    Ok({
          37  +
        #[allow(unused_mut)]
          38  +
        let mut builder = ::http::Response::builder();
          39  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          40  +
            builder,
          41  +
            ::http::header::CONTENT_TYPE,
          42  +
            "application/vnd.amazon.eventstream",
          43  +
        );
          44  +
        let http_status: u16 = 200;
          45  +
        builder = builder.status(http_status);
          46  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          47  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          48  +
                let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
          49  +
                let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          50  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          51  +
                output
          52  +
                    .stream
          53  +
                    .into_body_stream(marshaller, error_marshaller, signer)
          54  +
            }),
          55  +
        );
          56  +
        builder.body(body)?
          57  +
    })
          58  +
}
          59  +
          60  +
#[allow(clippy::unnecessary_wraps)]
          61  +
pub fn ser_output_stream_http_error(
          62  +
    error: &crate::error::OutputStreamError,
          63  +
) -> std::result::Result<
          64  +
    ::aws_smithy_legacy_http_server::response::Response,
          65  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          66  +
> {
          67  +
    Ok({
          68  +
        match error {
          69  +
            crate::error::OutputStreamError::ServiceUnavailableError(output) => {
          70  +
                let payload = crate::protocol_serde::shape_service_unavailable_error::ser_service_unavailable_error_error(output)?;
          71  +
                #[allow(unused_mut)]
          72  +
                let mut builder = ::http::Response::builder();
          73  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          74  +
                    builder,
          75  +
                    ::http::header::CONTENT_TYPE,
          76  +
                    "application/vnd.amazon.eventstream",
          77  +
                );
          78  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          79  +
                    builder,
          80  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          81  +
                    "ServiceUnavailableError",
          82  +
                );
          83  +
                let content_length = payload.len();
          84  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
                    builder,
          86  +
                    ::http::header::CONTENT_LENGTH,
          87  +
                    content_length,
          88  +
                );
          89  +
                builder
          90  +
                    .status(500)
          91  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          92  +
            }
          93  +
            crate::error::OutputStreamError::ErrorEvent(output) => {
          94  +
                let payload =
          95  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
          96  +
                #[allow(unused_mut)]
          97  +
                let mut builder = ::http::Response::builder();
          98  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          99  +
                    builder,
         100  +
                    ::http::header::CONTENT_TYPE,
         101  +
                    "application/vnd.amazon.eventstream",
         102  +
                );
         103  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         104  +
                    builder,
         105  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         106  +
                    "ErrorEvent",
         107  +
                );
         108  +
                let content_length = payload.len();
         109  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         110  +
                    builder,
         111  +
                    ::http::header::CONTENT_LENGTH,
         112  +
                    content_length,
         113  +
                );
         114  +
                builder
         115  +
                    .status(400)
         116  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         117  +
            }
         118  +
            crate::error::OutputStreamError::InternalServerError(output) => {
         119  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         120  +
                #[allow(unused_mut)]
         121  +
                let mut builder = ::http::Response::builder();
         122  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         123  +
                    builder,
         124  +
                    ::http::header::CONTENT_TYPE,
         125  +
                    "application/vnd.amazon.eventstream",
         126  +
                );
         127  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         128  +
                    builder,
         129  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         130  +
                    "InternalServerError",
         131  +
                );
         132  +
                let content_length = payload.len();
         133  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         134  +
                    builder,
         135  +
                    ::http::header::CONTENT_LENGTH,
         136  +
                    content_length,
         137  +
                );
         138  +
                builder
         139  +
                    .status(500)
         140  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         141  +
            }
         142  +
        }
         143  +
    })
         144  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_output_stream_with_initial_response.rs

@@ -0,1 +0,146 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_output_stream_with_initial_response_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::OutputStreamWithInitialResponseInput,
           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 =
          18  +
            crate::input::output_stream_with_initial_response_input_internal::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  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          24  +
            &headers, None,
          25  +
        )?;
          26  +
        input.build()
          27  +
    })
          28  +
}
          29  +
          30  +
#[allow(clippy::unnecessary_wraps)]
          31  +
pub fn ser_output_stream_with_initial_response_http_response(
          32  +
    #[allow(unused_variables)] output: crate::output::OutputStreamWithInitialResponseOutput,
          33  +
) -> std::result::Result<
          34  +
    ::aws_smithy_legacy_http_server::response::Response,
          35  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          36  +
> {
          37  +
    Ok({
          38  +
        #[allow(unused_mut)]
          39  +
        let mut builder = ::http::Response::builder();
          40  +
        builder = crate::protocol_serde::shape_output_stream_with_initial_response::ser_output_stream_with_initial_response_headers(&output, builder)?;
          41  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          42  +
            builder,
          43  +
            ::http::header::CONTENT_TYPE,
          44  +
            "application/vnd.amazon.eventstream",
          45  +
        );
          46  +
        let http_status: u16 = 200;
          47  +
        builder = builder.status(http_status);
          48  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          49  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          50  +
                let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
          51  +
                let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          52  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          53  +
                output
          54  +
                    .stream
          55  +
                    .into_body_stream(marshaller, error_marshaller, signer)
          56  +
            }),
          57  +
        );
          58  +
        builder.body(body)?
          59  +
    })
          60  +
}
          61  +
          62  +
#[allow(clippy::unnecessary_wraps)]
          63  +
pub fn ser_output_stream_with_initial_response_http_error(
          64  +
    error: &crate::error::OutputStreamWithInitialResponseError,
          65  +
) -> std::result::Result<
          66  +
    ::aws_smithy_legacy_http_server::response::Response,
          67  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          68  +
> {
          69  +
    Ok({
          70  +
        match error {
          71  +
            crate::error::OutputStreamWithInitialResponseError::ErrorEvent(output) => {
          72  +
                let payload =
          73  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
          74  +
                #[allow(unused_mut)]
          75  +
                let mut builder = ::http::Response::builder();
          76  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          77  +
                    builder,
          78  +
                    ::http::header::CONTENT_TYPE,
          79  +
                    "application/vnd.amazon.eventstream",
          80  +
                );
          81  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
                    builder,
          83  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          84  +
                    "ErrorEvent",
          85  +
                );
          86  +
                let content_length = payload.len();
          87  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          88  +
                    builder,
          89  +
                    ::http::header::CONTENT_LENGTH,
          90  +
                    content_length,
          91  +
                );
          92  +
                builder
          93  +
                    .status(400)
          94  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          95  +
            }
          96  +
            crate::error::OutputStreamWithInitialResponseError::InternalServerError(output) => {
          97  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
          98  +
                #[allow(unused_mut)]
          99  +
                let mut builder = ::http::Response::builder();
         100  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         101  +
                    builder,
         102  +
                    ::http::header::CONTENT_TYPE,
         103  +
                    "application/vnd.amazon.eventstream",
         104  +
                );
         105  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         106  +
                    builder,
         107  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         108  +
                    "InternalServerError",
         109  +
                );
         110  +
                let content_length = payload.len();
         111  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         112  +
                    builder,
         113  +
                    ::http::header::CONTENT_LENGTH,
         114  +
                    content_length,
         115  +
                );
         116  +
                builder
         117  +
                    .status(500)
         118  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         119  +
            }
         120  +
        }
         121  +
    })
         122  +
}
         123  +
         124  +
pub fn ser_output_stream_with_initial_response_headers(
         125  +
    input: &crate::output::OutputStreamWithInitialResponseOutput,
         126  +
    mut builder: ::http::response::Builder,
         127  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         128  +
{
         129  +
    {
         130  +
        let formatted_1 = &input.initial_response_member.as_str();
         131  +
        if !formatted_1.is_empty() {
         132  +
            let header_value = formatted_1;
         133  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         134  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         135  +
                    "initial_response_member",
         136  +
                    format!(
         137  +
                        "`{}` cannot be used as a header value: {}",
         138  +
                        &header_value, err
         139  +
                    ),
         140  +
                )
         141  +
            })?;
         142  +
            builder = builder.header("initial-response-member", header_value);
         143  +
        }
         144  +
    }
         145  +
    Ok(builder)
         146  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_payload_structure.rs

@@ -0,1 +0,94 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_payload_structure_payload(
           3  +
    _value: &[u8],
           4  +
) -> ::std::result::Result<
           5  +
    crate::model::PayloadStructure,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
> {
           8  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
           9  +
        crate::protocol_serde::or_empty_doc(_value),
          10  +
    )
          11  +
    .peekable();
          12  +
    let tokens = &mut tokens_owned;
          13  +
    let result =
          14  +
        crate::protocol_serde::shape_payload_structure::de_payload_structure(tokens, _value)?
          15  +
            .ok_or_else(|| {
          16  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          17  +
                    "expected payload member value",
          18  +
                )
          19  +
            });
          20  +
    if tokens.next().is_some() {
          21  +
        return Err(
          22  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          23  +
                "found more JSON tokens after completing parsing",
          24  +
            ),
          25  +
        );
          26  +
    }
          27  +
    result
          28  +
}
          29  +
          30  +
pub fn ser_payload_structure(
          31  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          32  +
    input: &crate::model::PayloadStructure,
          33  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          34  +
    if let Some(var_1) = &input.structure_member {
          35  +
        object.key("structureMember").string(var_1.as_str());
          36  +
    }
          37  +
    Ok(())
          38  +
}
          39  +
          40  +
pub(crate) fn de_payload_structure<'a, I>(
          41  +
    tokens: &mut ::std::iter::Peekable<I>,
          42  +
    _value: &'a [u8],
          43  +
) -> ::std::result::Result<
          44  +
    Option<crate::model::PayloadStructure>,
          45  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          46  +
>
          47  +
where
          48  +
    I: Iterator<
          49  +
        Item = Result<
          50  +
            ::aws_smithy_json::deserialize::Token<'a>,
          51  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          52  +
        >,
          53  +
    >,
          54  +
{
          55  +
    match tokens.next().transpose()? {
          56  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          57  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          58  +
            #[allow(unused_mut)]
          59  +
            let mut builder = crate::model::payload_structure_internal::Builder::default();
          60  +
            loop {
          61  +
                match tokens.next().transpose()? {
          62  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          63  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          64  +
                        match key.to_unescaped()?.as_ref() {
          65  +
                            "structureMember" => {
          66  +
                                builder = builder.set_structure_member(
          67  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
          68  +
                                        tokens.next(),
          69  +
                                    )?
          70  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          71  +
                                    .transpose()?,
          72  +
                                );
          73  +
                            }
          74  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          75  +
                        }
          76  +
                    }
          77  +
                    other => {
          78  +
                        return Err(
          79  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          80  +
                                format!("expected object key or end object, found: {other:?}"),
          81  +
                            ),
          82  +
                        )
          83  +
                    }
          84  +
                }
          85  +
            }
          86  +
            Ok(Some(builder.build()))
          87  +
        }
          88  +
        _ => Err(
          89  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          90  +
                "expected start object or null",
          91  +
            ),
          92  +
        ),
          93  +
    }
          94  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_payload_union.rs

@@ -0,1 +0,129 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_payload_union_payload(
           3  +
    _value: &[u8],
           4  +
) -> ::std::result::Result<
           5  +
    crate::model::PayloadUnion,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
> {
           8  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
           9  +
        crate::protocol_serde::or_empty_doc(_value),
          10  +
    )
          11  +
    .peekable();
          12  +
    let tokens = &mut tokens_owned;
          13  +
    let result = crate::protocol_serde::shape_payload_union::de_payload_union(tokens, _value)?
          14  +
        .ok_or_else(|| {
          15  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          16  +
                "expected payload member value",
          17  +
            )
          18  +
        });
          19  +
    if tokens.next().is_some() {
          20  +
        return Err(
          21  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          22  +
                "found more JSON tokens after completing parsing",
          23  +
            ),
          24  +
        );
          25  +
    }
          26  +
    result
          27  +
}
          28  +
          29  +
pub fn ser_payload_union(
          30  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          31  +
    input: &crate::model::PayloadUnion,
          32  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          33  +
    match input {
          34  +
        crate::model::PayloadUnion::UnionMember(inner) => {
          35  +
            object.key("unionMember").string(inner.as_str());
          36  +
        }
          37  +
    }
          38  +
    Ok(())
          39  +
}
          40  +
          41  +
pub(crate) fn de_payload_union<'a, I>(
          42  +
    tokens: &mut ::std::iter::Peekable<I>,
          43  +
    _value: &'a [u8],
          44  +
) -> ::std::result::Result<
          45  +
    Option<crate::model::PayloadUnion>,
          46  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          47  +
>
          48  +
where
          49  +
    I: Iterator<
          50  +
        Item = Result<
          51  +
            ::aws_smithy_json::deserialize::Token<'a>,
          52  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          53  +
        >,
          54  +
    >,
          55  +
{
          56  +
    let mut variant = None;
          57  +
    match tokens.next().transpose()? {
          58  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
          59  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
          60  +
            match tokens.next().transpose()? {
          61  +
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          62  +
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          63  +
                    if let ::std::option::Option::Some(::std::result::Result::Ok(
          64  +
                        ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          65  +
                    )) = tokens.peek()
          66  +
                    {
          67  +
                        let _ = tokens.next().expect("peek returned a token")?;
          68  +
                        continue;
          69  +
                    }
          70  +
                    let key = key.to_unescaped()?;
          71  +
                    if key == "__type" {
          72  +
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          73  +
                        continue;
          74  +
                    }
          75  +
                    if variant.is_some() {
          76  +
                        return Err(
          77  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          78  +
                                "encountered mixed variants in union",
          79  +
                            ),
          80  +
                        );
          81  +
                    }
          82  +
                    variant = match key.as_ref() {
          83  +
                        "unionMember" => Some(crate::model::PayloadUnion::UnionMember(
          84  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          85  +
                                tokens.next(),
          86  +
                            )?
          87  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          88  +
                            .transpose()?
          89  +
                            .ok_or_else(|| {
          90  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          91  +
                                    "value for 'unionMember' cannot be null",
          92  +
                                )
          93  +
                            })?,
          94  +
                        )),
          95  +
                        variant => {
          96  +
                            return Err(
          97  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          98  +
                                    format!("unexpected union variant: {variant}"),
          99  +
                                ),
         100  +
                            )
         101  +
                        }
         102  +
                    };
         103  +
                }
         104  +
                other => {
         105  +
                    return Err(
         106  +
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         107  +
                            "expected object key or end object, found: {other:?}"
         108  +
                        )),
         109  +
                    )
         110  +
                }
         111  +
            }
         112  +
        },
         113  +
        _ => {
         114  +
            return Err(
         115  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         116  +
                    "expected start object or null",
         117  +
                ),
         118  +
            )
         119  +
        }
         120  +
    }
         121  +
    if variant.is_none() {
         122  +
        return Err(
         123  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         124  +
                "Union did not contain a valid variant.",
         125  +
            ),
         126  +
        );
         127  +
    }
         128  +
    Ok(variant)
         129  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_service_unavailable_error.rs

@@ -0,1 +0,23 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_service_unavailable_error_error(
           3  +
    value: &crate::error::ServiceUnavailableError,
           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_unavailable_error::ser_service_unavailable_error(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_service_unavailable_error(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::error::ServiceUnavailableError,
          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  +
    Ok(())
          23  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_singleton_event.rs

@@ -0,1 +0,10 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_singleton_event(
           3  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
           4  +
    input: &crate::model::SingletonEvent,
           5  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    if let Some(var_1) = &input.value {
           7  +
        object.key("value").string(var_1.as_str());
           8  +
    }
           9  +
    Ok(())
          10  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_singleton_event_stream.rs

@@ -0,1 +0,18 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_singleton_event_stream(
           3  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
           4  +
    input: &crate::model::SingletonEventStream,
           5  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    match input {
           7  +
        crate::model::SingletonEventStream::Singleton(inner) => {
           8  +
            #[allow(unused_mut)]
           9  +
            let mut object_1 = object.key("singleton").start_object();
          10  +
            crate::protocol_serde::shape_singleton_event::ser_singleton_event(
          11  +
                &mut object_1,
          12  +
                inner,
          13  +
            )?;
          14  +
            object_1.finish();
          15  +
        }
          16  +
    }
          17  +
    Ok(())
          18  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_structure_payload_event.rs

@@ -0,1 +0,13 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_payload_payload(
           3  +
    input: &crate::model::PayloadStructure,
           4  +
) -> std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut out = String::new();
           9  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          10  +
    crate::protocol_serde::shape_payload_structure::ser_payload_structure(&mut object, input)?;
          11  +
    object.finish();
          12  +
    Ok(out.into_bytes())
          13  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_union_payload_event.rs

@@ -0,1 +0,13 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_payload_payload(
           3  +
    input: &crate::model::PayloadUnion,
           4  +
) -> std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut out = String::new();
           9  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          10  +
    crate::protocol_serde::shape_payload_union::ser_payload_union(&mut object, input)?;
          11  +
    object.finish();
          12  +
    Ok(out.into_bytes())
          13  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/python_event_stream.rs

@@ -0,1 +0,701 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[::pyo3::pyclass]
           3  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
           4  +
pub struct InputStreamInputStreamReceiver {
           5  +
    inner: ::std::sync::Arc<
           6  +
        ::tokio::sync::Mutex<
           7  +
            ::aws_smithy_legacy_http::event_stream::Receiver<
           8  +
                crate::model::EventStream,
           9  +
                crate::error::EventStreamError,
          10  +
            >,
          11  +
        >,
          12  +
    >,
          13  +
}
          14  +
impl InputStreamInputStreamReceiver {
          15  +
    pub fn new(
          16  +
        unmarshaller: impl ::aws_smithy_eventstream::frame::UnmarshallMessage<
          17  +
                Output = crate::model::EventStream,
          18  +
                Error = crate::error::EventStreamError,
          19  +
            > + ::std::marker::Send
          20  +
            + ::std::marker::Sync
          21  +
            + 'static,
          22  +
        body: ::aws_smithy_types::body::SdkBody,
          23  +
    ) -> InputStreamInputStreamReceiver {
          24  +
        let inner = ::aws_smithy_legacy_http::event_stream::Receiver::new(unmarshaller, body);
          25  +
        let inner = ::std::sync::Arc::new(::tokio::sync::Mutex::new(inner));
          26  +
        InputStreamInputStreamReceiver { inner }
          27  +
    }
          28  +
          29  +
    pub async fn try_recv_initial(
          30  +
        &mut self,
          31  +
        message_type: ::aws_smithy_legacy_http::event_stream::InitialMessageType,
          32  +
    ) -> Result<
          33  +
        ::std::option::Option<::aws_smithy_types::event_stream::Message>,
          34  +
        ::aws_smithy_runtime_api::client::result::SdkError<
          35  +
            crate::error::EventStreamError,
          36  +
            ::aws_smithy_types::event_stream::RawMessage,
          37  +
        >,
          38  +
    > {
          39  +
        let mut inner = self.inner.lock().await;
          40  +
        inner.try_recv_initial(message_type).await
          41  +
    }
          42  +
}
          43  +
#[::pyo3::pymethods]
          44  +
impl InputStreamInputStreamReceiver {
          45  +
    pub fn __aiter__(slf: ::pyo3::PyRef<Self>) -> ::pyo3::PyRef<Self> {
          46  +
        slf
          47  +
    }
          48  +
          49  +
    pub fn __anext__(slf: ::pyo3::PyRefMut<Self>) -> ::pyo3::PyResult<Option<::pyo3::PyObject>> {
          50  +
        let body = slf.inner.clone();
          51  +
        let fut = ::pyo3_asyncio::tokio::future_into_py(slf.py(), async move {
          52  +
            let mut inner = body.lock().await;
          53  +
            let next = inner.recv().await;
          54  +
            match next {
          55  +
                Ok(Some(data)) => Ok(::pyo3::Python::with_gil(|py| {
          56  +
                    ::pyo3::IntoPy::into_py(data, py)
          57  +
                })),
          58  +
                Ok(None) => Err(::pyo3::exceptions::PyStopAsyncIteration::new_err(
          59  +
                    "stream exhausted",
          60  +
                )),
          61  +
                Err(::aws_smithy_runtime_api::client::result::SdkError::ServiceError(
          62  +
                    service_err,
          63  +
                )) => Err(service_err.into_err().into()),
          64  +
                Err(err) => Err(::pyo3::exceptions::PyRuntimeError::new_err(err.to_string())),
          65  +
            }
          66  +
        })?;
          67  +
        Ok(Some(fut.into()))
          68  +
    }
          69  +
}
          70  +
          71  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
          72  +
pub struct OutputStreamOutputStreamEventStreamSender {
          73  +
    inner: ::std::sync::Arc<
          74  +
        ::parking_lot::Mutex<
          75  +
            ::std::option::Option<
          76  +
                ::aws_smithy_legacy_http::event_stream::EventStreamSender<
          77  +
                    crate::model::EventStream,
          78  +
                    crate::error::EventStreamError,
          79  +
                >,
          80  +
            >,
          81  +
        >,
          82  +
    >,
          83  +
}
          84  +
impl OutputStreamOutputStreamEventStreamSender {
          85  +
    pub fn into_body_stream(
          86  +
        self,
          87  +
        marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::model::EventStream>
          88  +
            + ::std::marker::Send
          89  +
            + ::std::marker::Sync
          90  +
            + 'static,
          91  +
        error_marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::error::EventStreamError>
          92  +
            + ::std::marker::Send
          93  +
            + ::std::marker::Sync
          94  +
            + 'static,
          95  +
        signer: impl ::aws_smithy_eventstream::frame::SignMessage
          96  +
            + ::std::marker::Send
          97  +
            + ::std::marker::Sync
          98  +
            + 'static,
          99  +
    ) -> ::aws_smithy_legacy_http::event_stream::MessageStreamAdapter<
         100  +
        crate::model::EventStream,
         101  +
        crate::error::EventStreamError,
         102  +
    > {
         103  +
        let mut inner = self.inner.lock();
         104  +
        let inner = inner.take().expect(
         105  +
                            "attempted to reuse an event stream. \
         106  +
                             that means you kept a reference to an event stream and tried to reuse it in another request, \
         107  +
                             event streams are request scoped and shouldn't be used outside of their bounded request scope"
         108  +
                        );
         109  +
        inner.into_body_stream(marshaller, error_marshaller, signer)
         110  +
    }
         111  +
}
         112  +
impl<'source> ::pyo3::FromPyObject<'source> for OutputStreamOutputStreamEventStreamSender {
         113  +
    fn extract(obj: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
         114  +
        use ::tokio_stream::StreamExt;
         115  +
        let stream = ::pyo3_asyncio::tokio::into_stream_v1(obj)?;
         116  +
        let stream = stream.filter_map(|res| {
         117  +
                        ::pyo3::Python::with_gil(|py| {
         118  +
                            // TODO(EventStreamImprovements): Add `InternalServerError` variant to all event streaming
         119  +
                            //                                errors and return that variant in case of errors here?
         120  +
                            match res {
         121  +
                                Ok(obj) => {
         122  +
                                    match obj.extract::<crate::model::EventStream>(py) {
         123  +
                                        Ok(it) => Some(Ok(it)),
         124  +
                                        Err(err) => {
         125  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         126  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the output type 'crate::model::EventStream' from streamed value");
         127  +
                                            None
         128  +
                                        },
         129  +
                                    }
         130  +
                                },
         131  +
                                Err(err) => {
         132  +
                                    match ::pyo3::IntoPy::into_py(err, py).extract::<crate::error::EventStreamError>(py) {
         133  +
                                        Ok(modelled_error) => Some(Err(modelled_error)),
         134  +
                                        Err(err) => {
         135  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         136  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the error type 'crate::error::EventStreamError' from raised exception");
         137  +
                                            None
         138  +
                                        }
         139  +
                                    }
         140  +
                                }
         141  +
                            }
         142  +
                        })
         143  +
                    });
         144  +
         145  +
        Ok(OutputStreamOutputStreamEventStreamSender {
         146  +
            inner: ::std::sync::Arc::new(::parking_lot::Mutex::new(Some(stream.into()))),
         147  +
        })
         148  +
    }
         149  +
}
         150  +
         151  +
impl ::pyo3::IntoPy<::pyo3::PyObject> for OutputStreamOutputStreamEventStreamSender {
         152  +
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
         153  +
        ::pyo3::exceptions::PyAttributeError::new_err("this is a write-only object").into_py(py)
         154  +
    }
         155  +
}
         156  +
         157  +
#[::pyo3::pyclass]
         158  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         159  +
pub struct DuplexStreamInputStreamReceiver {
         160  +
    inner: ::std::sync::Arc<
         161  +
        ::tokio::sync::Mutex<
         162  +
            ::aws_smithy_legacy_http::event_stream::Receiver<
         163  +
                crate::model::EventStream,
         164  +
                crate::error::EventStreamError,
         165  +
            >,
         166  +
        >,
         167  +
    >,
         168  +
}
         169  +
impl DuplexStreamInputStreamReceiver {
         170  +
    pub fn new(
         171  +
        unmarshaller: impl ::aws_smithy_eventstream::frame::UnmarshallMessage<
         172  +
                Output = crate::model::EventStream,
         173  +
                Error = crate::error::EventStreamError,
         174  +
            > + ::std::marker::Send
         175  +
            + ::std::marker::Sync
         176  +
            + 'static,
         177  +
        body: ::aws_smithy_types::body::SdkBody,
         178  +
    ) -> DuplexStreamInputStreamReceiver {
         179  +
        let inner = ::aws_smithy_legacy_http::event_stream::Receiver::new(unmarshaller, body);
         180  +
        let inner = ::std::sync::Arc::new(::tokio::sync::Mutex::new(inner));
         181  +
        DuplexStreamInputStreamReceiver { inner }
         182  +
    }
         183  +
         184  +
    pub async fn try_recv_initial(
         185  +
        &mut self,
         186  +
        message_type: ::aws_smithy_legacy_http::event_stream::InitialMessageType,
         187  +
    ) -> Result<
         188  +
        ::std::option::Option<::aws_smithy_types::event_stream::Message>,
         189  +
        ::aws_smithy_runtime_api::client::result::SdkError<
         190  +
            crate::error::EventStreamError,
         191  +
            ::aws_smithy_types::event_stream::RawMessage,
         192  +
        >,
         193  +
    > {
         194  +
        let mut inner = self.inner.lock().await;
         195  +
        inner.try_recv_initial(message_type).await
         196  +
    }
         197  +
}
         198  +
#[::pyo3::pymethods]
         199  +
impl DuplexStreamInputStreamReceiver {
         200  +
    pub fn __aiter__(slf: ::pyo3::PyRef<Self>) -> ::pyo3::PyRef<Self> {
         201  +
        slf
         202  +
    }
         203  +
         204  +
    pub fn __anext__(slf: ::pyo3::PyRefMut<Self>) -> ::pyo3::PyResult<Option<::pyo3::PyObject>> {
         205  +
        let body = slf.inner.clone();
         206  +
        let fut = ::pyo3_asyncio::tokio::future_into_py(slf.py(), async move {
         207  +
            let mut inner = body.lock().await;
         208  +
            let next = inner.recv().await;
         209  +
            match next {
         210  +
                Ok(Some(data)) => Ok(::pyo3::Python::with_gil(|py| {
         211  +
                    ::pyo3::IntoPy::into_py(data, py)
         212  +
                })),
         213  +
                Ok(None) => Err(::pyo3::exceptions::PyStopAsyncIteration::new_err(
         214  +
                    "stream exhausted",
         215  +
                )),
         216  +
                Err(::aws_smithy_runtime_api::client::result::SdkError::ServiceError(
         217  +
                    service_err,
         218  +
                )) => Err(service_err.into_err().into()),
         219  +
                Err(err) => Err(::pyo3::exceptions::PyRuntimeError::new_err(err.to_string())),
         220  +
            }
         221  +
        })?;
         222  +
        Ok(Some(fut.into()))
         223  +
    }
         224  +
}
         225  +
         226  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         227  +
pub struct DuplexStreamOutputStreamEventStreamSender {
         228  +
    inner: ::std::sync::Arc<
         229  +
        ::parking_lot::Mutex<
         230  +
            ::std::option::Option<
         231  +
                ::aws_smithy_legacy_http::event_stream::EventStreamSender<
         232  +
                    crate::model::EventStream,
         233  +
                    crate::error::EventStreamError,
         234  +
                >,
         235  +
            >,
         236  +
        >,
         237  +
    >,
         238  +
}
         239  +
impl DuplexStreamOutputStreamEventStreamSender {
         240  +
    pub fn into_body_stream(
         241  +
        self,
         242  +
        marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::model::EventStream>
         243  +
            + ::std::marker::Send
         244  +
            + ::std::marker::Sync
         245  +
            + 'static,
         246  +
        error_marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::error::EventStreamError>
         247  +
            + ::std::marker::Send
         248  +
            + ::std::marker::Sync
         249  +
            + 'static,
         250  +
        signer: impl ::aws_smithy_eventstream::frame::SignMessage
         251  +
            + ::std::marker::Send
         252  +
            + ::std::marker::Sync
         253  +
            + 'static,
         254  +
    ) -> ::aws_smithy_legacy_http::event_stream::MessageStreamAdapter<
         255  +
        crate::model::EventStream,
         256  +
        crate::error::EventStreamError,
         257  +
    > {
         258  +
        let mut inner = self.inner.lock();
         259  +
        let inner = inner.take().expect(
         260  +
                            "attempted to reuse an event stream. \
         261  +
                             that means you kept a reference to an event stream and tried to reuse it in another request, \
         262  +
                             event streams are request scoped and shouldn't be used outside of their bounded request scope"
         263  +
                        );
         264  +
        inner.into_body_stream(marshaller, error_marshaller, signer)
         265  +
    }
         266  +
}
         267  +
impl<'source> ::pyo3::FromPyObject<'source> for DuplexStreamOutputStreamEventStreamSender {
         268  +
    fn extract(obj: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
         269  +
        use ::tokio_stream::StreamExt;
         270  +
        let stream = ::pyo3_asyncio::tokio::into_stream_v1(obj)?;
         271  +
        let stream = stream.filter_map(|res| {
         272  +
                        ::pyo3::Python::with_gil(|py| {
         273  +
                            // TODO(EventStreamImprovements): Add `InternalServerError` variant to all event streaming
         274  +
                            //                                errors and return that variant in case of errors here?
         275  +
                            match res {
         276  +
                                Ok(obj) => {
         277  +
                                    match obj.extract::<crate::model::EventStream>(py) {
         278  +
                                        Ok(it) => Some(Ok(it)),
         279  +
                                        Err(err) => {
         280  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         281  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the output type 'crate::model::EventStream' from streamed value");
         282  +
                                            None
         283  +
                                        },
         284  +
                                    }
         285  +
                                },
         286  +
                                Err(err) => {
         287  +
                                    match ::pyo3::IntoPy::into_py(err, py).extract::<crate::error::EventStreamError>(py) {
         288  +
                                        Ok(modelled_error) => Some(Err(modelled_error)),
         289  +
                                        Err(err) => {
         290  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         291  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the error type 'crate::error::EventStreamError' from raised exception");
         292  +
                                            None
         293  +
                                        }
         294  +
                                    }
         295  +
                                }
         296  +
                            }
         297  +
                        })
         298  +
                    });
         299  +
         300  +
        Ok(DuplexStreamOutputStreamEventStreamSender {
         301  +
            inner: ::std::sync::Arc::new(::parking_lot::Mutex::new(Some(stream.into()))),
         302  +
        })
         303  +
    }
         304  +
}
         305  +
         306  +
impl ::pyo3::IntoPy<::pyo3::PyObject> for DuplexStreamOutputStreamEventStreamSender {
         307  +
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
         308  +
        ::pyo3::exceptions::PyAttributeError::new_err("this is a write-only object").into_py(py)
         309  +
    }
         310  +
}
         311  +
         312  +
#[::pyo3::pyclass]
         313  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         314  +
pub struct InputStreamWithInitialRequestInputStreamReceiver {
         315  +
    inner: ::std::sync::Arc<
         316  +
        ::tokio::sync::Mutex<
         317  +
            ::aws_smithy_legacy_http::event_stream::Receiver<
         318  +
                crate::model::EventStream,
         319  +
                crate::error::EventStreamError,
         320  +
            >,
         321  +
        >,
         322  +
    >,
         323  +
}
         324  +
impl InputStreamWithInitialRequestInputStreamReceiver {
         325  +
    pub fn new(
         326  +
        unmarshaller: impl ::aws_smithy_eventstream::frame::UnmarshallMessage<
         327  +
                Output = crate::model::EventStream,
         328  +
                Error = crate::error::EventStreamError,
         329  +
            > + ::std::marker::Send
         330  +
            + ::std::marker::Sync
         331  +
            + 'static,
         332  +
        body: ::aws_smithy_types::body::SdkBody,
         333  +
    ) -> InputStreamWithInitialRequestInputStreamReceiver {
         334  +
        let inner = ::aws_smithy_legacy_http::event_stream::Receiver::new(unmarshaller, body);
         335  +
        let inner = ::std::sync::Arc::new(::tokio::sync::Mutex::new(inner));
         336  +
        InputStreamWithInitialRequestInputStreamReceiver { inner }
         337  +
    }
         338  +
         339  +
    pub async fn try_recv_initial(
         340  +
        &mut self,
         341  +
        message_type: ::aws_smithy_legacy_http::event_stream::InitialMessageType,
         342  +
    ) -> Result<
         343  +
        ::std::option::Option<::aws_smithy_types::event_stream::Message>,
         344  +
        ::aws_smithy_runtime_api::client::result::SdkError<
         345  +
            crate::error::EventStreamError,
         346  +
            ::aws_smithy_types::event_stream::RawMessage,
         347  +
        >,
         348  +
    > {
         349  +
        let mut inner = self.inner.lock().await;
         350  +
        inner.try_recv_initial(message_type).await
         351  +
    }
         352  +
}
         353  +
#[::pyo3::pymethods]
         354  +
impl InputStreamWithInitialRequestInputStreamReceiver {
         355  +
    pub fn __aiter__(slf: ::pyo3::PyRef<Self>) -> ::pyo3::PyRef<Self> {
         356  +
        slf
         357  +
    }
         358  +
         359  +
    pub fn __anext__(slf: ::pyo3::PyRefMut<Self>) -> ::pyo3::PyResult<Option<::pyo3::PyObject>> {
         360  +
        let body = slf.inner.clone();
         361  +
        let fut = ::pyo3_asyncio::tokio::future_into_py(slf.py(), async move {
         362  +
            let mut inner = body.lock().await;
         363  +
            let next = inner.recv().await;
         364  +
            match next {
         365  +
                Ok(Some(data)) => Ok(::pyo3::Python::with_gil(|py| {
         366  +
                    ::pyo3::IntoPy::into_py(data, py)
         367  +
                })),
         368  +
                Ok(None) => Err(::pyo3::exceptions::PyStopAsyncIteration::new_err(
         369  +
                    "stream exhausted",
         370  +
                )),
         371  +
                Err(::aws_smithy_runtime_api::client::result::SdkError::ServiceError(
         372  +
                    service_err,
         373  +
                )) => Err(service_err.into_err().into()),
         374  +
                Err(err) => Err(::pyo3::exceptions::PyRuntimeError::new_err(err.to_string())),
         375  +
            }
         376  +
        })?;
         377  +
        Ok(Some(fut.into()))
         378  +
    }
         379  +
}
         380  +
         381  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         382  +
pub struct OutputStreamWithInitialResponseOutputStreamEventStreamSender {
         383  +
    inner: ::std::sync::Arc<
         384  +
        ::parking_lot::Mutex<
         385  +
            ::std::option::Option<
         386  +
                ::aws_smithy_legacy_http::event_stream::EventStreamSender<
         387  +
                    crate::model::EventStream,
         388  +
                    crate::error::EventStreamError,
         389  +
                >,
         390  +
            >,
         391  +
        >,
         392  +
    >,
         393  +
}
         394  +
impl OutputStreamWithInitialResponseOutputStreamEventStreamSender {
         395  +
    pub fn into_body_stream(
         396  +
        self,
         397  +
        marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::model::EventStream>
         398  +
            + ::std::marker::Send
         399  +
            + ::std::marker::Sync
         400  +
            + 'static,
         401  +
        error_marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::error::EventStreamError>
         402  +
            + ::std::marker::Send
         403  +
            + ::std::marker::Sync
         404  +
            + 'static,
         405  +
        signer: impl ::aws_smithy_eventstream::frame::SignMessage
         406  +
            + ::std::marker::Send
         407  +
            + ::std::marker::Sync
         408  +
            + 'static,
         409  +
    ) -> ::aws_smithy_legacy_http::event_stream::MessageStreamAdapter<
         410  +
        crate::model::EventStream,
         411  +
        crate::error::EventStreamError,
         412  +
    > {
         413  +
        let mut inner = self.inner.lock();
         414  +
        let inner = inner.take().expect(
         415  +
                            "attempted to reuse an event stream. \
         416  +
                             that means you kept a reference to an event stream and tried to reuse it in another request, \
         417  +
                             event streams are request scoped and shouldn't be used outside of their bounded request scope"
         418  +
                        );
         419  +
        inner.into_body_stream(marshaller, error_marshaller, signer)
         420  +
    }
         421  +
}
         422  +
impl<'source> ::pyo3::FromPyObject<'source>
         423  +
    for OutputStreamWithInitialResponseOutputStreamEventStreamSender
         424  +
{
         425  +
    fn extract(obj: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
         426  +
        use ::tokio_stream::StreamExt;
         427  +
        let stream = ::pyo3_asyncio::tokio::into_stream_v1(obj)?;
         428  +
        let stream = stream.filter_map(|res| {
         429  +
                        ::pyo3::Python::with_gil(|py| {
         430  +
                            // TODO(EventStreamImprovements): Add `InternalServerError` variant to all event streaming
         431  +
                            //                                errors and return that variant in case of errors here?
         432  +
                            match res {
         433  +
                                Ok(obj) => {
         434  +
                                    match obj.extract::<crate::model::EventStream>(py) {
         435  +
                                        Ok(it) => Some(Ok(it)),
         436  +
                                        Err(err) => {
         437  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         438  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the output type 'crate::model::EventStream' from streamed value");
         439  +
                                            None
         440  +
                                        },
         441  +
                                    }
         442  +
                                },
         443  +
                                Err(err) => {
         444  +
                                    match ::pyo3::IntoPy::into_py(err, py).extract::<crate::error::EventStreamError>(py) {
         445  +
                                        Ok(modelled_error) => Some(Err(modelled_error)),
         446  +
                                        Err(err) => {
         447  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         448  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the error type 'crate::error::EventStreamError' from raised exception");
         449  +
                                            None
         450  +
                                        }
         451  +
                                    }
         452  +
                                }
         453  +
                            }
         454  +
                        })
         455  +
                    });
         456  +
         457  +
        Ok(
         458  +
            OutputStreamWithInitialResponseOutputStreamEventStreamSender {
         459  +
                inner: ::std::sync::Arc::new(::parking_lot::Mutex::new(Some(stream.into()))),
         460  +
            },
         461  +
        )
         462  +
    }
         463  +
}
         464  +
         465  +
impl ::pyo3::IntoPy<::pyo3::PyObject>
         466  +
    for OutputStreamWithInitialResponseOutputStreamEventStreamSender
         467  +
{
         468  +
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
         469  +
        ::pyo3::exceptions::PyAttributeError::new_err("this is a write-only object").into_py(py)
         470  +
    }
         471  +
}
         472  +
         473  +
#[::pyo3::pyclass]
         474  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         475  +
pub struct DuplexStreamWithInitialMessagesInputStreamReceiver {
         476  +
    inner: ::std::sync::Arc<
         477  +
        ::tokio::sync::Mutex<
         478  +
            ::aws_smithy_legacy_http::event_stream::Receiver<
         479  +
                crate::model::EventStream,
         480  +
                crate::error::EventStreamError,
         481  +
            >,
         482  +
        >,
         483  +
    >,
         484  +
}
         485  +
impl DuplexStreamWithInitialMessagesInputStreamReceiver {
         486  +
    pub fn new(
         487  +
        unmarshaller: impl ::aws_smithy_eventstream::frame::UnmarshallMessage<
         488  +
                Output = crate::model::EventStream,
         489  +
                Error = crate::error::EventStreamError,
         490  +
            > + ::std::marker::Send
         491  +
            + ::std::marker::Sync
         492  +
            + 'static,
         493  +
        body: ::aws_smithy_types::body::SdkBody,
         494  +
    ) -> DuplexStreamWithInitialMessagesInputStreamReceiver {
         495  +
        let inner = ::aws_smithy_legacy_http::event_stream::Receiver::new(unmarshaller, body);
         496  +
        let inner = ::std::sync::Arc::new(::tokio::sync::Mutex::new(inner));
         497  +
        DuplexStreamWithInitialMessagesInputStreamReceiver { inner }
         498  +
    }
         499  +
         500  +
    pub async fn try_recv_initial(
         501  +
        &mut self,
         502  +
        message_type: ::aws_smithy_legacy_http::event_stream::InitialMessageType,
         503  +
    ) -> Result<
         504  +
        ::std::option::Option<::aws_smithy_types::event_stream::Message>,
         505  +
        ::aws_smithy_runtime_api::client::result::SdkError<
         506  +
            crate::error::EventStreamError,
         507  +
            ::aws_smithy_types::event_stream::RawMessage,
         508  +
        >,
         509  +
    > {
         510  +
        let mut inner = self.inner.lock().await;
         511  +
        inner.try_recv_initial(message_type).await
         512  +
    }
         513  +
}
         514  +
#[::pyo3::pymethods]
         515  +
impl DuplexStreamWithInitialMessagesInputStreamReceiver {
         516  +
    pub fn __aiter__(slf: ::pyo3::PyRef<Self>) -> ::pyo3::PyRef<Self> {
         517  +
        slf
         518  +
    }
         519  +
         520  +
    pub fn __anext__(slf: ::pyo3::PyRefMut<Self>) -> ::pyo3::PyResult<Option<::pyo3::PyObject>> {
         521  +
        let body = slf.inner.clone();
         522  +
        let fut = ::pyo3_asyncio::tokio::future_into_py(slf.py(), async move {
         523  +
            let mut inner = body.lock().await;
         524  +
            let next = inner.recv().await;
         525  +
            match next {
         526  +
                Ok(Some(data)) => Ok(::pyo3::Python::with_gil(|py| {
         527  +
                    ::pyo3::IntoPy::into_py(data, py)
         528  +
                })),
         529  +
                Ok(None) => Err(::pyo3::exceptions::PyStopAsyncIteration::new_err(
         530  +
                    "stream exhausted",
         531  +
                )),
         532  +
                Err(::aws_smithy_runtime_api::client::result::SdkError::ServiceError(
         533  +
                    service_err,
         534  +
                )) => Err(service_err.into_err().into()),
         535  +
                Err(err) => Err(::pyo3::exceptions::PyRuntimeError::new_err(err.to_string())),
         536  +
            }
         537  +
        })?;
         538  +
        Ok(Some(fut.into()))
         539  +
    }
         540  +
}
         541  +
         542  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         543  +
pub struct DuplexStreamWithInitialMessagesOutputStreamEventStreamSender {
         544  +
    inner: ::std::sync::Arc<
         545  +
        ::parking_lot::Mutex<
         546  +
            ::std::option::Option<
         547  +
                ::aws_smithy_legacy_http::event_stream::EventStreamSender<
         548  +
                    crate::model::EventStream,
         549  +
                    crate::error::EventStreamError,
         550  +
                >,
         551  +
            >,
         552  +
        >,
         553  +
    >,
         554  +
}
         555  +
impl DuplexStreamWithInitialMessagesOutputStreamEventStreamSender {
         556  +
    pub fn into_body_stream(
         557  +
        self,
         558  +
        marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::model::EventStream>
         559  +
            + ::std::marker::Send
         560  +
            + ::std::marker::Sync
         561  +
            + 'static,
         562  +
        error_marshaller: impl ::aws_smithy_eventstream::frame::MarshallMessage<Input = crate::error::EventStreamError>
         563  +
            + ::std::marker::Send
         564  +
            + ::std::marker::Sync
         565  +
            + 'static,
         566  +
        signer: impl ::aws_smithy_eventstream::frame::SignMessage
         567  +
            + ::std::marker::Send
         568  +
            + ::std::marker::Sync
         569  +
            + 'static,
         570  +
    ) -> ::aws_smithy_legacy_http::event_stream::MessageStreamAdapter<
         571  +
        crate::model::EventStream,
         572  +
        crate::error::EventStreamError,
         573  +
    > {
         574  +
        let mut inner = self.inner.lock();
         575  +
        let inner = inner.take().expect(
         576  +
                            "attempted to reuse an event stream. \
         577  +
                             that means you kept a reference to an event stream and tried to reuse it in another request, \
         578  +
                             event streams are request scoped and shouldn't be used outside of their bounded request scope"
         579  +
                        );
         580  +
        inner.into_body_stream(marshaller, error_marshaller, signer)
         581  +
    }
         582  +
}
         583  +
impl<'source> ::pyo3::FromPyObject<'source>
         584  +
    for DuplexStreamWithInitialMessagesOutputStreamEventStreamSender
         585  +
{
         586  +
    fn extract(obj: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
         587  +
        use ::tokio_stream::StreamExt;
         588  +
        let stream = ::pyo3_asyncio::tokio::into_stream_v1(obj)?;
         589  +
        let stream = stream.filter_map(|res| {
         590  +
                        ::pyo3::Python::with_gil(|py| {
         591  +
                            // TODO(EventStreamImprovements): Add `InternalServerError` variant to all event streaming
         592  +
                            //                                errors and return that variant in case of errors here?
         593  +
                            match res {
         594  +
                                Ok(obj) => {
         595  +
                                    match obj.extract::<crate::model::EventStream>(py) {
         596  +
                                        Ok(it) => Some(Ok(it)),
         597  +
                                        Err(err) => {
         598  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         599  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the output type 'crate::model::EventStream' from streamed value");
         600  +
                                            None
         601  +
                                        },
         602  +
                                    }
         603  +
                                },
         604  +
                                Err(err) => {
         605  +
                                    match ::pyo3::IntoPy::into_py(err, py).extract::<crate::error::EventStreamError>(py) {
         606  +
                                        Ok(modelled_error) => Some(Err(modelled_error)),
         607  +
                                        Err(err) => {
         608  +
                                            let rich_py_err = ::aws_smithy_http_server_python::rich_py_err(err);
         609  +
                                            ::tracing::error!(error = ?rich_py_err, "could not extract the error type 'crate::error::EventStreamError' from raised exception");
         610  +
                                            None
         611  +
                                        }
         612  +
                                    }
         613  +
                                }
         614  +
                            }
         615  +
                        })
         616  +
                    });
         617  +
         618  +
        Ok(
         619  +
            DuplexStreamWithInitialMessagesOutputStreamEventStreamSender {
         620  +
                inner: ::std::sync::Arc::new(::parking_lot::Mutex::new(Some(stream.into()))),
         621  +
            },
         622  +
        )
         623  +
    }
         624  +
}
         625  +
         626  +
impl ::pyo3::IntoPy<::pyo3::PyObject>
         627  +
    for DuplexStreamWithInitialMessagesOutputStreamEventStreamSender
         628  +
{
         629  +
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
         630  +
        ::pyo3::exceptions::PyAttributeError::new_err("this is a write-only object").into_py(py)
         631  +
    }
         632  +
}
         633  +
         634  +
#[::pyo3::pyclass]
         635  +
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
         636  +
pub struct DuplexStreamWithDistinctStreamsInputStreamReceiver {
         637  +
    inner: ::std::sync::Arc<
         638  +
        ::tokio::sync::Mutex<
         639  +
            ::aws_smithy_legacy_http::event_stream::Receiver<
         640  +
                crate::model::EventStream,
         641  +
                crate::error::EventStreamError,
         642  +
            >,
         643  +
        >,
         644  +
    >,
         645  +
}
         646  +
impl DuplexStreamWithDistinctStreamsInputStreamReceiver {
         647  +
    pub fn new(
         648  +
        unmarshaller: impl ::aws_smithy_eventstream::frame::UnmarshallMessage<
         649  +
                Output = crate::model::EventStream,
         650  +
                Error = crate::error::EventStreamError,
         651  +
            > + ::std::marker::Send
         652  +
            + ::std::marker::Sync
         653  +
            + 'static,
         654  +
        body: ::aws_smithy_types::body::SdkBody,
         655  +
    ) -> DuplexStreamWithDistinctStreamsInputStreamReceiver {
         656  +
        let inner = ::aws_smithy_legacy_http::event_stream::Receiver::new(unmarshaller, body);
         657  +
        let inner = ::std::sync::Arc::new(::tokio::sync::Mutex::new(inner));
         658  +
        DuplexStreamWithDistinctStreamsInputStreamReceiver { inner }
         659  +
    }
         660  +
         661  +
    pub async fn try_recv_initial(
         662  +
        &mut self,
         663  +
        message_type: ::aws_smithy_legacy_http::event_stream::InitialMessageType,
         664  +
    ) -> Result<
         665  +
        ::std::option::Option<::aws_smithy_types::event_stream::Message>,
         666  +
        ::aws_smithy_runtime_api::client::result::SdkError<
         667  +
            crate::error::EventStreamError,
         668  +
            ::aws_smithy_types::event_stream::RawMessage,
         669  +
        >,
         670  +
    > {
         671  +
        let mut inner = self.inner.lock().await;
         672  +
        inner.try_recv_initial(message_type).await
         673  +
    }
         674  +
}
         675  +
#[::pyo3::pymethods]
         676  +
impl DuplexStreamWithDistinctStreamsInputStreamReceiver {
         677  +
    pub fn __aiter__(slf: ::pyo3::PyRef<Self>) -> ::pyo3::PyRef<Self> {
         678  +
        slf
         679  +
    }
         680  +
         681  +
    pub fn __anext__(slf: ::pyo3::PyRefMut<Self>) -> ::pyo3::PyResult<Option<::pyo3::PyObject>> {
         682  +
        let body = slf.inner.clone();
         683  +
        let fut = ::pyo3_asyncio::tokio::future_into_py(slf.py(), async move {
         684  +
            let mut inner = body.lock().await;
         685  +
            let next = inner.recv().await;
         686  +
            match next {
         687  +
                Ok(Some(data)) => Ok(::pyo3::Python::with_gil(|py| {
         688  +
                    ::pyo3::IntoPy::into_py(data, py)
         689  +
                })),
         690  +
                Ok(None) => Err(::pyo3::exceptions::PyStopAsyncIteration::new_err(
         691  +
                    "stream exhausted",
         692  +
                )),
         693  +
                Err(::aws_smithy_runtime_api::client::result::SdkError::ServiceError(
         694  +
                    service_err,
         695  +
                )) => Err(service_err.into_err().into()),
         696  +
                Err(err) => Err(::pyo3::exceptions::PyRuntimeError::new_err(err.to_string())),
         697  +
            }
         698  +
        })?;
         699  +
        Ok(Some(fut.into()))
         700  +
    }
         701  +
}