Client Test

Client Test

rev. ec7b2441254af868911fccffe8d8dca83aff0045

Files changed:

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_primitive_int_op_input.rs

@@ -1,0 +13,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub fn ser_primitive_int_op_input_input(
    3         -
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    4         -
    input: &crate::operation::primitive_int_op::PrimitiveIntOpInput,
    5         -
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    6         -
    if let Some(var_1) = &input.value {
    7         -
        object.key("value").number(
    8         -
            #[allow(clippy::useless_conversion)]
    9         -
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
   10         -
        );
   11         -
    }
   12         -
    Ok(())
   13         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_query_precedence.rs

@@ -1,0 +49,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
#[allow(clippy::unnecessary_wraps)]
    3         -
pub fn de_query_precedence_http_error(
    4         -
    _response_status: u16,
    5         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    6         -
    _response_body: &[u8],
    7         -
) -> std::result::Result<crate::operation::query_precedence::QueryPrecedenceOutput, crate::operation::query_precedence::QueryPrecedenceError> {
    8         -
    #[allow(unused_mut)]
    9         -
    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
   10         -
        .map_err(crate::operation::query_precedence::QueryPrecedenceError::unhandled)?;
   11         -
    let generic = generic_builder.build();
   12         -
    let error_code = match generic.code() {
   13         -
        Some(code) => code,
   14         -
        None => return Err(crate::operation::query_precedence::QueryPrecedenceError::unhandled(generic)),
   15         -
    };
   16         -
   17         -
    let _error_message = generic.message().map(|msg| msg.to_owned());
   18         -
    Err(match error_code {
   19         -
        "ExtraError" => crate::operation::query_precedence::QueryPrecedenceError::ExtraError({
   20         -
            #[allow(unused_mut)]
   21         -
            let mut tmp = {
   22         -
                #[allow(unused_mut)]
   23         -
                let mut output = crate::types::error::builders::ExtraErrorBuilder::default();
   24         -
                output = crate::protocol_serde::shape_extra_error::de_extra_error_json_err(_response_body, output)
   25         -
                    .map_err(crate::operation::query_precedence::QueryPrecedenceError::unhandled)?;
   26         -
                let output = output.meta(generic);
   27         -
                output.build()
   28         -
            };
   29         -
            if tmp.message.is_none() {
   30         -
                tmp.message = _error_message;
   31         -
            }
   32         -
            tmp
   33         -
        }),
   34         -
        _ => crate::operation::query_precedence::QueryPrecedenceError::generic(generic),
   35         -
    })
   36         -
}
   37         -
   38         -
#[allow(clippy::unnecessary_wraps)]
   39         -
pub fn de_query_precedence_http_response(
   40         -
    _response_status: u16,
   41         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
   42         -
    _response_body: &[u8],
   43         -
) -> std::result::Result<crate::operation::query_precedence::QueryPrecedenceOutput, crate::operation::query_precedence::QueryPrecedenceError> {
   44         -
    Ok({
   45         -
        #[allow(unused_mut)]
   46         -
        let mut output = crate::operation::query_precedence::builders::QueryPrecedenceOutputBuilder::default();
   47         -
        output.build()
   48         -
    })
   49         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_single_element_union.rs

@@ -1,0 +64,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) fn de_single_element_union<'a, I>(
    3         -
    tokens: &mut ::std::iter::Peekable<I>,
    4         -
    _value: &'a [u8],
    5         -
) -> ::std::result::Result<Option<crate::types::SingleElementUnion>, ::aws_smithy_json::deserialize::error::DeserializeError>
    6         -
where
    7         -
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
    8         -
{
    9         -
    let mut variant = None;
   10         -
    match tokens.next().transpose()? {
   11         -
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
   12         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
   13         -
            match tokens.next().transpose()? {
   14         -
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   15         -
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   16         -
                    if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
   17         -
                        tokens.peek()
   18         -
                    {
   19         -
                        let _ = tokens.next().expect("peek returned a token")?;
   20         -
                        continue;
   21         -
                    }
   22         -
                    let key = key.to_unescaped()?;
   23         -
                    if key == "__type" {
   24         -
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   25         -
                        continue;
   26         -
                    }
   27         -
                    if variant.is_some() {
   28         -
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   29         -
                            "encountered mixed variants in union",
   30         -
                        ));
   31         -
                    }
   32         -
                    variant = match key.as_ref() {
   33         -
                        "a" => Some(crate::types::SingleElementUnion::A(
   34         -
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
   35         -
                                .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   36         -
                                .transpose()?
   37         -
                                .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'a' cannot be null"))?,
   38         -
                        )),
   39         -
                        _ => {
   40         -
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   41         -
                            Some(crate::types::SingleElementUnion::Unknown)
   42         -
                        }
   43         -
                    };
   44         -
                }
   45         -
                other => {
   46         -
                    return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   47         -
                        "expected object key or end object, found: {other:?}"
   48         -
                    )))
   49         -
                }
   50         -
            }
   51         -
        },
   52         -
        _ => {
   53         -
            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   54         -
                "expected start object or null",
   55         -
            ))
   56         -
        }
   57         -
    }
   58         -
    if variant.is_none() {
   59         -
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   60         -
            "Union did not contain a valid variant.",
   61         -
        ));
   62         -
    }
   63         -
    Ok(variant)
   64         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_status_response.rs

@@ -1,0 +50,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
#[allow(clippy::unnecessary_wraps)]
    3         -
pub fn de_status_response_http_error(
    4         -
    _response_status: u16,
    5         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    6         -
    _response_body: &[u8],
    7         -
) -> std::result::Result<crate::operation::status_response::StatusResponseOutput, crate::operation::status_response::StatusResponseError> {
    8         -
    #[allow(unused_mut)]
    9         -
    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
   10         -
        .map_err(crate::operation::status_response::StatusResponseError::unhandled)?;
   11         -
    let generic = generic_builder.build();
   12         -
    let error_code = match generic.code() {
   13         -
        Some(code) => code,
   14         -
        None => return Err(crate::operation::status_response::StatusResponseError::unhandled(generic)),
   15         -
    };
   16         -
   17         -
    let _error_message = generic.message().map(|msg| msg.to_owned());
   18         -
    Err(match error_code {
   19         -
        "ExtraError" => crate::operation::status_response::StatusResponseError::ExtraError({
   20         -
            #[allow(unused_mut)]
   21         -
            let mut tmp = {
   22         -
                #[allow(unused_mut)]
   23         -
                let mut output = crate::types::error::builders::ExtraErrorBuilder::default();
   24         -
                output = crate::protocol_serde::shape_extra_error::de_extra_error_json_err(_response_body, output)
   25         -
                    .map_err(crate::operation::status_response::StatusResponseError::unhandled)?;
   26         -
                let output = output.meta(generic);
   27         -
                output.build()
   28         -
            };
   29         -
            if tmp.message.is_none() {
   30         -
                tmp.message = _error_message;
   31         -
            }
   32         -
            tmp
   33         -
        }),
   34         -
        _ => crate::operation::status_response::StatusResponseError::generic(generic),
   35         -
    })
   36         -
}
   37         -
   38         -
#[allow(clippy::unnecessary_wraps)]
   39         -
pub fn de_status_response_http_response(
   40         -
    _response_status: u16,
   41         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
   42         -
    _response_body: &[u8],
   43         -
) -> std::result::Result<crate::operation::status_response::StatusResponseOutput, crate::operation::status_response::StatusResponseError> {
   44         -
    Ok({
   45         -
        #[allow(unused_mut)]
   46         -
        let mut output = crate::operation::status_response::builders::StatusResponseOutputBuilder::default();
   47         -
        output = output.set_field(Some(_response_status as _));
   48         -
        output.build()
   49         -
    })
   50         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_string_payload.rs

@@ -1,0 +50,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
#[allow(clippy::unnecessary_wraps)]
    3         -
pub fn de_string_payload_http_error(
    4         -
    _response_status: u16,
    5         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    6         -
    _response_body: &[u8],
    7         -
) -> std::result::Result<crate::operation::string_payload::StringPayloadOutput, crate::operation::string_payload::StringPayloadError> {
    8         -
    #[allow(unused_mut)]
    9         -
    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
   10         -
        .map_err(crate::operation::string_payload::StringPayloadError::unhandled)?;
   11         -
    let generic = generic_builder.build();
   12         -
    let error_code = match generic.code() {
   13         -
        Some(code) => code,
   14         -
        None => return Err(crate::operation::string_payload::StringPayloadError::unhandled(generic)),
   15         -
    };
   16         -
   17         -
    let _error_message = generic.message().map(|msg| msg.to_owned());
   18         -
    Err(match error_code {
   19         -
        "ExtraError" => crate::operation::string_payload::StringPayloadError::ExtraError({
   20         -
            #[allow(unused_mut)]
   21         -
            let mut tmp = {
   22         -
                #[allow(unused_mut)]
   23         -
                let mut output = crate::types::error::builders::ExtraErrorBuilder::default();
   24         -
                output = crate::protocol_serde::shape_extra_error::de_extra_error_json_err(_response_body, output)
   25         -
                    .map_err(crate::operation::string_payload::StringPayloadError::unhandled)?;
   26         -
                let output = output.meta(generic);
   27         -
                output.build()
   28         -
            };
   29         -
            if tmp.message.is_none() {
   30         -
                tmp.message = _error_message;
   31         -
            }
   32         -
            tmp
   33         -
        }),
   34         -
        _ => crate::operation::string_payload::StringPayloadError::generic(generic),
   35         -
    })
   36         -
}
   37         -
   38         -
#[allow(clippy::unnecessary_wraps)]
   39         -
pub fn de_string_payload_http_response(
   40         -
    _response_status: u16,
   41         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
   42         -
    _response_body: &[u8],
   43         -
) -> std::result::Result<crate::operation::string_payload::StringPayloadOutput, crate::operation::string_payload::StringPayloadError> {
   44         -
    Ok({
   45         -
        #[allow(unused_mut)]
   46         -
        let mut output = crate::operation::string_payload::builders::StringPayloadOutputBuilder::default();
   47         -
        output = output.set_payload(crate::protocol_serde::shape_string_payload_output::de_payload_payload(_response_body)?);
   48         -
        output.build()
   49         -
    })
   50         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_string_payload_input.rs

@@ -1,0 +10,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub fn ser_payload_http_payload(
    3         -
    payload: ::std::option::Option<::std::string::String>,
    4         -
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
    5         -
    let payload = match payload {
    6         -
        Some(t) => t,
    7         -
        None => return Ok(Vec::new()),
    8         -
    };
    9         -
    Ok(payload.into_bytes())
   10         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_string_payload_output.rs

@@ -1,0 +11,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) fn de_payload_payload(
    3         -
    body: &[u8],
    4         -
) -> std::result::Result<::std::option::Option<::std::string::String>, crate::operation::string_payload::StringPayloadError> {
    5         -
    (!body.is_empty())
    6         -
        .then(|| {
    7         -
            let body_str = std::str::from_utf8(body).map_err(crate::operation::string_payload::StringPayloadError::unhandled)?;
    8         -
            Ok(body_str.to_string())
    9         -
        })
   10         -
        .transpose()
   11         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_validation_exception.rs

@@ -1,0 +40,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) fn de_validation_exception_json_err(
    3         -
    _value: &[u8],
    4         -
    mut builder: crate::types::error::builders::ValidationErrorBuilder,
    5         -
) -> ::std::result::Result<crate::types::error::builders::ValidationErrorBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
    6         -
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
    7         -
    let tokens = &mut tokens_owned;
    8         -
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
    9         -
    loop {
   10         -
        match tokens.next().transpose()? {
   11         -
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   12         -
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
   13         -
                "message" => {
   14         -
                    builder = builder.set_message(
   15         -
                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
   16         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   17         -
                            .transpose()?,
   18         -
                    );
   19         -
                }
   20         -
                "fieldList" => {
   21         -
                    builder = builder.set_field_list(
   22         -
                        crate::protocol_serde::shape_validation_exception_field_list::de_validation_exception_field_list(tokens, _value)?,
   23         -
                    );
   24         -
                }
   25         -
                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
   26         -
            },
   27         -
            other => {
   28         -
                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   29         -
                    "expected object key or end object, found: {other:?}"
   30         -
                )))
   31         -
            }
   32         -
        }
   33         -
    }
   34         -
    if tokens.next().is_some() {
   35         -
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   36         -
            "found more JSON tokens after completing parsing",
   37         -
        ));
   38         -
    }
   39         -
    Ok(builder)
   40         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_validation_exception_field.rs

@@ -1,0 +51,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) fn de_validation_exception_field<'a, I>(
    3         -
    tokens: &mut ::std::iter::Peekable<I>,
    4         -
    _value: &'a [u8],
    5         -
) -> ::std::result::Result<Option<crate::types::ValidationExceptionField>, ::aws_smithy_json::deserialize::error::DeserializeError>
    6         -
where
    7         -
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
    8         -
{
    9         -
    match tokens.next().transpose()? {
   10         -
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   11         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
   12         -
            #[allow(unused_mut)]
   13         -
            let mut builder = crate::types::builders::ValidationExceptionFieldBuilder::default();
   14         -
            loop {
   15         -
                match tokens.next().transpose()? {
   16         -
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   17         -
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
   18         -
                        "path" => {
   19         -
                            builder = builder.set_path(
   20         -
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
   21         -
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   22         -
                                    .transpose()?,
   23         -
                            );
   24         -
                        }
   25         -
                        "message" => {
   26         -
                            builder = builder.set_message(
   27         -
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
   28         -
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   29         -
                                    .transpose()?,
   30         -
                            );
   31         -
                        }
   32         -
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
   33         -
                    },
   34         -
                    other => {
   35         -
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   36         -
                            "expected object key or end object, found: {other:?}"
   37         -
                        )))
   38         -
                    }
   39         -
                }
   40         -
            }
   41         -
            Ok(Some(
   42         -
                crate::serde_util::validation_exception_field_correct_errors(builder)
   43         -
                    .build()
   44         -
                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
   45         -
            ))
   46         -
        }
   47         -
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   48         -
            "expected start object or null",
   49         -
        )),
   50         -
    }
   51         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/protocol_serde/shape_validation_exception_field_list.rs

@@ -1,0 +37,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) fn de_validation_exception_field_list<'a, I>(
    3         -
    tokens: &mut ::std::iter::Peekable<I>,
    4         -
    _value: &'a [u8],
    5         -
) -> ::std::result::Result<Option<::std::vec::Vec<crate::types::ValidationExceptionField>>, ::aws_smithy_json::deserialize::error::DeserializeError>
    6         -
where
    7         -
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
    8         -
{
    9         -
    match tokens.next().transpose()? {
   10         -
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   11         -
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
   12         -
            let mut items = Vec::new();
   13         -
            loop {
   14         -
                match tokens.peek() {
   15         -
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
   16         -
                        tokens.next().transpose().unwrap();
   17         -
                        break;
   18         -
                    }
   19         -
                    _ => {
   20         -
                        let value = crate::protocol_serde::shape_validation_exception_field::de_validation_exception_field(tokens, _value)?;
   21         -
                        if let Some(value) = value {
   22         -
                            items.push(value);
   23         -
                        } else {
   24         -
                            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   25         -
                                "dense list cannot contain null values",
   26         -
                            ));
   27         -
                        }
   28         -
                    }
   29         -
                }
   30         -
            }
   31         -
            Ok(Some(items))
   32         -
        }
   33         -
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
   34         -
            "expected start array or null",
   35         -
        )),
   36         -
    }
   37         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/serde_util.rs

@@ -1,0 +30,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) fn validation_exception_correct_errors(
    3         -
    mut builder: crate::types::error::builders::ValidationErrorBuilder,
    4         -
) -> crate::types::error::builders::ValidationErrorBuilder {
    5         -
    if builder.message.is_none() {
    6         -
        builder.message = Some(Default::default())
    7         -
    }
    8         -
    builder
    9         -
}
   10         -
   11         -
pub(crate) fn primitive_int_header_output_output_correct_errors(
   12         -
    mut builder: crate::operation::primitive_int_header::builders::PrimitiveIntHeaderOutputBuilder,
   13         -
) -> crate::operation::primitive_int_header::builders::PrimitiveIntHeaderOutputBuilder {
   14         -
    if builder.field.is_none() {
   15         -
        builder.field = Some(Default::default())
   16         -
    }
   17         -
    builder
   18         -
}
   19         -
   20         -
pub(crate) fn validation_exception_field_correct_errors(
   21         -
    mut builder: crate::types::builders::ValidationExceptionFieldBuilder,
   22         -
) -> crate::types::builders::ValidationExceptionFieldBuilder {
   23         -
    if builder.path.is_none() {
   24         -
        builder.path = Some(Default::default())
   25         -
    }
   26         -
    if builder.message.is_none() {
   27         -
        builder.message = Some(Default::default())
   28         -
    }
   29         -
    builder
   30         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/serialization_settings.rs

@@ -1,0 +89,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
/*
    3         -
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
    4         -
 * SPDX-License-Identifier: Apache-2.0
    5         -
 */
    6         -
    7         -
#![allow(dead_code)]
    8         -
    9         -
use aws_smithy_http::header::set_request_header_if_absent;
   10         -
use aws_smithy_types::config_bag::{Storable, StoreReplace};
   11         -
use http_1x::header::{HeaderName, CONTENT_LENGTH, CONTENT_TYPE};
   12         -
   13         -
/// Configuration for how default protocol headers are serialized
   14         -
#[derive(Clone, Debug, Default)]
   15         -
pub(crate) struct HeaderSerializationSettings {
   16         -
    omit_default_content_length: bool,
   17         -
    omit_default_content_type: bool,
   18         -
}
   19         -
   20         -
impl HeaderSerializationSettings {
   21         -
    /// Creates new [`HeaderSerializationSettings`]
   22         -
    pub(crate) fn new() -> Self {
   23         -
        Default::default()
   24         -
    }
   25         -
   26         -
    /// Omit the default `Content-Length` header during serialization
   27         -
    pub(crate) fn omit_default_content_length(self) -> Self {
   28         -
        Self {
   29         -
            omit_default_content_length: true,
   30         -
            ..self
   31         -
        }
   32         -
    }
   33         -
   34         -
    /// Omit the default `Content-Type` header during serialization
   35         -
    pub(crate) fn omit_default_content_type(self) -> Self {
   36         -
        Self {
   37         -
            omit_default_content_type: true,
   38         -
            ..self
   39         -
        }
   40         -
    }
   41         -
   42         -
    /// Returns true if the given default header name should be serialized
   43         -
    fn include_header(&self, header: &HeaderName) -> bool {
   44         -
        (!self.omit_default_content_length || header != CONTENT_LENGTH) && (!self.omit_default_content_type || header != CONTENT_TYPE)
   45         -
    }
   46         -
   47         -
    /// Sets a default header on the given request builder if it should be serialized
   48         -
    pub(crate) fn set_default_header(
   49         -
        &self,
   50         -
        mut request: http_1x::request::Builder,
   51         -
        header_name: HeaderName,
   52         -
        value: &str,
   53         -
    ) -> http_1x::request::Builder {
   54         -
        if self.include_header(&header_name) {
   55         -
            request = set_request_header_if_absent(request, header_name, value);
   56         -
        }
   57         -
        request
   58         -
    }
   59         -
}
   60         -
   61         -
impl Storable for HeaderSerializationSettings {
   62         -
    type Storer = StoreReplace<Self>;
   63         -
}
   64         -
   65         -
#[cfg(test)]
   66         -
mod tests {
   67         -
    use super::*;
   68         -
   69         -
    #[test]
   70         -
    fn test_include_header() {
   71         -
        let settings = HeaderSerializationSettings::default();
   72         -
        assert!(settings.include_header(&CONTENT_LENGTH));
   73         -
        assert!(settings.include_header(&CONTENT_TYPE));
   74         -
   75         -
        let settings = HeaderSerializationSettings::default().omit_default_content_length();
   76         -
        assert!(!settings.include_header(&CONTENT_LENGTH));
   77         -
        assert!(settings.include_header(&CONTENT_TYPE));
   78         -
   79         -
        let settings = HeaderSerializationSettings::default().omit_default_content_type();
   80         -
        assert!(settings.include_header(&CONTENT_LENGTH));
   81         -
        assert!(!settings.include_header(&CONTENT_TYPE));
   82         -
   83         -
        let settings = HeaderSerializationSettings::default()
   84         -
            .omit_default_content_type()
   85         -
            .omit_default_content_length();
   86         -
        assert!(!settings.include_header(&CONTENT_LENGTH));
   87         -
        assert!(!settings.include_header(&CONTENT_TYPE));
   88         -
    }
   89         -
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/types/_empty_struct.rs

@@ -1,1 +62,73 @@
   15     15   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   16     16   
    fn serialize_members(
   17     17   
        &self,
   18     18   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   19     19   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   20     20   
        Ok(())
   21     21   
    }
   22     22   
}
   23     23   
impl EmptyStruct {
   24     24   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   25         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   26         -
        deserializer: &mut D,
          25  +
    pub fn deserialize(
          26  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   27     27   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   28     28   
        #[allow(unused_variables, unused_mut)]
   29     29   
        let mut builder = Self::builder();
   30     30   
        #[allow(
   31     31   
            unused_variables,
   32     32   
            unreachable_code,
   33     33   
            clippy::single_match,
   34     34   
            clippy::match_single_binding,
   35     35   
            clippy::diverging_sub_expression
   36     36   
        )]
   37         -
        deserializer.read_struct(&EMPTYSTRUCT_SCHEMA, (), |_, member, deser| {
          37  +
        deserializer.read_struct(&EMPTYSTRUCT_SCHEMA, &mut |member, deser| {
   38     38   
            match member.member_index() {
   39     39   
                _ => {}
   40     40   
            }
   41     41   
            Ok(())
   42     42   
        })?;
   43     43   
        Ok(builder.build())
   44     44   
    }
   45     45   
}
          46  +
impl EmptyStruct {
          47  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          48  +
    pub fn deserialize_with_response(
          49  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          50  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          51  +
        _status: u16,
          52  +
        _body: &[u8],
          53  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          54  +
        Ok(Self::builder().build())
          55  +
    }
          56  +
}
   46     57   
impl EmptyStruct {
   47     58   
    /// Creates a new builder-style object to manufacture [`EmptyStruct`](crate::types::EmptyStruct).
   48     59   
    pub fn builder() -> crate::types::builders::EmptyStructBuilder {
   49     60   
        crate::types::builders::EmptyStructBuilder::default()
   50     61   
    }
   51     62   
}
   52     63   
   53     64   
/// A builder for [`EmptyStruct`](crate::types::EmptyStruct).
   54     65   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   55     66   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/types/_single_element_union.rs

@@ -8,8 +0,93 @@
   28     28   
    }
   29     29   
    /// Returns true if this is a [`A`](crate::types::SingleElementUnion::A).
   30     30   
    pub fn is_a(&self) -> bool {
   31     31   
        self.as_a().is_ok()
   32     32   
    }
   33     33   
    /// Returns true if the enum instance is the `Unknown` variant.
   34     34   
    pub fn is_unknown(&self) -> bool {
   35     35   
        matches!(self, Self::Unknown)
   36     36   
    }
   37     37   
}
          38  +
static SINGLEELEMENTUNION_SCHEMA_ID: ::aws_smithy_schema::ShapeId = ::aws_smithy_schema::ShapeId::from_static(
          39  +
    "aws.protocoltests.restjson#SingleElementUnion",
          40  +
    "aws.protocoltests.restjson",
          41  +
    "SingleElementUnion",
          42  +
);
          43  +
static SINGLEELEMENTUNION_MEMBER_A: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
          44  +
    ::aws_smithy_schema::ShapeId::from_static(
          45  +
        "aws.protocoltests.restjson#SingleElementUnion$a",
          46  +
        "aws.protocoltests.restjson",
          47  +
        "SingleElementUnion",
          48  +
    ),
          49  +
    ::aws_smithy_schema::ShapeType::String,
          50  +
    "a",
          51  +
    0,
          52  +
);
          53  +
static SINGLEELEMENTUNION_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
          54  +
    SINGLEELEMENTUNION_SCHEMA_ID,
          55  +
    ::aws_smithy_schema::ShapeType::Union,
          56  +
    &[&SINGLEELEMENTUNION_MEMBER_A],
          57  +
);
          58  +
impl SingleElementUnion {
          59  +
    /// The schema for this shape.
          60  +
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &SINGLEELEMENTUNION_SCHEMA;
          61  +
}
          62  +
impl ::aws_smithy_schema::serde::SerializableStruct for SingleElementUnion {
          63  +
    #[allow(unused_variables, clippy::diverging_sub_expression)]
          64  +
    fn serialize_members(
          65  +
        &self,
          66  +
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
          67  +
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
          68  +
        match self {
          69  +
            Self::A(val) => {
          70  +
                ser.write_string(&SINGLEELEMENTUNION_MEMBER_A, val)?;
          71  +
            }
          72  +
            Self::Unknown => return Err(::aws_smithy_schema::serde::SerdeError::custom("cannot serialize unknown union variant")),
          73  +
        }
          74  +
        Ok(())
          75  +
    }
          76  +
}
          77  +
impl SingleElementUnion {
          78  +
    /// Deserializes this union from a [`ShapeDeserializer`].
          79  +
    pub fn deserialize(
          80  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          81  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          82  +
        let mut result: ::std::option::Option<Self> = ::std::option::Option::None;
          83  +
        #[allow(unused_variables, unreachable_code, clippy::single_match, clippy::match_single_binding)]
          84  +
        deserializer.read_struct(&SINGLEELEMENTUNION_SCHEMA, &mut |member, deser| {
          85  +
            result = ::std::option::Option::Some(match member.member_index() {
          86  +
                Some(0) => Self::A(deser.read_string(member)?),
          87  +
                _ => Self::Unknown,
          88  +
            });
          89  +
            Ok(())
          90  +
        })?;
          91  +
        result.ok_or_else(|| ::aws_smithy_schema::serde::SerdeError::custom("expected a union variant"))
          92  +
    }
          93  +
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/types/_validation_exception_field.rs

@@ -47,47 +135,148 @@
   67     67   
        }
   68     68   
        {
   69     69   
            let val = &self.message;
   70     70   
            ser.write_string(&VALIDATIONEXCEPTIONFIELD_MEMBER_MESSAGE, val)?;
   71     71   
        }
   72     72   
        Ok(())
   73     73   
    }
   74     74   
}
   75     75   
impl ValidationExceptionField {
   76     76   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   77         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   78         -
        deserializer: &mut D,
          77  +
    pub fn deserialize(
          78  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   79     79   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   80     80   
        #[allow(unused_variables, unused_mut)]
   81     81   
        let mut builder = Self::builder();
   82     82   
        #[allow(
   83     83   
            unused_variables,
   84     84   
            unreachable_code,
   85     85   
            clippy::single_match,
   86     86   
            clippy::match_single_binding,
   87     87   
            clippy::diverging_sub_expression
   88     88   
        )]
   89         -
        deserializer.read_struct(&VALIDATIONEXCEPTIONFIELD_SCHEMA, (), |_, member, deser| {
          89  +
        deserializer.read_struct(&VALIDATIONEXCEPTIONFIELD_SCHEMA, &mut |member, deser| {
   90     90   
            match member.member_index() {
   91     91   
                Some(0) => {
   92     92   
                    builder.path = Some(deser.read_string(member)?);
   93     93   
                }
   94     94   
                Some(1) => {
   95     95   
                    builder.message = Some(deser.read_string(member)?);
   96     96   
                }
   97     97   
                _ => {}
   98     98   
            }
   99     99   
            Ok(())
  100    100   
        })?;
         101  +
        builder.path = builder.path.or(Some(String::new()));
         102  +
        builder.message = builder.message.or(Some(String::new()));
  101    103   
        builder
  102    104   
            .build()
  103    105   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  104    106   
    }
  105    107   
}
         108  +
impl ValidationExceptionField {
         109  +
    /// Deserializes this structure from a body deserializer and HTTP response.
         110  +
    pub fn deserialize_with_response(
         111  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         112  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
         113  +
        _status: u16,
         114  +
        _body: &[u8],
         115  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         116  +
        Self::deserialize(deserializer)
         117  +
    }
         118  +
}
  106    119   
impl ValidationExceptionField {
  107    120   
    /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::types::ValidationExceptionField).
  108    121   
    pub fn builder() -> crate::types::builders::ValidationExceptionFieldBuilder {
  109    122   
        crate::types::builders::ValidationExceptionFieldBuilder::default()
  110    123   
    }
  111    124   
}
  112    125   
  113    126   
/// A builder for [`ValidationExceptionField`](crate::types::ValidationExceptionField).
  114    127   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  115    128   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/types/error/_case_insensitive_error.rs

@@ -18,18 +101,112 @@
   38     38   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   39     39   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   40     40   
        if let Some(ref val) = self.message {
   41     41   
            ser.write_string(&CASEINSENSITIVEERROR_MEMBER_MESSAGE, val)?;
   42     42   
        }
   43     43   
        Ok(())
   44     44   
    }
   45     45   
}
   46     46   
impl CaseInsensitiveError {
   47     47   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   48         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   49         -
        deserializer: &mut D,
          48  +
    pub fn deserialize(
          49  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   50     50   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   51     51   
        #[allow(unused_variables, unused_mut)]
   52     52   
        let mut builder = Self::builder();
   53     53   
        #[allow(
   54     54   
            unused_variables,
   55     55   
            unreachable_code,
   56     56   
            clippy::single_match,
   57     57   
            clippy::match_single_binding,
   58     58   
            clippy::diverging_sub_expression
   59     59   
        )]
   60         -
        deserializer.read_struct(&CASEINSENSITIVEERROR_SCHEMA, (), |_, member, deser| {
          60  +
        deserializer.read_struct(&CASEINSENSITIVEERROR_SCHEMA, &mut |member, deser| {
   61     61   
            match member.member_index() {
   62     62   
                Some(0) => {
   63     63   
                    builder.message = Some(deser.read_string(member)?);
   64     64   
                }
   65     65   
                _ => {}
   66     66   
            }
   67     67   
            Ok(())
   68     68   
        })?;
   69     69   
        Ok(builder.build())
   70     70   
    }
   71     71   
}
          72  +
impl CaseInsensitiveError {
          73  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          74  +
    pub fn deserialize_with_response(
          75  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          76  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          77  +
        _status: u16,
          78  +
        _body: &[u8],
          79  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          80  +
        Self::deserialize(deserializer)
          81  +
    }
          82  +
}
   72     83   
impl CaseInsensitiveError {
   73     84   
    /// Returns the error message.
   74     85   
    pub fn message(&self) -> ::std::option::Option<&str> {
   75     86   
        self.message.as_deref()
   76     87   
    }
   77     88   
}
   78     89   
impl ::std::fmt::Display for CaseInsensitiveError {
   79     90   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
   80     91   
        ::std::write!(f, "CaseInsensitiveError")?;
   81     92   
        if let ::std::option::Option::Some(inner_1) = &self.message {