Server Test

Server Test

rev. 0b749be6d000fdc7ef59d1bc26f1dce00358d95c (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/rest_json_extras/rust-server-codegen/src/error.rs

@@ -1,1 +275,57 @@
   18     18   
    }
   19     19   
}
   20     20   
impl ::std::error::Error for ExtraError {}
   21     21   
impl ExtraError {
   22     22   
    /// Creates a new builder-style object to manufacture [`ExtraError`](crate::error::ExtraError).
   23     23   
    pub fn builder() -> crate::error::extra_error::Builder {
   24     24   
        crate::error::extra_error::Builder::default()
   25     25   
    }
   26     26   
}
   27     27   
   28         -
/// Error type for the `HttpStringPayload2` operation.
   29         -
/// Each variant represents an error that can occur for the `HttpStringPayload2` operation.
   30         -
#[derive(::std::fmt::Debug)]
   31         -
pub enum HttpStringPayload2Error {
   32         -
    #[allow(missing_docs)] // documentation missing in model
   33         -
    ExtraError(crate::error::ExtraError),
   34         -
}
   35         -
impl ::std::fmt::Display for HttpStringPayload2Error {
   36         -
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
   37         -
        match &self {
   38         -
            HttpStringPayload2Error::ExtraError(_inner) => _inner.fmt(f),
   39         -
        }
   40         -
    }
   41         -
}
   42         -
impl HttpStringPayload2Error {
   43         -
    /// Returns `true` if the error kind is `HttpStringPayload2Error::ExtraError`.
   44         -
    pub fn is_extra_error(&self) -> bool {
   45         -
        matches!(&self, HttpStringPayload2Error::ExtraError(_))
   46         -
    }
   47         -
    /// Returns the error name string by matching the correct variant.
   48         -
    pub fn name(&self) -> &'static str {
   49         -
        match &self {
   50         -
            HttpStringPayload2Error::ExtraError(_inner) => _inner.name(),
   51         -
        }
   52         -
    }
   53         -
}
   54         -
impl ::std::error::Error for HttpStringPayload2Error {
   55         -
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
   56         -
        match &self {
   57         -
            HttpStringPayload2Error::ExtraError(_inner) => Some(_inner),
   58         -
        }
   59         -
    }
   60         -
}
   61         -
impl ::std::convert::From<crate::error::ExtraError> for crate::error::HttpStringPayload2Error {
   62         -
    fn from(variant: crate::error::ExtraError) -> crate::error::HttpStringPayload2Error {
   63         -
        Self::ExtraError(variant)
   64         -
    }
   65         -
}
   66         -
   67         -
/// Error type for the `HttpEnumPayload2` operation.
   68         -
/// Each variant represents an error that can occur for the `HttpEnumPayload2` operation.
   69         -
#[derive(::std::fmt::Debug)]
   70         -
pub enum HttpEnumPayload2Error {
   71         -
    /// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
   72         -
    ValidationException(crate::error::ValidationException),
   73         -
    #[allow(missing_docs)] // documentation missing in model
   74         -
    ExtraError(crate::error::ExtraError),
   75         -
}
   76         -
impl ::std::fmt::Display for HttpEnumPayload2Error {
   77         -
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
   78         -
        match &self {
   79         -
            HttpEnumPayload2Error::ValidationException(_inner) => _inner.fmt(f),
   80         -
            HttpEnumPayload2Error::ExtraError(_inner) => _inner.fmt(f),
   81         -
        }
   82         -
    }
   83         -
}
   84         -
impl HttpEnumPayload2Error {
   85         -
    /// Returns `true` if the error kind is `HttpEnumPayload2Error::ValidationException`.
   86         -
    pub fn is_validation_exception(&self) -> bool {
   87         -
        matches!(&self, HttpEnumPayload2Error::ValidationException(_))
   88         -
    }
   89         -
    /// Returns `true` if the error kind is `HttpEnumPayload2Error::ExtraError`.
   90         -
    pub fn is_extra_error(&self) -> bool {
   91         -
        matches!(&self, HttpEnumPayload2Error::ExtraError(_))
   92         -
    }
   93         -
    /// Returns the error name string by matching the correct variant.
   94         -
    pub fn name(&self) -> &'static str {
   95         -
        match &self {
   96         -
            HttpEnumPayload2Error::ValidationException(_inner) => _inner.name(),
   97         -
            HttpEnumPayload2Error::ExtraError(_inner) => _inner.name(),
   98         -
        }
   99         -
    }
  100         -
}
  101         -
impl ::std::error::Error for HttpEnumPayload2Error {
  102         -
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
  103         -
        match &self {
  104         -
            HttpEnumPayload2Error::ValidationException(_inner) => Some(_inner),
  105         -
            HttpEnumPayload2Error::ExtraError(_inner) => Some(_inner),
  106         -
        }
  107         -
    }
  108         -
}
  109         -
impl ::std::convert::From<crate::error::ValidationException>
  110         -
    for crate::error::HttpEnumPayload2Error
  111         -
{
  112         -
    fn from(variant: crate::error::ValidationException) -> crate::error::HttpEnumPayload2Error {
  113         -
        Self::ValidationException(variant)
  114         -
    }
  115         -
}
  116         -
impl ::std::convert::From<crate::error::ExtraError> for crate::error::HttpEnumPayload2Error {
  117         -
    fn from(variant: crate::error::ExtraError) -> crate::error::HttpEnumPayload2Error {
  118         -
        Self::ExtraError(variant)
  119         -
    }
  120         -
}
  121         -
  122         -
/// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
  123         -
#[derive(
  124         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  125         -
)]
  126         -
pub struct ValidationException {
  127         -
    /// A summary of the validation failure.
  128         -
    pub message: ::std::string::String,
  129         -
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
  130         -
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  131         -
}
  132         -
impl ValidationException {
  133         -
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
  134         -
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
  135         -
        self.field_list.as_deref()
  136         -
    }
  137         -
}
  138         -
impl ValidationException {
  139         -
    /// Returns the error message.
  140         -
    pub fn message(&self) -> &str {
  141         -
        &self.message
  142         -
    }
  143         -
    #[doc(hidden)]
  144         -
    /// Returns the error name.
  145         -
    pub fn name(&self) -> &'static str {
  146         -
        "ValidationException"
  147         -
    }
  148         -
}
  149         -
impl ::std::fmt::Display for ValidationException {
  150         -
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  151         -
        ::std::write!(f, "ValidationException")?;
  152         -
        {
  153         -
            ::std::write!(f, ": {}", &self.message)?;
  154         -
        }
  155         -
        Ok(())
  156         -
    }
  157         -
}
  158         -
impl ::std::error::Error for ValidationException {}
  159         -
impl ValidationException {
  160         -
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
  161         -
    pub fn builder() -> crate::error::validation_exception::Builder {
  162         -
        crate::error::validation_exception::Builder::default()
  163         -
    }
  164         -
}
  165         -
  166         -
/// Error type for the `MalformedContentTypeWithBody2` operation.
  167         -
/// Each variant represents an error that can occur for the `MalformedContentTypeWithBody2` operation.
  168         -
#[derive(::std::fmt::Debug)]
  169         -
pub enum MalformedContentTypeWithBody2Error {
  170         -
    #[allow(missing_docs)] // documentation missing in model
  171         -
    ExtraError(crate::error::ExtraError),
  172         -
}
  173         -
impl ::std::fmt::Display for MalformedContentTypeWithBody2Error {
  174         -
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  175         -
        match &self {
  176         -
            MalformedContentTypeWithBody2Error::ExtraError(_inner) => _inner.fmt(f),
  177         -
        }
  178         -
    }
  179         -
}
  180         -
impl MalformedContentTypeWithBody2Error {
  181         -
    /// Returns `true` if the error kind is `MalformedContentTypeWithBody2Error::ExtraError`.
  182         -
    pub fn is_extra_error(&self) -> bool {
  183         -
        matches!(&self, MalformedContentTypeWithBody2Error::ExtraError(_))
  184         -
    }
  185         -
    /// Returns the error name string by matching the correct variant.
  186         -
    pub fn name(&self) -> &'static str {
  187         -
        match &self {
  188         -
            MalformedContentTypeWithBody2Error::ExtraError(_inner) => _inner.name(),
  189         -
        }
  190         -
    }
  191         -
}
  192         -
impl ::std::error::Error for MalformedContentTypeWithBody2Error {
  193         -
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
  194         -
        match &self {
  195         -
            MalformedContentTypeWithBody2Error::ExtraError(_inner) => Some(_inner),
  196         -
        }
  197         -
    }
  198         -
}
  199         -
impl ::std::convert::From<crate::error::ExtraError>
  200         -
    for crate::error::MalformedContentTypeWithBody2Error
  201         -
{
  202         -
    fn from(variant: crate::error::ExtraError) -> crate::error::MalformedContentTypeWithBody2Error {
  203         -
        Self::ExtraError(variant)
  204         -
    }
  205         -
}
  206         -
  207         -
/// Error type for the `HttpPayloadTraits2` operation.
  208         -
/// Each variant represents an error that can occur for the `HttpPayloadTraits2` operation.
  209         -
#[derive(::std::fmt::Debug)]
  210         -
pub enum HttpPayloadTraits2Error {
  211         -
    #[allow(missing_docs)] // documentation missing in model
  212         -
    ExtraError(crate::error::ExtraError),
  213         -
}
  214         -
impl ::std::fmt::Display for HttpPayloadTraits2Error {
  215         -
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  216         -
        match &self {
  217         -
            HttpPayloadTraits2Error::ExtraError(_inner) => _inner.fmt(f),
  218         -
        }
  219         -
    }
  220         -
}
  221         -
impl HttpPayloadTraits2Error {
  222         -
    /// Returns `true` if the error kind is `HttpPayloadTraits2Error::ExtraError`.
  223         -
    pub fn is_extra_error(&self) -> bool {
  224         -
        matches!(&self, HttpPayloadTraits2Error::ExtraError(_))
  225         -
    }
  226         -
    /// Returns the error name string by matching the correct variant.
  227         -
    pub fn name(&self) -> &'static str {
  228         -
        match &self {
  229         -
            HttpPayloadTraits2Error::ExtraError(_inner) => _inner.name(),
  230         -
        }
  231         -
    }
  232         -
}
  233         -
impl ::std::error::Error for HttpPayloadTraits2Error {
  234         -
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
  235         -
        match &self {
  236         -
            HttpPayloadTraits2Error::ExtraError(_inner) => Some(_inner),
  237         -
        }
  238         -
    }
  239         -
}
  240         -
impl ::std::convert::From<crate::error::ExtraError> for crate::error::HttpPayloadTraits2Error {
  241         -
    fn from(variant: crate::error::ExtraError) -> crate::error::HttpPayloadTraits2Error {
  242         -
        Self::ExtraError(variant)
  243         -
    }
  244         -
}
  245         -
  246     28   
/// Error type for the `QueryPrecedence` operation.
  247     29   
/// Each variant represents an error that can occur for the `QueryPrecedence` operation.
  248     30   
#[derive(::std::fmt::Debug)]
  249     31   
pub enum QueryPrecedenceError {
  250     32   
    #[allow(missing_docs)] // documentation missing in model
  251     33   
    ExtraError(crate::error::ExtraError),
  252     34   
}
  253     35   
impl ::std::fmt::Display for QueryPrecedenceError {
  254     36   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  255     37   
        match &self {
@@ -492,274 +551,377 @@
  512    294   
    fn from(variant: crate::error::ValidationException) -> crate::error::EscapedStringValuesError {
  513    295   
        Self::ValidationException(variant)
  514    296   
    }
  515    297   
}
  516    298   
impl ::std::convert::From<crate::error::ExtraError> for crate::error::EscapedStringValuesError {
  517    299   
    fn from(variant: crate::error::ExtraError) -> crate::error::EscapedStringValuesError {
  518    300   
        Self::ExtraError(variant)
  519    301   
    }
  520    302   
}
  521    303   
         304  +
/// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
         305  +
#[derive(
         306  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         307  +
)]
         308  +
pub struct ValidationException {
         309  +
    /// A summary of the validation failure.
         310  +
    pub message: ::std::string::String,
         311  +
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         312  +
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         313  +
}
         314  +
impl ValidationException {
         315  +
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         316  +
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
         317  +
        self.field_list.as_deref()
         318  +
    }
         319  +
}
         320  +
impl ValidationException {
         321  +
    /// Returns the error message.
         322  +
    pub fn message(&self) -> &str {
         323  +
        &self.message
         324  +
    }
         325  +
    #[doc(hidden)]
         326  +
    /// Returns the error name.
         327  +
    pub fn name(&self) -> &'static str {
         328  +
        "ValidationException"
         329  +
    }
         330  +
}
         331  +
impl ::std::fmt::Display for ValidationException {
         332  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         333  +
        ::std::write!(f, "ValidationException")?;
         334  +
        {
         335  +
            ::std::write!(f, ": {}", &self.message)?;
         336  +
        }
         337  +
        Ok(())
         338  +
    }
         339  +
}
         340  +
impl ::std::error::Error for ValidationException {}
         341  +
impl ValidationException {
         342  +
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
         343  +
    pub fn builder() -> crate::error::validation_exception::Builder {
         344  +
        crate::error::validation_exception::Builder::default()
         345  +
    }
         346  +
}
         347  +
  522    348   
/// Error type for the `PrimitiveIntOp` operation.
  523    349   
/// Each variant represents an error that can occur for the `PrimitiveIntOp` operation.
  524    350   
#[derive(::std::fmt::Debug)]
  525    351   
pub enum PrimitiveIntOpError {
  526    352   
    #[allow(missing_docs)] // documentation missing in model
  527    353   
    ExtraError(crate::error::ExtraError),
  528    354   
}
  529    355   
impl ::std::fmt::Display for PrimitiveIntOpError {
  530    356   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  531    357   
        match &self {
@@ -793,619 +852,709 @@
  813    639   
    impl Builder {
  814    640   
        /// Consumes the builder and constructs a [`ExtraError`](crate::error::ExtraError).
  815    641   
        pub fn build(self) -> crate::error::ExtraError {
  816    642   
            self.build_enforcing_all_constraints()
  817    643   
        }
  818    644   
        fn build_enforcing_all_constraints(self) -> crate::error::ExtraError {
  819    645   
            crate::error::ExtraError {}
  820    646   
        }
  821    647   
    }
  822    648   
}
         649  +
/// See [`CaseInsensitiveError`](crate::error::CaseInsensitiveError).
         650  +
///
         651  +
pub mod case_insensitive_error {
         652  +
         653  +
    impl ::std::convert::From<Builder> for crate::error::CaseInsensitiveError {
         654  +
        fn from(builder: Builder) -> Self {
         655  +
            builder.build()
         656  +
        }
         657  +
    }
         658  +
    /// A builder for [`CaseInsensitiveError`](crate::error::CaseInsensitiveError).
         659  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         660  +
    pub struct Builder {
         661  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         662  +
    }
         663  +
    impl Builder {
         664  +
        #[allow(missing_docs)] // documentation missing in model
         665  +
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         666  +
            self.message = input;
         667  +
            self
         668  +
        }
         669  +
        /// Consumes the builder and constructs a [`CaseInsensitiveError`](crate::error::CaseInsensitiveError).
         670  +
        pub fn build(self) -> crate::error::CaseInsensitiveError {
         671  +
            self.build_enforcing_all_constraints()
         672  +
        }
         673  +
        fn build_enforcing_all_constraints(self) -> crate::error::CaseInsensitiveError {
         674  +
            crate::error::CaseInsensitiveError {
         675  +
                message: self.message,
         676  +
            }
         677  +
        }
         678  +
    }
         679  +
}
  823    680   
/// See [`ValidationException`](crate::error::ValidationException).
  824    681   
///
  825    682   
pub mod validation_exception {
  826    683   
  827    684   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  828    685   
    /// Holds one variant for each of the ways the builder can fail.
  829    686   
    #[non_exhaustive]
  830    687   
    #[allow(clippy::enum_variant_names)]
  831    688   
    pub enum ConstraintViolation {
  832    689   
        /// `message` was not provided but it is required when building `ValidationException`.
@@ -858,715 +918,0 @@
  878    735   
        fn build_enforcing_all_constraints(
  879    736   
            self,
  880    737   
        ) -> Result<crate::error::ValidationException, ConstraintViolation> {
  881    738   
            Ok(crate::error::ValidationException {
  882    739   
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  883    740   
                field_list: self.field_list,
  884    741   
            })
  885    742   
        }
  886    743   
    }
  887    744   
}
  888         -
/// See [`CaseInsensitiveError`](crate::error::CaseInsensitiveError).
  889         -
///
  890         -
pub mod case_insensitive_error {
  891         -
  892         -
    impl ::std::convert::From<Builder> for crate::error::CaseInsensitiveError {
  893         -
        fn from(builder: Builder) -> Self {
  894         -
            builder.build()
  895         -
        }
  896         -
    }
  897         -
    /// A builder for [`CaseInsensitiveError`](crate::error::CaseInsensitiveError).
  898         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  899         -
    pub struct Builder {
  900         -
        pub(crate) message: ::std::option::Option<::std::string::String>,
  901         -
    }
  902         -
    impl Builder {
  903         -
        #[allow(missing_docs)] // documentation missing in model
  904         -
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
  905         -
            self.message = input;
  906         -
            self
  907         -
        }
  908         -
        /// Consumes the builder and constructs a [`CaseInsensitiveError`](crate::error::CaseInsensitiveError).
  909         -
        pub fn build(self) -> crate::error::CaseInsensitiveError {
  910         -
            self.build_enforcing_all_constraints()
  911         -
        }
  912         -
        fn build_enforcing_all_constraints(self) -> crate::error::CaseInsensitiveError {
  913         -
            crate::error::CaseInsensitiveError {
  914         -
                message: self.message,
  915         -
            }
  916         -
        }
  917         -
    }
  918         -
}

tmp-codegen-diff/codegen-server-test/rest_json_extras/rust-server-codegen/src/input.rs

@@ -1,1 +133,31 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
#[allow(missing_docs)] // documentation missing in model
    3         -
#[derive(
    4         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    5         -
)]
    6         -
pub struct HttpStringPayload2Input {
    7         -
    #[allow(missing_docs)] // documentation missing in model
    8         -
    pub payload: ::std::option::Option<::std::string::String>,
    9         -
}
   10         -
impl HttpStringPayload2Input {
   11         -
    #[allow(missing_docs)] // documentation missing in model
   12         -
    pub fn payload(&self) -> ::std::option::Option<&str> {
   13         -
        self.payload.as_deref()
   14         -
    }
   15         -
}
   16         -
impl HttpStringPayload2Input {
   17         -
    /// Creates a new builder-style object to manufacture [`HttpStringPayload2Input`](crate::input::HttpStringPayload2Input).
   18         -
    pub fn builder() -> crate::input::http_string_payload2_input::Builder {
   19         -
        crate::input::http_string_payload2_input::Builder::default()
   20         -
    }
   21         -
}
   22         -
impl crate::constrained::Constrained for crate::input::HttpStringPayload2Input {
   23         -
    type Unconstrained = crate::input::http_string_payload2_input::Builder;
   24         -
}
   25         -
   26         -
#[allow(missing_docs)] // documentation missing in model
   27         -
#[derive(
   28         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   29         -
)]
   30         -
pub struct HttpEnumPayload2Input {
   31         -
    #[allow(missing_docs)] // documentation missing in model
   32         -
    pub payload: ::std::option::Option<crate::model::StringEnum>,
   33         -
}
   34         -
impl HttpEnumPayload2Input {
   35         -
    #[allow(missing_docs)] // documentation missing in model
   36         -
    pub fn payload(&self) -> ::std::option::Option<&crate::model::StringEnum> {
   37         -
        self.payload.as_ref()
   38         -
    }
   39         -
}
   40         -
impl HttpEnumPayload2Input {
   41         -
    /// Creates a new builder-style object to manufacture [`HttpEnumPayload2Input`](crate::input::HttpEnumPayload2Input).
   42         -
    pub fn builder() -> crate::input::http_enum_payload2_input::Builder {
   43         -
        crate::input::http_enum_payload2_input::Builder::default()
   44         -
    }
   45         -
}
   46         -
impl crate::constrained::Constrained for crate::input::HttpEnumPayload2Input {
   47         -
    type Unconstrained = crate::input::http_enum_payload2_input::Builder;
   48         -
}
   49         -
   50         -
#[allow(missing_docs)] // documentation missing in model
   51         -
#[derive(
   52         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   53         -
)]
   54         -
pub struct MalformedContentTypeWithBody2Input {
   55         -
    #[allow(missing_docs)] // documentation missing in model
   56         -
    pub salutation: ::std::option::Option<::std::string::String>,
   57         -
}
   58         -
impl MalformedContentTypeWithBody2Input {
   59         -
    #[allow(missing_docs)] // documentation missing in model
   60         -
    pub fn salutation(&self) -> ::std::option::Option<&str> {
   61         -
        self.salutation.as_deref()
   62         -
    }
   63         -
}
   64         -
impl MalformedContentTypeWithBody2Input {
   65         -
    /// Creates a new builder-style object to manufacture [`MalformedContentTypeWithBody2Input`](crate::input::MalformedContentTypeWithBody2Input).
   66         -
    pub fn builder() -> crate::input::malformed_content_type_with_body2_input::Builder {
   67         -
        crate::input::malformed_content_type_with_body2_input::Builder::default()
   68         -
    }
   69         -
}
   70         -
impl crate::constrained::Constrained for crate::input::MalformedContentTypeWithBody2Input {
   71         -
    type Unconstrained = crate::input::malformed_content_type_with_body2_input::Builder;
   72         -
}
   73         -
   74         -
#[allow(missing_docs)] // documentation missing in model
   75         -
#[derive(
   76         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   77         -
)]
   78         -
pub struct HttpPayloadTraits2Input {
   79         -
    #[allow(missing_docs)] // documentation missing in model
   80         -
    pub foo: ::std::option::Option<::std::string::String>,
   81         -
    #[allow(missing_docs)] // documentation missing in model
   82         -
    pub blob: ::std::option::Option<::aws_smithy_types::Blob>,
   83         -
}
   84         -
impl HttpPayloadTraits2Input {
   85         -
    #[allow(missing_docs)] // documentation missing in model
   86         -
    pub fn foo(&self) -> ::std::option::Option<&str> {
   87         -
        self.foo.as_deref()
   88         -
    }
   89         -
    #[allow(missing_docs)] // documentation missing in model
   90         -
    pub fn blob(&self) -> ::std::option::Option<&::aws_smithy_types::Blob> {
   91         -
        self.blob.as_ref()
   92         -
    }
   93         -
}
   94         -
impl HttpPayloadTraits2Input {
   95         -
    /// Creates a new builder-style object to manufacture [`HttpPayloadTraits2Input`](crate::input::HttpPayloadTraits2Input).
   96         -
    pub fn builder() -> crate::input::http_payload_traits2_input::Builder {
   97         -
        crate::input::http_payload_traits2_input::Builder::default()
   98         -
    }
   99         -
}
  100         -
impl crate::constrained::Constrained for crate::input::HttpPayloadTraits2Input {
  101         -
    type Unconstrained = crate::input::http_payload_traits2_input::Builder;
  102         -
}
  103         -
  104      2   
#[allow(missing_docs)] // documentation missing in model
  105      3   
#[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
  106      4   
pub struct QueryPrecedenceInput {
  107      5   
    #[allow(missing_docs)] // documentation missing in model
  108      6   
    pub foo: ::std::option::Option<::std::string::String>,
  109      7   
    #[allow(missing_docs)] // documentation missing in model
  110      8   
    pub baz: ::std::option::Option<
  111      9   
        ::std::collections::HashMap<::std::string::String, ::std::string::String>,
  112     10   
    >,
  113     11   
}
@@ -312,210 +621,269 @@
  332    230   
}
  333    231   
impl StringPayloadInput {
  334    232   
    /// Creates a new builder-style object to manufacture [`StringPayloadInput`](crate::input::StringPayloadInput).
  335    233   
    pub fn builder() -> crate::input::string_payload_input::Builder {
  336    234   
        crate::input::string_payload_input::Builder::default()
  337    235   
    }
  338    236   
}
  339    237   
impl crate::constrained::Constrained for crate::input::StringPayloadInput {
  340    238   
    type Unconstrained = crate::input::string_payload_input::Builder;
  341    239   
}
  342         -
/// See [`HttpStringPayload2Input`](crate::input::HttpStringPayload2Input).
  343         -
///
  344         -
pub mod http_string_payload2_input {
  345         -
  346         -
    impl ::std::convert::From<Builder> for crate::input::HttpStringPayload2Input {
  347         -
        fn from(builder: Builder) -> Self {
  348         -
            builder.build()
  349         -
        }
  350         -
    }
  351         -
    /// A builder for [`HttpStringPayload2Input`](crate::input::HttpStringPayload2Input).
  352         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  353         -
    pub struct Builder {
  354         -
        pub(crate) payload: ::std::option::Option<::std::string::String>,
  355         -
    }
  356         -
    impl Builder {
  357         -
        #[allow(missing_docs)] // documentation missing in model
  358         -
        pub fn payload(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
  359         -
            self.payload = input;
  360         -
            self
  361         -
        }
  362         -
        #[allow(missing_docs)] // documentation missing in model
  363         -
        pub(crate) fn set_payload(
  364         -
            mut self,
  365         -
            input: Option<impl ::std::convert::Into<::std::string::String>>,
  366         -
        ) -> Self {
  367         -
            self.payload = input.map(|v| v.into());
  368         -
            self
  369         -
        }
  370         -
        /// Consumes the builder and constructs a [`HttpStringPayload2Input`](crate::input::HttpStringPayload2Input).
  371         -
        pub fn build(self) -> crate::input::HttpStringPayload2Input {
  372         -
            self.build_enforcing_all_constraints()
  373         -
        }
  374         -
        fn build_enforcing_all_constraints(self) -> crate::input::HttpStringPayload2Input {
  375         -
            crate::input::HttpStringPayload2Input {
  376         -
                payload: self.payload,
  377         -
            }
  378         -
        }
  379         -
    }
  380         -
}
  381         -
/// See [`HttpEnumPayload2Input`](crate::input::HttpEnumPayload2Input).
  382         -
///
  383         -
pub mod http_enum_payload2_input {
  384         -
  385         -
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  386         -
    /// Holds one variant for each of the ways the builder can fail.
  387         -
    #[non_exhaustive]
  388         -
    #[allow(clippy::enum_variant_names)]
  389         -
    pub enum ConstraintViolation {
  390         -
        /// Constraint violation occurred building member `payload` when building `HttpEnumPayload2Input`.
  391         -
        #[doc(hidden)]
  392         -
        Payload(crate::model::string_enum::ConstraintViolation),
  393         -
    }
  394         -
    impl ::std::fmt::Display for ConstraintViolation {
  395         -
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  396         -
            match self {
  397         -
                ConstraintViolation::Payload(_) => write!(f, "constraint violation occurred building member `payload` when building `HttpEnumPayload2Input`"),
  398         -
            }
  399         -
        }
  400         -
    }
  401         -
    impl ::std::error::Error for ConstraintViolation {}
  402         -
    impl ConstraintViolation {
  403         -
        pub(crate) fn as_validation_exception_field(
  404         -
            self,
  405         -
            path: ::std::string::String,
  406         -
        ) -> crate::model::ValidationExceptionField {
  407         -
            match self {
  408         -
                ConstraintViolation::Payload(inner) => {
  409         -
                    inner.as_validation_exception_field(path + "/payload")
  410         -
                }
  411         -
            }
  412         -
        }
  413         -
    }
  414         -
    impl ::std::convert::From<ConstraintViolation>
  415         -
        for ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection
  416         -
    {
  417         -
        fn from(constraint_violation: ConstraintViolation) -> Self {
  418         -
            let first_validation_exception_field =
  419         -
                constraint_violation.as_validation_exception_field("".to_owned());
  420         -
            let validation_exception = crate::error::ValidationException {
  421         -
                message: format!(
  422         -
                    "1 validation error detected. {}",
  423         -
                    &first_validation_exception_field.message
  424         -
                ),
  425         -
                field_list: Some(vec![first_validation_exception_field]),
  426         -
            };
  427         -
            Self::ConstraintViolation(
  428         -
                                crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(&validation_exception)
  429         -
                                    .expect("validation exceptions should never fail to serialize; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues")
  430         -
                            )
  431         -
        }
  432         -
    }
  433         -
    impl ::std::convert::From<Builder>
  434         -
        for crate::constrained::MaybeConstrained<crate::input::HttpEnumPayload2Input>
  435         -
    {
  436         -
        fn from(builder: Builder) -> Self {
  437         -
            Self::Unconstrained(builder)
  438         -
        }
  439         -
    }
  440         -
    impl ::std::convert::TryFrom<Builder> for crate::input::HttpEnumPayload2Input {
  441         -
        type Error = ConstraintViolation;
  442         -
  443         -
        fn try_from(builder: Builder) -> Result<Self, Self::Error> {
  444         -
            builder.build()
  445         -
        }
  446         -
    }
  447         -
    /// A builder for [`HttpEnumPayload2Input`](crate::input::HttpEnumPayload2Input).
  448         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  449         -
    pub struct Builder {
  450         -
        pub(crate) payload:
  451         -
            ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::StringEnum>>,
  452         -
    }
  453         -
    impl Builder {
  454         -
        #[allow(missing_docs)] // documentation missing in model
  455         -
        pub fn payload(mut self, input: ::std::option::Option<crate::model::StringEnum>) -> Self {
  456         -
            self.payload = input.map(
  457         -
                #[allow(clippy::redundant_closure)]
  458         -
                |v| crate::constrained::MaybeConstrained::Constrained(v),
  459         -
            );
  460         -
            self
  461         -
        }
  462         -
        #[allow(missing_docs)] // documentation missing in model
  463         -
        pub(crate) fn set_payload(
  464         -
            mut self,
  465         -
            input: Option<
  466         -
                impl ::std::convert::Into<
  467         -
                    crate::constrained::MaybeConstrained<crate::model::StringEnum>,
  468         -
                >,
  469         -
            >,
  470         -
        ) -> Self {
  471         -
            self.payload = input.map(|v| v.into());
  472         -
            self
  473         -
        }
  474         -
        /// Consumes the builder and constructs a [`HttpEnumPayload2Input`](crate::input::HttpEnumPayload2Input).
  475         -
        ///
  476         -
        /// The builder fails to construct a [`HttpEnumPayload2Input`](crate::input::HttpEnumPayload2Input) if a [`ConstraintViolation`] occurs.
  477         -
        ///
  478         -
        pub fn build(self) -> Result<crate::input::HttpEnumPayload2Input, ConstraintViolation> {
  479         -
            self.build_enforcing_all_constraints()
  480         -
        }
  481         -
        fn build_enforcing_all_constraints(
  482         -
            self,
  483         -
        ) -> Result<crate::input::HttpEnumPayload2Input, ConstraintViolation> {
  484         -
            Ok(crate::input::HttpEnumPayload2Input {
  485         -
                payload: self
  486         -
                    .payload
  487         -
                    .map(|v| match v {
  488         -
                        crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
  489         -
                        crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
  490         -
                    })
  491         -
                    .map(|res| res.map_err(ConstraintViolation::Payload))
  492         -
                    .transpose()?,
  493         -
            })
  494         -
        }
  495         -
    }
  496         -
}
  497         -
/// See [`MalformedContentTypeWithBody2Input`](crate::input::MalformedContentTypeWithBody2Input).
  498         -
///
  499         -
pub mod malformed_content_type_with_body2_input {
  500         -
  501         -
    impl ::std::convert::From<Builder> for crate::input::MalformedContentTypeWithBody2Input {
  502         -
        fn from(builder: Builder) -> Self {
  503         -
            builder.build()
  504         -
        }
  505         -
    }
  506         -
    /// A builder for [`MalformedContentTypeWithBody2Input`](crate::input::MalformedContentTypeWithBody2Input).
  507         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  508         -
    pub struct Builder {
  509         -
        pub(crate) salutation: ::std::option::Option<::std::string::String>,
  510         -
    }
  511         -
    impl Builder {
  512         -
        #[allow(missing_docs)] // documentation missing in model
  513         -
        pub fn salutation(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
  514         -
            self.salutation = input;
  515         -
            self
  516         -
        }
  517         -
        #[allow(missing_docs)] // documentation missing in model
  518         -
        pub(crate) fn set_salutation(
  519         -
            mut self,
  520         -
            input: Option<impl ::std::convert::Into<::std::string::String>>,
  521         -
        ) -> Self {
  522         -
            self.salutation = input.map(|v| v.into());
  523         -
            self
  524         -
        }
  525         -
        /// Consumes the builder and constructs a [`MalformedContentTypeWithBody2Input`](crate::input::MalformedContentTypeWithBody2Input).
  526         -
        pub fn build(self) -> crate::input::MalformedContentTypeWithBody2Input {
  527         -
            self.build_enforcing_all_constraints()
  528         -
        }
  529         -
        fn build_enforcing_all_constraints(
  530         -
            self,
  531         -
        ) -> crate::input::MalformedContentTypeWithBody2Input {
  532         -
            crate::input::MalformedContentTypeWithBody2Input {
  533         -
                salutation: self.salutation,
  534         -
            }
  535         -
        }
  536         -
    }
  537         -
}
  538         -
/// See [`HttpPayloadTraits2Input`](crate::input::HttpPayloadTraits2Input).
  539         -
///
  540         -
pub mod http_payload_traits2_input {
  541         -
  542         -
    impl ::std::convert::From<Builder> for crate::input::HttpPayloadTraits2Input {
  543         -
        fn from(builder: Builder) -> Self {
  544         -
            builder.build()
  545         -
        }
  546         -
    }
  547         -
    /// A builder for [`HttpPayloadTraits2Input`](crate::input::HttpPayloadTraits2Input).
  548         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  549         -
    pub struct Builder {
  550         -
        pub(crate) foo: ::std::option::Option<::std::string::String>,
  551         -
        pub(crate) blob: ::std::option::Option<::aws_smithy_types::Blob>,
  552         -
    }
  553         -
    impl Builder {
  554         -
        #[allow(missing_docs)] // documentation missing in model
  555         -
        pub fn foo(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
  556         -
            self.foo = input;
  557         -
            self
  558         -
        }
  559         -
        #[allow(missing_docs)] // documentation missing in model
  560         -
        pub(crate) fn set_foo(
  561         -
            mut self,
  562         -
            input: Option<impl ::std::convert::Into<::std::string::String>>,
  563         -
        ) -> Self {
  564         -
            self.foo = input.map(|v| v.into());
  565         -
            self
  566         -
        }
  567         -
        #[allow(missing_docs)] // documentation missing in model
  568         -
        pub fn blob(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
  569         -
            self.blob = input;
  570         -
            self
  571         -
        }
  572         -
        #[allow(missing_docs)] // documentation missing in model
  573         -
        pub(crate) fn set_blob(
  574         -
            mut self,
  575         -
            input: Option<impl ::std::convert::Into<::aws_smithy_types::Blob>>,
  576         -
        ) -> Self {
  577         -
            self.blob = input.map(|v| v.into());
  578         -
            self
  579         -
        }
  580         -
        /// Consumes the builder and constructs a [`HttpPayloadTraits2Input`](crate::input::HttpPayloadTraits2Input).
  581         -
        pub fn build(self) -> crate::input::HttpPayloadTraits2Input {
  582         -
            self.build_enforcing_all_constraints()
  583         -
        }
  584         -
        fn build_enforcing_all_constraints(self) -> crate::input::HttpPayloadTraits2Input {
  585         -
            crate::input::HttpPayloadTraits2Input {
  586         -
                foo: self.foo,
  587         -
                blob: self.blob,
  588         -
            }
  589         -
        }
  590         -
    }
  591         -
}
  592    240   
/// See [`QueryPrecedenceInput`](crate::input::QueryPrecedenceInput).
  593    241   
///
  594    242   
pub mod query_precedence_input {
  595    243   
  596    244   
    impl ::std::convert::From<Builder> for crate::input::QueryPrecedenceInput {
  597    245   
        fn from(builder: Builder) -> Self {
  598    246   
            builder.build()
  599    247   
        }
  600    248   
    }
  601    249   
    /// A builder for [`QueryPrecedenceInput`](crate::input::QueryPrecedenceInput).

tmp-codegen-diff/codegen-server-test/rest_json_extras/rust-server-codegen/src/lib.rs

@@ -134,134 +252,232 @@
  154    154   
//! use rest_json_extras::{RestJsonExtras, RestJsonExtrasConfig};
  155    155   
//!
  156    156   
//! #[::tokio::main]
  157    157   
//! pub async fn main() {
  158    158   
//!    let config = RestJsonExtrasConfig::builder().build();
  159    159   
//!    let app = RestJsonExtras::builder(config)
  160    160   
//!        .case_insensitive_error_operation(case_insensitive_error_operation)
  161    161   
//!        .empty_struct_with_content_on_wire_op(empty_struct_with_content_on_wire_op)
  162    162   
//!        .enum_query(enum_query)
  163    163   
//!        .escaped_string_values(escaped_string_values)
  164         -
//!        .http_enum_payload2(http_enum_payload2)
  165         -
//!        .http_payload_traits2(http_payload_traits2)
  166         -
//!        .http_string_payload2(http_string_payload2)
  167         -
//!        .malformed_content_type_with_body2(malformed_content_type_with_body2)
  168    164   
//!        .map_with_enum_key_op(map_with_enum_key_op)
  169    165   
//!        .null_in_non_sparse(null_in_non_sparse)
  170    166   
//!        .primitive_int_header(primitive_int_header)
  171    167   
//!        .primitive_int_op(primitive_int_op)
  172    168   
//!        .query_precedence(query_precedence)
  173    169   
//!        .status_response(status_response)
  174    170   
//!        .string_payload(string_payload)
  175    171   
//!        .build()
  176    172   
//!        .expect("failed to build an instance of RestJsonExtras");
  177    173   
//!
  178    174   
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
  179    175   
//!        .expect("unable to parse the server bind address and port");
  180    176   
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
  181    177   
//!    # let server = async { Ok::<_, ()>(()) };
  182    178   
//!
  183    179   
//!    // Run your service!
  184    180   
//!    if let Err(err) = server.await {
  185    181   
//!        eprintln!("server error: {:?}", err);
  186    182   
//!    }
  187    183   
//! }
  188    184   
//!
  189    185   
//! use rest_json_extras::{input, output, error};
  190    186   
//!
  191    187   
//! async fn case_insensitive_error_operation(input: input::CaseInsensitiveErrorOperationInput) -> Result<output::CaseInsensitiveErrorOperationOutput, error::CaseInsensitiveErrorOperationError> {
  192    188   
//!     todo!()
  193    189   
//! }
  194    190   
//!
  195    191   
//! async fn empty_struct_with_content_on_wire_op(input: input::EmptyStructWithContentOnWireOpInput) -> Result<output::EmptyStructWithContentOnWireOpOutput, error::EmptyStructWithContentOnWireOpError> {
  196    192   
//!     todo!()
  197    193   
//! }
  198    194   
//!
  199    195   
//! async fn enum_query(input: input::EnumQueryInput) -> Result<output::EnumQueryOutput, error::EnumQueryError> {
  200    196   
//!     todo!()
  201    197   
//! }
  202    198   
//!
  203    199   
//! async fn escaped_string_values(input: input::EscapedStringValuesInput) -> Result<output::EscapedStringValuesOutput, error::EscapedStringValuesError> {
  204    200   
//!     todo!()
  205    201   
//! }
  206    202   
//!
  207         -
//! async fn http_enum_payload2(input: input::HttpEnumPayload2Input) -> Result<output::HttpEnumPayload2Output, error::HttpEnumPayload2Error> {
  208         -
//!     todo!()
  209         -
//! }
  210         -
//!
  211         -
//! async fn http_payload_traits2(input: input::HttpPayloadTraits2Input) -> Result<output::HttpPayloadTraits2Output, error::HttpPayloadTraits2Error> {
  212         -
//!     todo!()
  213         -
//! }
  214         -
//!
  215         -
//! async fn http_string_payload2(input: input::HttpStringPayload2Input) -> Result<output::HttpStringPayload2Output, error::HttpStringPayload2Error> {
  216         -
//!     todo!()
  217         -
//! }
  218         -
//!
  219         -
//! async fn malformed_content_type_with_body2(input: input::MalformedContentTypeWithBody2Input) -> Result<output::MalformedContentTypeWithBody2Output, error::MalformedContentTypeWithBody2Error> {
  220         -
//!     todo!()
  221         -
//! }
  222         -
//!
  223    203   
//! async fn map_with_enum_key_op(input: input::MapWithEnumKeyOpInput) -> Result<output::MapWithEnumKeyOpOutput, error::MapWithEnumKeyOpError> {
  224    204   
//!     todo!()
  225    205   
//! }
  226    206   
//!
  227    207   
//! async fn null_in_non_sparse(input: input::NullInNonSparseInput) -> Result<output::NullInNonSparseOutput, error::NullInNonSparseError> {
  228    208   
//!     todo!()
  229    209   
//! }
  230    210   
//!
  231    211   
//! async fn primitive_int_header(input: input::PrimitiveIntHeaderInput) -> Result<output::PrimitiveIntHeaderOutput, error::PrimitiveIntHeaderError> {
  232    212   
//!     todo!()

tmp-codegen-diff/codegen-server-test/rest_json_extras/rust-server-codegen/src/model.rs

@@ -1,1 +302,322 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
#[derive(
           4  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
           5  +
)]
           6  +
pub struct EmptyStruct {}
           7  +
impl EmptyStruct {
           8  +
    /// Creates a new builder-style object to manufacture [`EmptyStruct`](crate::model::EmptyStruct).
           9  +
    pub fn builder() -> crate::model::empty_struct::Builder {
          10  +
        crate::model::empty_struct::Builder::default()
          11  +
    }
          12  +
}
          13  +
          14  +
#[allow(missing_docs)] // documentation missing in model
          15  +
#[derive(
          16  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          17  +
)]
          18  +
pub enum SingleElementUnion {
          19  +
    #[allow(missing_docs)] // documentation missing in model
          20  +
    A(::std::string::String),
          21  +
}
          22  +
impl SingleElementUnion {
          23  +
    #[allow(irrefutable_let_patterns)]
          24  +
    /// Tries to convert the enum instance into [`A`](crate::model::SingleElementUnion::A), extracting the inner [`String`](::std::string::String).
          25  +
    /// Returns `Err(&Self)` if it can't be converted.
          26  +
    pub fn as_a(&self) -> ::std::result::Result<&::std::string::String, &Self> {
          27  +
        if let SingleElementUnion::A(val) = &self {
          28  +
            ::std::result::Result::Ok(val)
          29  +
        } else {
          30  +
            ::std::result::Result::Err(self)
          31  +
        }
          32  +
    }
          33  +
    /// Returns true if this is a [`A`](crate::model::SingleElementUnion::A).
          34  +
    pub fn is_a(&self) -> bool {
          35  +
        self.as_a().is_ok()
          36  +
    }
          37  +
}
    2     38   
    3     39   
/// Describes one specific validation failure for an input member.
    4     40   
#[derive(
    5     41   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    6     42   
)]
    7     43   
pub struct ValidationExceptionField {
    8     44   
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
    9     45   
    pub path: ::std::string::String,
   10     46   
    /// A detailed description of the validation failure.
   11     47   
    pub message: ::std::string::String,
   12     48   
}
   13     49   
impl ValidationExceptionField {
   14     50   
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
   15     51   
    pub fn path(&self) -> &str {
   16     52   
        use std::ops::Deref;
   17     53   
        self.path.deref()
   18     54   
    }
   19     55   
    /// A detailed description of the validation failure.
   20     56   
    pub fn message(&self) -> &str {
   21     57   
        use std::ops::Deref;
   22     58   
        self.message.deref()
   23     59   
    }
   24     60   
}
   25     61   
impl ValidationExceptionField {
   26     62   
    /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
   27     63   
    pub fn builder() -> crate::model::validation_exception_field::Builder {
   28     64   
        crate::model::validation_exception_field::Builder::default()
   29     65   
    }
   30     66   
}
   31     67   
   32     68   
#[allow(missing_docs)] // documentation missing in model
   33     69   
#[derive(
   34     70   
    ::std::clone::Clone,
   35     71   
    ::std::cmp::Eq,
   36     72   
    ::std::cmp::Ord,
   37     73   
    ::std::cmp::PartialEq,
   38     74   
    ::std::cmp::PartialOrd,
   39     75   
    ::std::fmt::Debug,
   40     76   
    ::std::hash::Hash,
   41     77   
)]
   42         -
pub enum StringEnum {
          78  +
pub enum EnumWithEscapedChars {
          79  +
    /// this needs#tobe escaped
          80  +
    HasQuotes,
   43     81   
    #[allow(missing_docs)] // documentation missing in model
   44         -
    V,
          82  +
    Normal,
   45     83   
}
   46         -
/// See [`StringEnum`](crate::model::StringEnum).
   47         -
pub mod string_enum {
          84  +
/// See [`EnumWithEscapedChars`](crate::model::EnumWithEscapedChars).
          85  +
pub mod enum_with_escaped_chars {
   48     86   
    #[derive(Debug, PartialEq)]
   49     87   
    pub struct ConstraintViolation(pub(crate) ::std::string::String);
   50     88   
   51     89   
    impl ::std::fmt::Display for ConstraintViolation {
   52     90   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
   53     91   
            write!(
   54     92   
                f,
   55         -
                r#"Value provided for 'aws.protocoltests.restjson#StringEnum' failed to satisfy constraint: Member must satisfy enum value set: [enumvalue]"#
          93  +
                r#"Value provided for 'aws.protocoltests.restjson#EnumWithEscapedChars' failed to satisfy constraint: Member must satisfy enum value set: [has"quotes, normal]"#
   56     94   
            )
   57     95   
        }
   58     96   
    }
   59     97   
   60     98   
    impl ::std::error::Error for ConstraintViolation {}
   61     99   
    impl ConstraintViolation {
   62    100   
        pub(crate) fn as_validation_exception_field(
   63    101   
            self,
   64    102   
            path: ::std::string::String,
   65    103   
        ) -> crate::model::ValidationExceptionField {
   66    104   
            crate::model::ValidationExceptionField {
   67    105   
                message: format!(
   68         -
                    r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [enumvalue]"#,
         106  +
                    r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [has"quotes, normal]"#,
   69    107   
                    &path
   70    108   
                ),
   71    109   
                path,
   72    110   
            }
   73    111   
        }
   74    112   
    }
   75    113   
}
   76         -
impl ::std::convert::TryFrom<&str> for StringEnum {
   77         -
    type Error = crate::model::string_enum::ConstraintViolation;
         114  +
impl ::std::convert::TryFrom<&str> for EnumWithEscapedChars {
         115  +
    type Error = crate::model::enum_with_escaped_chars::ConstraintViolation;
   78    116   
    fn try_from(
   79    117   
        s: &str,
   80    118   
    ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
   81    119   
        match s {
   82         -
            "enumvalue" => Ok(StringEnum::V),
   83         -
            _ => Err(crate::model::string_enum::ConstraintViolation(s.to_owned())),
         120  +
            "has\"quotes" => Ok(EnumWithEscapedChars::HasQuotes),
         121  +
            "normal" => Ok(EnumWithEscapedChars::Normal),
         122  +
            _ => Err(crate::model::enum_with_escaped_chars::ConstraintViolation(
         123  +
                s.to_owned(),
         124  +
            )),
   84    125   
        }
   85    126   
    }
   86    127   
}
   87         -
impl ::std::convert::TryFrom<::std::string::String> for StringEnum {
   88         -
    type Error = crate::model::string_enum::ConstraintViolation;
         128  +
impl ::std::convert::TryFrom<::std::string::String> for EnumWithEscapedChars {
         129  +
    type Error = crate::model::enum_with_escaped_chars::ConstraintViolation;
   89    130   
    fn try_from(
   90    131   
        s: ::std::string::String,
   91    132   
    ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
   92    133   
    {
   93    134   
        s.as_str().try_into()
   94    135   
    }
   95    136   
}
   96         -
impl std::str::FromStr for StringEnum {
   97         -
    type Err = crate::model::string_enum::ConstraintViolation;
         137  +
impl std::str::FromStr for EnumWithEscapedChars {
         138  +
    type Err = crate::model::enum_with_escaped_chars::ConstraintViolation;
   98    139   
    fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
   99    140   
        Self::try_from(s)
  100    141   
    }
  101    142   
}
  102         -
impl StringEnum {
         143  +
impl EnumWithEscapedChars {
  103    144   
    /// Returns the `&str` value of the enum member.
  104    145   
    pub fn as_str(&self) -> &str {
  105    146   
        match self {
  106         -
            StringEnum::V => "enumvalue",
         147  +
            EnumWithEscapedChars::HasQuotes => "has\"quotes",
         148  +
            EnumWithEscapedChars::Normal => "normal",
  107    149   
        }
  108    150   
    }
  109    151   
    /// Returns all the `&str` representations of the enum members.
  110    152   
    pub const fn values() -> &'static [&'static str] {
  111         -
        &["enumvalue"]
         153  +
        &["has\"quotes", "normal"]
  112    154   
    }
  113    155   
}
  114         -
impl ::std::convert::AsRef<str> for StringEnum {
         156  +
impl ::std::convert::AsRef<str> for EnumWithEscapedChars {
  115    157   
    fn as_ref(&self) -> &str {
  116    158   
        self.as_str()
  117    159   
    }
  118    160   
}
  119         -
impl crate::constrained::Constrained for StringEnum {
         161  +
impl crate::constrained::Constrained for EnumWithEscapedChars {
  120    162   
    type Unconstrained = ::std::string::String;
  121    163   
}
  122    164   
  123    165   
impl ::std::convert::From<::std::string::String>
  124         -
    for crate::constrained::MaybeConstrained<crate::model::StringEnum>
         166  +
    for crate::constrained::MaybeConstrained<crate::model::EnumWithEscapedChars>
  125    167   
{
  126    168   
    fn from(value: ::std::string::String) -> Self {
  127    169   
        Self::Unconstrained(value)
  128    170   
    }
  129    171   
}
  130    172   
  131         -
#[allow(missing_docs)] // documentation missing in model
  132         -
#[derive(
  133         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  134         -
)]
  135         -
pub struct EmptyStruct {}
  136         -
impl EmptyStruct {
  137         -
    /// Creates a new builder-style object to manufacture [`EmptyStruct`](crate::model::EmptyStruct).
  138         -
    pub fn builder() -> crate::model::empty_struct::Builder {
  139         -
        crate::model::empty_struct::Builder::default()
  140         -
    }
  141         -
}
  142         -
  143         -
#[allow(missing_docs)] // documentation missing in model
  144         -
#[derive(
  145         -
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  146         -
)]
  147         -
pub enum SingleElementUnion {
  148         -
    #[allow(missing_docs)] // documentation missing in model
  149         -
    A(::std::string::String),
  150         -
}
  151         -
impl SingleElementUnion {
  152         -
    #[allow(irrefutable_let_patterns)]
  153         -
    /// Tries to convert the enum instance into [`A`](crate::model::SingleElementUnion::A), extracting the inner [`String`](::std::string::String).
  154         -
    /// Returns `Err(&Self)` if it can't be converted.
  155         -
    pub fn as_a(&self) -> ::std::result::Result<&::std::string::String, &Self> {
  156         -
        if let SingleElementUnion::A(val) = &self {
  157         -
            ::std::result::Result::Ok(val)
  158         -
        } else {
  159         -
            ::std::result::Result::Err(self)
  160         -
        }
  161         -
    }
  162         -
    /// Returns true if this is a [`A`](crate::model::SingleElementUnion::A).
  163         -
    pub fn is_a(&self) -> bool {
  164         -
        self.as_a().is_ok()
  165         -
    }
  166         -
}
  167         -
  168    173   
#[allow(missing_docs)] // documentation missing in model
  169    174   
#[derive(
  170    175   
    ::std::clone::Clone,
  171    176   
    ::std::cmp::Eq,
  172    177   
    ::std::cmp::Ord,
  173    178   
    ::std::cmp::PartialEq,
  174    179   
    ::std::cmp::PartialOrd,
  175    180   
    ::std::fmt::Debug,
  176    181   
    ::std::hash::Hash,
  177    182   
)]
  178         -
pub enum EnumWithEscapedChars {
  179         -
    /// this needs#tobe escaped
  180         -
    HasQuotes,
         183  +
pub enum StringEnum {
  181    184   
    #[allow(missing_docs)] // documentation missing in model
  182         -
    Normal,
         185  +
    V,
  183    186   
}
  184         -
/// See [`EnumWithEscapedChars`](crate::model::EnumWithEscapedChars).
  185         -
pub mod enum_with_escaped_chars {
         187  +
/// See [`StringEnum`](crate::model::StringEnum).
         188  +
pub mod string_enum {
  186    189   
    #[derive(Debug, PartialEq)]
  187    190   
    pub struct ConstraintViolation(pub(crate) ::std::string::String);
  188    191   
  189    192   
    impl ::std::fmt::Display for ConstraintViolation {
  190    193   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  191    194   
            write!(
  192    195   
                f,
  193         -
                r#"Value provided for 'aws.protocoltests.restjson#EnumWithEscapedChars' failed to satisfy constraint: Member must satisfy enum value set: [has"quotes, normal]"#
         196  +
                r#"Value provided for 'aws.protocoltests.restjson#StringEnum' failed to satisfy constraint: Member must satisfy enum value set: [enumvalue]"#
  194    197   
            )
  195    198   
        }
  196    199   
    }
  197    200   
  198    201   
    impl ::std::error::Error for ConstraintViolation {}
  199    202   
    impl ConstraintViolation {
  200    203   
        pub(crate) fn as_validation_exception_field(
  201    204   
            self,
  202    205   
            path: ::std::string::String,
  203    206   
        ) -> crate::model::ValidationExceptionField {
  204    207   
            crate::model::ValidationExceptionField {
  205    208   
                message: format!(
  206         -
                    r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [has"quotes, normal]"#,
         209  +
                    r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [enumvalue]"#,
  207    210   
                    &path
  208    211   
                ),
  209    212   
                path,
  210    213   
            }
  211    214   
        }
  212    215   
    }
  213    216   
}
  214         -
impl ::std::convert::TryFrom<&str> for EnumWithEscapedChars {
  215         -
    type Error = crate::model::enum_with_escaped_chars::ConstraintViolation;
         217  +
impl ::std::convert::TryFrom<&str> for StringEnum {
         218  +
    type Error = crate::model::string_enum::ConstraintViolation;
  216    219   
    fn try_from(
  217    220   
        s: &str,
  218    221   
    ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
  219    222   
        match s {
  220         -
            "has\"quotes" => Ok(EnumWithEscapedChars::HasQuotes),
  221         -
            "normal" => Ok(EnumWithEscapedChars::Normal),
  222         -
            _ => Err(crate::model::enum_with_escaped_chars::ConstraintViolation(
  223         -
                s.to_owned(),
  224         -
            )),
         223  +
            "enumvalue" => Ok(StringEnum::V),
         224  +
            _ => Err(crate::model::string_enum::ConstraintViolation(s.to_owned())),
  225    225   
        }
  226    226   
    }
  227    227   
}
  228         -
impl ::std::convert::TryFrom<::std::string::String> for EnumWithEscapedChars {
  229         -
    type Error = crate::model::enum_with_escaped_chars::ConstraintViolation;
         228  +
impl ::std::convert::TryFrom<::std::string::String> for StringEnum {
         229  +
    type Error = crate::model::string_enum::ConstraintViolation;
  230    230   
    fn try_from(
  231    231   
        s: ::std::string::String,
  232    232   
    ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
  233    233   
    {
  234    234   
        s.as_str().try_into()
  235    235   
    }
  236    236   
}
  237         -
impl std::str::FromStr for EnumWithEscapedChars {
  238         -
    type Err = crate::model::enum_with_escaped_chars::ConstraintViolation;
         237  +
impl std::str::FromStr for StringEnum {
         238  +
    type Err = crate::model::string_enum::ConstraintViolation;
  239    239   
    fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
  240    240   
        Self::try_from(s)
  241    241   
    }
  242    242   
}
  243         -
impl EnumWithEscapedChars {
         243  +
impl StringEnum {
  244    244   
    /// Returns the `&str` value of the enum member.
  245    245   
    pub fn as_str(&self) -> &str {
  246    246   
        match self {
  247         -
            EnumWithEscapedChars::HasQuotes => "has\"quotes",
  248         -
            EnumWithEscapedChars::Normal => "normal",
         247  +
            StringEnum::V => "enumvalue",
  249    248   
        }
  250    249   
    }
  251    250   
    /// Returns all the `&str` representations of the enum members.
  252    251   
    pub const fn values() -> &'static [&'static str] {
  253         -
        &["has\"quotes", "normal"]
         252  +
        &["enumvalue"]
  254    253   
    }
  255    254   
}
  256         -
impl ::std::convert::AsRef<str> for EnumWithEscapedChars {
         255  +
impl ::std::convert::AsRef<str> for StringEnum {
  257    256   
    fn as_ref(&self) -> &str {
  258    257   
        self.as_str()
  259    258   
    }
  260    259   
}
  261         -
impl crate::constrained::Constrained for EnumWithEscapedChars {
         260  +
impl crate::constrained::Constrained for StringEnum {
  262    261   
    type Unconstrained = ::std::string::String;
  263    262   
}
  264    263   
  265    264   
impl ::std::convert::From<::std::string::String>
  266         -
    for crate::constrained::MaybeConstrained<crate::model::EnumWithEscapedChars>
         265  +
    for crate::constrained::MaybeConstrained<crate::model::StringEnum>
  267    266   
{
  268    267   
    fn from(value: ::std::string::String) -> Self {
  269    268   
        Self::Unconstrained(value)
  270    269   
    }
  271    270   
}
         271  +
/// See [`EmptyStruct`](crate::model::EmptyStruct).
         272  +
///
         273  +
pub mod empty_struct {
  272    274   
         275  +
    impl ::std::convert::From<Builder> for crate::model::EmptyStruct {
         276  +
        fn from(builder: Builder) -> Self {
         277  +
            builder.build()
         278  +
        }
         279  +
    }
         280  +
    /// A builder for [`EmptyStruct`](crate::model::EmptyStruct).
         281  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         282  +
    pub struct Builder {}
         283  +
    impl Builder {
         284  +
        /// Consumes the builder and constructs a [`EmptyStruct`](crate::model::EmptyStruct).
         285  +
        pub fn build(self) -> crate::model::EmptyStruct {
         286  +
            self.build_enforcing_all_constraints()
         287  +
        }
         288  +
        fn build_enforcing_all_constraints(self) -> crate::model::EmptyStruct {
         289  +
            crate::model::EmptyStruct {}
         290  +
        }
         291  +
    }
         292  +
}
  273    293   
/// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
  274    294   
///
  275    295   
pub mod validation_exception_field {
  276    296   
  277    297   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  278    298   
    /// Holds one variant for each of the ways the builder can fail.
  279    299   
    #[non_exhaustive]
  280    300   
    #[allow(clippy::enum_variant_names)]
  281    301   
    pub enum ConstraintViolation {
  282    302   
        /// `path` was not provided but it is required when building `ValidationExceptionField`.
@@ -308,328 +389,387 @@
  328    348   
        fn build_enforcing_all_constraints(
  329    349   
            self,
  330    350   
        ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
  331    351   
            Ok(crate::model::ValidationExceptionField {
  332    352   
                path: self.path.ok_or(ConstraintViolation::MissingPath)?,
  333    353   
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  334    354   
            })
  335    355   
        }
  336    356   
    }
  337    357   
}
  338         -
/// See [`EmptyStruct`](crate::model::EmptyStruct).
  339         -
///
  340         -
pub mod empty_struct {
  341         -
  342         -
    impl ::std::convert::From<Builder> for crate::model::EmptyStruct {
  343         -
        fn from(builder: Builder) -> Self {
  344         -
            builder.build()
  345         -
        }
  346         -
    }
  347         -
    /// A builder for [`EmptyStruct`](crate::model::EmptyStruct).
  348         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  349         -
    pub struct Builder {}
  350         -
    impl Builder {
  351         -
        /// Consumes the builder and constructs a [`EmptyStruct`](crate::model::EmptyStruct).
  352         -
        pub fn build(self) -> crate::model::EmptyStruct {
  353         -
            self.build_enforcing_all_constraints()
  354         -
        }
  355         -
        fn build_enforcing_all_constraints(self) -> crate::model::EmptyStruct {
  356         -
            crate::model::EmptyStruct {}
  357         -
        }
  358         -
    }
  359         -
}
  360    358   
///
  361    359   
pub mod map_with_enum_key {
  362    360   
  363    361   
    #[allow(clippy::enum_variant_names)]
  364    362   
    #[derive(Debug, PartialEq)]
  365    363   
    pub enum ConstraintViolation {
  366    364   
        #[doc(hidden)]
  367    365   
        Key(crate::model::string_enum::ConstraintViolation),
  368    366   
    }
  369    367   

tmp-codegen-diff/codegen-server-test/rest_json_extras/rust-server-codegen/src/operation.rs

@@ -1,1 +954,31 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
static CONTENT_TYPE_HTTPSTRINGPAYLOAD2: ::once_cell::sync::Lazy<::mime::Mime> =
    3         -
    ::once_cell::sync::Lazy::new(|| {
    4         -
        "text/plain"
    5         -
            .parse::<::mime::Mime>()
    6         -
            .expect("BUG: MIME parsing failed, content_type is not valid")
    7         -
    });
    8         -
::pin_project_lite::pin_project! {
    9         -
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
   10         -
    /// [`HttpStringPayload2Input`](crate::input::HttpStringPayload2Input) using modelled bindings.
   11         -
    pub struct HttpStringPayload2InputFuture {
   12         -
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HttpStringPayload2Input, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
   13         -
    }
   14         -
}
   15         -
   16         -
impl std::future::Future for HttpStringPayload2InputFuture {
   17         -
    type Output = Result<
   18         -
        crate::input::HttpStringPayload2Input,
   19         -
        ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
   20         -
    >;
   21         -
   22         -
    fn poll(
   23         -
        self: std::pin::Pin<&mut Self>,
   24         -
        cx: &mut std::task::Context<'_>,
   25         -
    ) -> std::task::Poll<Self::Output> {
   26         -
        let this = self.project();
   27         -
        this.inner.as_mut().poll(cx)
   28         -
    }
   29         -
}
   30         -
   31         -
impl<B>
   32         -
    ::aws_smithy_http_server::request::FromRequest<
   33         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
   34         -
        B,
   35         -
    > for crate::input::HttpStringPayload2Input
   36         -
where
   37         -
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   38         -
    B: 'static,
   39         -
   40         -
    B::Data: Send,
   41         -
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   42         -
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   43         -
{
   44         -
    type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
   45         -
    type Future = HttpStringPayload2InputFuture;
   46         -
   47         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
   48         -
        let fut = async move {
   49         -
            if !::aws_smithy_http_server::protocol::accept_header_classifier(
   50         -
                request.headers(),
   51         -
                &CONTENT_TYPE_HTTPSTRINGPAYLOAD2,
   52         -
            ) {
   53         -
                return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
   54         -
            }
   55         -
            crate::protocol_serde::shape_http_string_payload2::de_http_string_payload2_http_request(
   56         -
                request,
   57         -
            )
   58         -
            .await
   59         -
            .map_err(Into::into)
   60         -
        };
   61         -
        use ::futures_util::future::TryFutureExt;
   62         -
        let fut = fut.map_err(
   63         -
            |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
   64         -
                ::tracing::debug!(error = %e, "failed to deserialize request");
   65         -
                ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
   66         -
                    e,
   67         -
                )
   68         -
            },
   69         -
        );
   70         -
        HttpStringPayload2InputFuture {
   71         -
            inner: Box::pin(fut),
   72         -
        }
   73         -
    }
   74         -
}
   75         -
impl
   76         -
    ::aws_smithy_http_server::response::IntoResponse<
   77         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
   78         -
    > for crate::output::HttpStringPayload2Output
   79         -
{
   80         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   81         -
        match crate::protocol_serde::shape_http_string_payload2::ser_http_string_payload2_http_response(self) {
   82         -
                        Ok(response) => response,
   83         -
                        Err(e) => {
   84         -
                            ::tracing::error!(error = %e, "failed to serialize response");
   85         -
                            ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
   86         -
                        }
   87         -
                    }
   88         -
    }
   89         -
}
   90         -
impl
   91         -
    ::aws_smithy_http_server::response::IntoResponse<
   92         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
   93         -
    > for crate::error::HttpStringPayload2Error
   94         -
{
   95         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   96         -
        match crate::protocol_serde::shape_http_string_payload2::ser_http_string_payload2_http_error(
   97         -
            &self,
   98         -
        ) {
   99         -
            Ok(mut response) => {
  100         -
                response.extensions_mut().insert(
  101         -
                    ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
  102         -
                );
  103         -
                response
  104         -
            }
  105         -
            Err(e) => {
  106         -
                ::tracing::error!(error = %e, "failed to serialize response");
  107         -
                ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  108         -
            }
  109         -
        }
  110         -
    }
  111         -
}
  112         -
  113         -
#[allow(unreachable_code, unused_variables)]
  114         -
#[cfg(test)]
  115         -
mod http_string_payload2_test {
  116         -
  117         -
    /// Test ID: RestJsonStringPayloadRequest2
  118         -
    #[::tokio::test]
  119         -
    #[::tracing_test::traced_test]
  120         -
    async fn rest_json_string_payload_request2_request() {
  121         -
        #[allow(unused_mut)]
  122         -
        let mut http_request = http::Request::builder()
  123         -
            .uri("/StringPayload2")
  124         -
            .method("POST")
  125         -
            .header("Content-Type", "text/plain")
  126         -
            .body(::aws_smithy_http_server::body::Body::from(
  127         -
                ::bytes::Bytes::from_static("rawstring".as_bytes()),
  128         -
            ))
  129         -
            .unwrap();
  130         -
        #[allow(unused_mut)]
  131         -
        let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  132         -
        let config = crate::service::RestJsonExtrasConfig::builder().build();
  133         -
        let service =
  134         -
            crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  135         -
                .http_string_payload2(move |input: crate::input::HttpStringPayload2Input| {
  136         -
                    let sender = sender.clone();
  137         -
                    async move {
  138         -
                        let result = {
  139         -
                            let expected = crate::input::HttpStringPayload2Input {
  140         -
                                payload: ::std::option::Option::Some("rawstring".to_owned()),
  141         -
                            };
  142         -
                            ::pretty_assertions::assert_eq!(input, expected);
  143         -
                            let response = crate::output::HttpStringPayload2Output {
  144         -
                                payload: ::std::option::Option::None,
  145         -
                            };
  146         -
                            Ok(response)
  147         -
                        };
  148         -
                        sender.send(()).await.expect("receiver dropped early");
  149         -
                        result
  150         -
                    }
  151         -
                })
  152         -
                .build_unchecked();
  153         -
        let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  154         -
            .await
  155         -
            .expect("unable to make an HTTP request");
  156         -
        assert!(
  157         -
            receiver.recv().await.is_some(),
  158         -
            "we expected operation handler to be invoked but it was not entered"
  159         -
        );
  160         -
    }
  161         -
    /// Test ID: RestJsonStringPayloadResponse2
  162         -
    #[::tokio::test]
  163         -
    #[::tracing_test::traced_test]
  164         -
    async fn rest_json_string_payload_response2_response() {
  165         -
        let output = crate::output::HttpStringPayload2Output {
  166         -
            payload: ::std::option::Option::Some("rawstring".to_owned()),
  167         -
        };
  168         -
        use ::aws_smithy_http_server::response::IntoResponse;
  169         -
        let http_response = output.into_response();
  170         -
        ::pretty_assertions::assert_eq!(
  171         -
            http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
  172         -
            http_response.status()
  173         -
        );
  174         -
        let expected_headers = [("Content-Type", "text/plain")];
  175         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  176         -
            http_response.headers(),
  177         -
            expected_headers,
  178         -
        ));
  179         -
        let body = ::hyper::body::to_bytes(http_response.into_body())
  180         -
            .await
  181         -
            .expect("unable to extract body to bytes");
  182         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
  183         -
            &body,
  184         -
            "rawstring",
  185         -
            ::aws_smithy_protocol_test::MediaType::from("text/plain"),
  186         -
        ));
  187         -
    }
  188         -
    /// Upper case error modeled lower case.
  189         -
    /// Test ID: ServiceLevelErrorServer
  190         -
    #[::tokio::test]
  191         -
    #[::tracing_test::traced_test]
  192         -
    async fn service_level_error_server_response() {
  193         -
        let output = crate::error::ExtraError {};
  194         -
        let output = crate::error::HttpStringPayload2Error::ExtraError(output);
  195         -
        use ::aws_smithy_http_server::response::IntoResponse;
  196         -
        let http_response = output.into_response();
  197         -
        ::pretty_assertions::assert_eq!(
  198         -
            http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
  199         -
            http_response.status()
  200         -
        );
  201         -
        let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
  202         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  203         -
            http_response.headers(),
  204         -
            expected_headers,
  205         -
        ));
  206         -
        let body = ::hyper::body::to_bytes(http_response.into_body())
  207         -
            .await
  208         -
            .expect("unable to extract body to bytes");
  209         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
  210         -
            &body,
  211         -
            "{}",
  212         -
            ::aws_smithy_protocol_test::MediaType::from("unknown"),
  213         -
        ));
  214         -
    }
  215         -
    /// Serializes a string in the HTTP payload without a content-type header
  216         -
    /// Test ID: RestJsonStringPayloadNoContentType2
  217         -
    #[::tokio::test]
  218         -
    #[::tracing_test::traced_test]
  219         -
    async fn rest_json_string_payload_no_content_type2_malformed_request() {
  220         -
        {
  221         -
            #[allow(unused_mut)]
  222         -
            let mut http_request = http::Request::builder()
  223         -
                .uri("/StringPayload2")
  224         -
                .method("POST")
  225         -
                .body(::aws_smithy_http_server::body::Body::from(
  226         -
                    ::bytes::Bytes::from_static("rawstring".as_bytes()),
  227         -
                ))
  228         -
                .unwrap();
  229         -
            #[allow(unused_mut)]
  230         -
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  231         -
            let config = crate::service::RestJsonExtrasConfig::builder().build();
  232         -
            let service = crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  233         -
                            .http_string_payload2(move |input: crate::input::HttpStringPayload2Input| {
  234         -
                                let sender = sender.clone();
  235         -
                                async move {
  236         -
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::HttpStringPayload2Output, crate::error::HttpStringPayload2Error> };
  237         -
                                    sender.send(()).await.expect("receiver dropped early");
  238         -
                                    result
  239         -
                                }
  240         -
                            })
  241         -
                            .build_unchecked();
  242         -
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  243         -
                .await
  244         -
                .expect("unable to make an HTTP request");
  245         -
            ::pretty_assertions::assert_eq!(
  246         -
                http::StatusCode::from_u16(415).expect("invalid expected HTTP status code"),
  247         -
                http_response.status()
  248         -
            );
  249         -
            let expected_headers = [("x-amzn-errortype", "UnsupportedMediaTypeException")];
  250         -
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  251         -
                http_response.headers(),
  252         -
                expected_headers,
  253         -
            ));
  254         -
        }
  255         -
    }
  256         -
    /// Serializes a string in the HTTP payload without the expected content-type header
  257         -
    /// Test ID: RestJsonStringPayloadWrongContentType2
  258         -
    #[::tokio::test]
  259         -
    #[::tracing_test::traced_test]
  260         -
    async fn rest_json_string_payload_wrong_content_type2_malformed_request() {
  261         -
        {
  262         -
            #[allow(unused_mut)]
  263         -
            let mut http_request = http::Request::builder()
  264         -
                .uri("/StringPayload2")
  265         -
                .method("POST")
  266         -
                .header("Content-Type", "application/json")
  267         -
                .body(::aws_smithy_http_server::body::Body::from(
  268         -
                    ::bytes::Bytes::from_static("rawstring".as_bytes()),
  269         -
                ))
  270         -
                .unwrap();
  271         -
            #[allow(unused_mut)]
  272         -
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  273         -
            let config = crate::service::RestJsonExtrasConfig::builder().build();
  274         -
            let service = crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  275         -
                            .http_string_payload2(move |input: crate::input::HttpStringPayload2Input| {
  276         -
                                let sender = sender.clone();
  277         -
                                async move {
  278         -
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::HttpStringPayload2Output, crate::error::HttpStringPayload2Error> };
  279         -
                                    sender.send(()).await.expect("receiver dropped early");
  280         -
                                    result
  281         -
                                }
  282         -
                            })
  283         -
                            .build_unchecked();
  284         -
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  285         -
                .await
  286         -
                .expect("unable to make an HTTP request");
  287         -
            ::pretty_assertions::assert_eq!(
  288         -
                http::StatusCode::from_u16(415).expect("invalid expected HTTP status code"),
  289         -
                http_response.status()
  290         -
            );
  291         -
            let expected_headers = [("x-amzn-errortype", "UnsupportedMediaTypeException")];
  292         -
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  293         -
                http_response.headers(),
  294         -
                expected_headers,
  295         -
            ));
  296         -
        }
  297         -
    }
  298         -
    /// Serializes a string in the HTTP payload with an unstatisfiable accept header
  299         -
    /// Test ID: RestJsonStringPayloadUnsatisfiableAccept2
  300         -
    #[::tokio::test]
  301         -
    #[::tracing_test::traced_test]
  302         -
    async fn rest_json_string_payload_unsatisfiable_accept2_malformed_request() {
  303         -
        {
  304         -
            #[allow(unused_mut)]
  305         -
            let mut http_request = http::Request::builder()
  306         -
                .uri("/StringPayload2")
  307         -
                .method("POST")
  308         -
                .header("Accept", "application/json")
  309         -
                .header("Content-Type", "text/plain")
  310         -
                .body(::aws_smithy_http_server::body::Body::from(
  311         -
                    ::bytes::Bytes::from_static("rawstring".as_bytes()),
  312         -
                ))
  313         -
                .unwrap();
  314         -
            #[allow(unused_mut)]
  315         -
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  316         -
            let config = crate::service::RestJsonExtrasConfig::builder().build();
  317         -
            let service = crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  318         -
                            .http_string_payload2(move |input: crate::input::HttpStringPayload2Input| {
  319         -
                                let sender = sender.clone();
  320         -
                                async move {
  321         -
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::HttpStringPayload2Output, crate::error::HttpStringPayload2Error> };
  322         -
                                    sender.send(()).await.expect("receiver dropped early");
  323         -
                                    result
  324         -
                                }
  325         -
                            })
  326         -
                            .build_unchecked();
  327         -
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  328         -
                .await
  329         -
                .expect("unable to make an HTTP request");
  330         -
            ::pretty_assertions::assert_eq!(
  331         -
                http::StatusCode::from_u16(406).expect("invalid expected HTTP status code"),
  332         -
                http_response.status()
  333         -
            );
  334         -
            let expected_headers = [("x-amzn-errortype", "NotAcceptableException")];
  335         -
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  336         -
                http_response.headers(),
  337         -
                expected_headers,
  338         -
            ));
  339         -
        }
  340         -
    }
  341         -
}
  342         -
  343         -
static CONTENT_TYPE_HTTPENUMPAYLOAD2: ::once_cell::sync::Lazy<::mime::Mime> =
  344         -
    ::once_cell::sync::Lazy::new(|| {
  345         -
        "text/plain"
  346         -
            .parse::<::mime::Mime>()
  347         -
            .expect("BUG: MIME parsing failed, content_type is not valid")
  348         -
    });
  349         -
::pin_project_lite::pin_project! {
  350         -
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
  351         -
    /// [`HttpEnumPayload2Input`](crate::input::HttpEnumPayload2Input) using modelled bindings.
  352         -
    pub struct HttpEnumPayload2InputFuture {
  353         -
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HttpEnumPayload2Input, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
  354         -
    }
  355         -
}
  356         -
  357         -
impl std::future::Future for HttpEnumPayload2InputFuture {
  358         -
    type Output = Result<
  359         -
        crate::input::HttpEnumPayload2Input,
  360         -
        ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
  361         -
    >;
  362         -
  363         -
    fn poll(
  364         -
        self: std::pin::Pin<&mut Self>,
  365         -
        cx: &mut std::task::Context<'_>,
  366         -
    ) -> std::task::Poll<Self::Output> {
  367         -
        let this = self.project();
  368         -
        this.inner.as_mut().poll(cx)
  369         -
    }
  370         -
}
  371         -
  372         -
impl<B>
  373         -
    ::aws_smithy_http_server::request::FromRequest<
  374         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  375         -
        B,
  376         -
    > for crate::input::HttpEnumPayload2Input
  377         -
where
  378         -
    B: ::aws_smithy_http_server::body::HttpBody + Send,
  379         -
    B: 'static,
  380         -
  381         -
    B::Data: Send,
  382         -
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
  383         -
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
  384         -
{
  385         -
    type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
  386         -
    type Future = HttpEnumPayload2InputFuture;
  387         -
  388         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
  389         -
        let fut = async move {
  390         -
            if !::aws_smithy_http_server::protocol::accept_header_classifier(
  391         -
                request.headers(),
  392         -
                &CONTENT_TYPE_HTTPENUMPAYLOAD2,
  393         -
            ) {
  394         -
                return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
  395         -
            }
  396         -
            crate::protocol_serde::shape_http_enum_payload2::de_http_enum_payload2_http_request(
  397         -
                request,
  398         -
            )
  399         -
            .await
  400         -
            .map_err(Into::into)
  401         -
        };
  402         -
        use ::futures_util::future::TryFutureExt;
  403         -
        let fut = fut.map_err(
  404         -
            |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
  405         -
                ::tracing::debug!(error = %e, "failed to deserialize request");
  406         -
                ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
  407         -
                    e,
  408         -
                )
  409         -
            },
  410         -
        );
  411         -
        HttpEnumPayload2InputFuture {
  412         -
            inner: Box::pin(fut),
  413         -
        }
  414         -
    }
  415         -
}
  416         -
impl
  417         -
    ::aws_smithy_http_server::response::IntoResponse<
  418         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  419         -
    > for crate::output::HttpEnumPayload2Output
  420         -
{
  421         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
  422         -
        match crate::protocol_serde::shape_http_enum_payload2::ser_http_enum_payload2_http_response(
  423         -
            self,
  424         -
        ) {
  425         -
            Ok(response) => response,
  426         -
            Err(e) => {
  427         -
                ::tracing::error!(error = %e, "failed to serialize response");
  428         -
                ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  429         -
            }
  430         -
        }
  431         -
    }
  432         -
}
  433         -
impl
  434         -
    ::aws_smithy_http_server::response::IntoResponse<
  435         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  436         -
    > for crate::error::HttpEnumPayload2Error
  437         -
{
  438         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
  439         -
        match crate::protocol_serde::shape_http_enum_payload2::ser_http_enum_payload2_http_error(
  440         -
            &self,
  441         -
        ) {
  442         -
            Ok(mut response) => {
  443         -
                response.extensions_mut().insert(
  444         -
                    ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
  445         -
                );
  446         -
                response
  447         -
            }
  448         -
            Err(e) => {
  449         -
                ::tracing::error!(error = %e, "failed to serialize response");
  450         -
                ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  451         -
            }
  452         -
        }
  453         -
    }
  454         -
}
  455         -
  456         -
#[allow(unreachable_code, unused_variables)]
  457         -
#[cfg(test)]
  458         -
mod http_enum_payload2_test {
  459         -
  460         -
    /// Test ID: RestJsonEnumPayloadRequest2
  461         -
    #[::tokio::test]
  462         -
    #[::tracing_test::traced_test]
  463         -
    async fn rest_json_enum_payload_request2_request() {
  464         -
        #[allow(unused_mut)]
  465         -
        let mut http_request = http::Request::builder()
  466         -
            .uri("/EnumPayload2")
  467         -
            .method("POST")
  468         -
            .header("Content-Type", "text/plain")
  469         -
            .body(::aws_smithy_http_server::body::Body::from(
  470         -
                ::bytes::Bytes::from_static("enumvalue".as_bytes()),
  471         -
            ))
  472         -
            .unwrap();
  473         -
        #[allow(unused_mut)]
  474         -
        let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  475         -
        let config = crate::service::RestJsonExtrasConfig::builder().build();
  476         -
        let service =
  477         -
            crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  478         -
                .http_enum_payload2(move |input: crate::input::HttpEnumPayload2Input| {
  479         -
                    let sender = sender.clone();
  480         -
                    async move {
  481         -
                        let result = {
  482         -
                            let expected = crate::input::HttpEnumPayload2Input {
  483         -
                                payload: ::std::option::Option::Some(
  484         -
                                    "enumvalue"
  485         -
                                        .parse::<crate::model::StringEnum>()
  486         -
                                        .expect("static value validated to member"),
  487         -
                                ),
  488         -
                            };
  489         -
                            ::pretty_assertions::assert_eq!(input, expected);
  490         -
                            let response = crate::output::HttpEnumPayload2Output {
  491         -
                                payload: ::std::option::Option::None,
  492         -
                            };
  493         -
                            Ok(response)
  494         -
                        };
  495         -
                        sender.send(()).await.expect("receiver dropped early");
  496         -
                        result
  497         -
                    }
  498         -
                })
  499         -
                .build_unchecked();
  500         -
        let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  501         -
            .await
  502         -
            .expect("unable to make an HTTP request");
  503         -
        assert!(
  504         -
            receiver.recv().await.is_some(),
  505         -
            "we expected operation handler to be invoked but it was not entered"
  506         -
        );
  507         -
    }
  508         -
    /// Test ID: RestJsonEnumPayloadResponse2
  509         -
    #[::tokio::test]
  510         -
    #[::tracing_test::traced_test]
  511         -
    async fn rest_json_enum_payload_response2_response() {
  512         -
        let output = crate::output::HttpEnumPayload2Output {
  513         -
            payload: ::std::option::Option::Some(
  514         -
                "enumvalue"
  515         -
                    .parse::<crate::model::StringEnum>()
  516         -
                    .expect("static value validated to member"),
  517         -
            ),
  518         -
        };
  519         -
        use ::aws_smithy_http_server::response::IntoResponse;
  520         -
        let http_response = output.into_response();
  521         -
        ::pretty_assertions::assert_eq!(
  522         -
            http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
  523         -
            http_response.status()
  524         -
        );
  525         -
        let expected_headers = [("Content-Type", "text/plain")];
  526         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  527         -
            http_response.headers(),
  528         -
            expected_headers,
  529         -
        ));
  530         -
        let body = ::hyper::body::to_bytes(http_response.into_body())
  531         -
            .await
  532         -
            .expect("unable to extract body to bytes");
  533         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
  534         -
            &body,
  535         -
            "enumvalue",
  536         -
            ::aws_smithy_protocol_test::MediaType::from("unknown"),
  537         -
        ));
  538         -
    }
  539         -
    /// Upper case error modeled lower case.
  540         -
    /// Test ID: ServiceLevelErrorServer
  541         -
    #[::tokio::test]
  542         -
    #[::tracing_test::traced_test]
  543         -
    async fn service_level_error_server_response() {
  544         -
        let output = crate::error::ExtraError {};
  545         -
        let output = crate::error::HttpEnumPayload2Error::ExtraError(output);
  546         -
        use ::aws_smithy_http_server::response::IntoResponse;
  547         -
        let http_response = output.into_response();
  548         -
        ::pretty_assertions::assert_eq!(
  549         -
            http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
  550         -
            http_response.status()
  551         -
        );
  552         -
        let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
  553         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  554         -
            http_response.headers(),
  555         -
            expected_headers,
  556         -
        ));
  557         -
        let body = ::hyper::body::to_bytes(http_response.into_body())
  558         -
            .await
  559         -
            .expect("unable to extract body to bytes");
  560         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
  561         -
            &body,
  562         -
            "{}",
  563         -
            ::aws_smithy_protocol_test::MediaType::from("unknown"),
  564         -
        ));
  565         -
    }
  566         -
}
  567         -
  568         -
const CONTENT_TYPE_MALFORMEDCONTENTTYPEWITHBODY2: ::mime::Mime = ::mime::APPLICATION_JSON;
  569         -
::pin_project_lite::pin_project! {
  570         -
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
  571         -
    /// [`MalformedContentTypeWithBody2Input`](crate::input::MalformedContentTypeWithBody2Input) using modelled bindings.
  572         -
    pub struct MalformedContentTypeWithBody2InputFuture {
  573         -
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedContentTypeWithBody2Input, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
  574         -
    }
  575         -
}
  576         -
  577         -
impl std::future::Future for MalformedContentTypeWithBody2InputFuture {
  578         -
    type Output = Result<
  579         -
        crate::input::MalformedContentTypeWithBody2Input,
  580         -
        ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
  581         -
    >;
  582         -
  583         -
    fn poll(
  584         -
        self: std::pin::Pin<&mut Self>,
  585         -
        cx: &mut std::task::Context<'_>,
  586         -
    ) -> std::task::Poll<Self::Output> {
  587         -
        let this = self.project();
  588         -
        this.inner.as_mut().poll(cx)
  589         -
    }
  590         -
}
  591         -
  592         -
impl<B>
  593         -
    ::aws_smithy_http_server::request::FromRequest<
  594         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  595         -
        B,
  596         -
    > for crate::input::MalformedContentTypeWithBody2Input
  597         -
where
  598         -
    B: ::aws_smithy_http_server::body::HttpBody + Send,
  599         -
    B: 'static,
  600         -
  601         -
    B::Data: Send,
  602         -
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
  603         -
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
  604         -
{
  605         -
    type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
  606         -
    type Future = MalformedContentTypeWithBody2InputFuture;
  607         -
  608         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
  609         -
        let fut = async move {
  610         -
            if !::aws_smithy_http_server::protocol::accept_header_classifier(
  611         -
                request.headers(),
  612         -
                &CONTENT_TYPE_MALFORMEDCONTENTTYPEWITHBODY2,
  613         -
            ) {
  614         -
                return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
  615         -
            }
  616         -
            crate::protocol_serde::shape_malformed_content_type_with_body2::de_malformed_content_type_with_body2_http_request(request)
  617         -
                            .await
  618         -
                            .map_err(Into::into)
  619         -
        };
  620         -
        use ::futures_util::future::TryFutureExt;
  621         -
        let fut = fut.map_err(
  622         -
            |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
  623         -
                ::tracing::debug!(error = %e, "failed to deserialize request");
  624         -
                ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
  625         -
                    e,
  626         -
                )
  627         -
            },
  628         -
        );
  629         -
        MalformedContentTypeWithBody2InputFuture {
  630         -
            inner: Box::pin(fut),
  631         -
        }
  632         -
    }
  633         -
}
  634         -
impl
  635         -
    ::aws_smithy_http_server::response::IntoResponse<
  636         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  637         -
    > for crate::output::MalformedContentTypeWithBody2Output
  638         -
{
  639         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
  640         -
        match crate::protocol_serde::shape_malformed_content_type_with_body2::ser_malformed_content_type_with_body2_http_response(self) {
  641         -
                        Ok(response) => response,
  642         -
                        Err(e) => {
  643         -
                            ::tracing::error!(error = %e, "failed to serialize response");
  644         -
                            ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  645         -
                        }
  646         -
                    }
  647         -
    }
  648         -
}
  649         -
impl
  650         -
    ::aws_smithy_http_server::response::IntoResponse<
  651         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  652         -
    > for crate::error::MalformedContentTypeWithBody2Error
  653         -
{
  654         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
  655         -
        match crate::protocol_serde::shape_malformed_content_type_with_body2::ser_malformed_content_type_with_body2_http_error(&self) {
  656         -
            Ok(mut response) => {
  657         -
                response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
  658         -
                response
  659         -
            },
  660         -
            Err(e) => {
  661         -
                ::tracing::error!(error = %e, "failed to serialize response");
  662         -
                ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  663         -
            }
  664         -
        }
  665         -
    }
  666         -
}
  667         -
  668         -
#[allow(unreachable_code, unused_variables)]
  669         -
#[cfg(test)]
  670         -
mod malformed_content_type_with_body2_test {
  671         -
  672         -
    /// Upper case error modeled lower case.
  673         -
    /// Test ID: ServiceLevelErrorServer
  674         -
    #[::tokio::test]
  675         -
    #[::tracing_test::traced_test]
  676         -
    async fn service_level_error_server_response() {
  677         -
        let output = crate::error::ExtraError {};
  678         -
        let output = crate::error::MalformedContentTypeWithBody2Error::ExtraError(output);
  679         -
        use ::aws_smithy_http_server::response::IntoResponse;
  680         -
        let http_response = output.into_response();
  681         -
        ::pretty_assertions::assert_eq!(
  682         -
            http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
  683         -
            http_response.status()
  684         -
        );
  685         -
        let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
  686         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  687         -
            http_response.headers(),
  688         -
            expected_headers,
  689         -
        ));
  690         -
        let body = ::hyper::body::to_bytes(http_response.into_body())
  691         -
            .await
  692         -
            .expect("unable to extract body to bytes");
  693         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
  694         -
            &body,
  695         -
            "{}",
  696         -
            ::aws_smithy_protocol_test::MediaType::from("unknown"),
  697         -
        ));
  698         -
    }
  699         -
    /// When there is modeled input, the content type must be application/json
  700         -
    /// Test ID: RestJsonWithBodyExpectsApplicationJsonContentTypeNoHeaders
  701         -
    #[::tokio::test]
  702         -
    #[::tracing_test::traced_test]
  703         -
    async fn rest_json_with_body_expects_application_json_content_type_no_headers_malformed_request(
  704         -
    ) {
  705         -
        {
  706         -
            #[allow(unused_mut)]
  707         -
            let mut http_request = http::Request::builder()
  708         -
                .uri("/MalformedContentTypeWithBody")
  709         -
                .method("POST")
  710         -
                .body(::aws_smithy_http_server::body::Body::from(
  711         -
                    ::bytes::Bytes::from_static("{}".as_bytes()),
  712         -
                ))
  713         -
                .unwrap();
  714         -
            #[allow(unused_mut)]
  715         -
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  716         -
            let config = crate::service::RestJsonExtrasConfig::builder().build();
  717         -
            let service = crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  718         -
                            .malformed_content_type_with_body2(move |input: crate::input::MalformedContentTypeWithBody2Input| {
  719         -
                                let sender = sender.clone();
  720         -
                                async move {
  721         -
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedContentTypeWithBody2Output, crate::error::MalformedContentTypeWithBody2Error> };
  722         -
                                    sender.send(()).await.expect("receiver dropped early");
  723         -
                                    result
  724         -
                                }
  725         -
                            })
  726         -
                            .build_unchecked();
  727         -
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  728         -
                .await
  729         -
                .expect("unable to make an HTTP request");
  730         -
            ::pretty_assertions::assert_eq!(
  731         -
                http::StatusCode::from_u16(415).expect("invalid expected HTTP status code"),
  732         -
                http_response.status()
  733         -
            );
  734         -
            let expected_headers = [("x-amzn-errortype", "UnsupportedMediaTypeException")];
  735         -
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  736         -
                http_response.headers(),
  737         -
                expected_headers,
  738         -
            ));
  739         -
        }
  740         -
    }
  741         -
}
  742         -
  743         -
::pin_project_lite::pin_project! {
  744         -
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
  745         -
    /// [`HttpPayloadTraits2Input`](crate::input::HttpPayloadTraits2Input) using modelled bindings.
  746         -
    pub struct HttpPayloadTraits2InputFuture {
  747         -
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HttpPayloadTraits2Input, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
  748         -
    }
  749         -
}
  750         -
  751         -
impl std::future::Future for HttpPayloadTraits2InputFuture {
  752         -
    type Output = Result<
  753         -
        crate::input::HttpPayloadTraits2Input,
  754         -
        ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
  755         -
    >;
  756         -
  757         -
    fn poll(
  758         -
        self: std::pin::Pin<&mut Self>,
  759         -
        cx: &mut std::task::Context<'_>,
  760         -
    ) -> std::task::Poll<Self::Output> {
  761         -
        let this = self.project();
  762         -
        this.inner.as_mut().poll(cx)
  763         -
    }
  764         -
}
  765         -
  766         -
impl<B>
  767         -
    ::aws_smithy_http_server::request::FromRequest<
  768         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  769         -
        B,
  770         -
    > for crate::input::HttpPayloadTraits2Input
  771         -
where
  772         -
    B: ::aws_smithy_http_server::body::HttpBody + Send,
  773         -
    B: 'static,
  774         -
  775         -
    B::Data: Send,
  776         -
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
  777         -
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
  778         -
{
  779         -
    type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
  780         -
    type Future = HttpPayloadTraits2InputFuture;
  781         -
  782         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
  783         -
        let fut = async move {
  784         -
            crate::protocol_serde::shape_http_payload_traits2::de_http_payload_traits2_http_request(
  785         -
                request,
  786         -
            )
  787         -
            .await
  788         -
            .map_err(Into::into)
  789         -
        };
  790         -
        use ::futures_util::future::TryFutureExt;
  791         -
        let fut = fut.map_err(
  792         -
            |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
  793         -
                ::tracing::debug!(error = %e, "failed to deserialize request");
  794         -
                ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
  795         -
                    e,
  796         -
                )
  797         -
            },
  798         -
        );
  799         -
        HttpPayloadTraits2InputFuture {
  800         -
            inner: Box::pin(fut),
  801         -
        }
  802         -
    }
  803         -
}
  804         -
impl
  805         -
    ::aws_smithy_http_server::response::IntoResponse<
  806         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  807         -
    > for crate::output::HttpPayloadTraits2Output
  808         -
{
  809         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
  810         -
        match crate::protocol_serde::shape_http_payload_traits2::ser_http_payload_traits2_http_response(self) {
  811         -
                        Ok(response) => response,
  812         -
                        Err(e) => {
  813         -
                            ::tracing::error!(error = %e, "failed to serialize response");
  814         -
                            ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  815         -
                        }
  816         -
                    }
  817         -
    }
  818         -
}
  819         -
impl
  820         -
    ::aws_smithy_http_server::response::IntoResponse<
  821         -
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  822         -
    > for crate::error::HttpPayloadTraits2Error
  823         -
{
  824         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
  825         -
        match crate::protocol_serde::shape_http_payload_traits2::ser_http_payload_traits2_http_error(
  826         -
            &self,
  827         -
        ) {
  828         -
            Ok(mut response) => {
  829         -
                response.extensions_mut().insert(
  830         -
                    ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
  831         -
                );
  832         -
                response
  833         -
            }
  834         -
            Err(e) => {
  835         -
                ::tracing::error!(error = %e, "failed to serialize response");
  836         -
                ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
  837         -
            }
  838         -
        }
  839         -
    }
  840         -
}
  841         -
  842         -
#[allow(unreachable_code, unused_variables)]
  843         -
#[cfg(test)]
  844         -
mod http_payload_traits2_test {
  845         -
  846         -
    /// Servers must accept no content type for blob inputs
  847         -
    /// without the media type trait.
  848         -
    /// Test ID: RestJsonHttpPayloadTraitsWithBlobAcceptsNoContentType
  849         -
    #[::tokio::test]
  850         -
    #[::tracing_test::traced_test]
  851         -
    async fn rest_json_http_payload_traits_with_blob_accepts_no_content_type_request() {
  852         -
        #[allow(unused_mut)]
  853         -
        let mut http_request = http::Request::builder()
  854         -
            .uri("/HttpPayloadTraits")
  855         -
            .method("POST")
  856         -
            .header("X-Foo", "Foo")
  857         -
            .body(::aws_smithy_http_server::body::Body::from(
  858         -
                ::bytes::Bytes::from_static("This is definitely a jpeg".as_bytes()),
  859         -
            ))
  860         -
            .unwrap();
  861         -
        #[allow(unused_mut)]
  862         -
        let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  863         -
        let config = crate::service::RestJsonExtrasConfig::builder().build();
  864         -
        let service =
  865         -
            crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
  866         -
                .http_payload_traits2(move |input: crate::input::HttpPayloadTraits2Input| {
  867         -
                    let sender = sender.clone();
  868         -
                    async move {
  869         -
                        let result = {
  870         -
                            let expected = crate::input::HttpPayloadTraits2Input {
  871         -
                                foo: ::std::option::Option::Some("Foo".to_owned()),
  872         -
                                blob: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
  873         -
                                    "This is definitely a jpeg",
  874         -
                                )),
  875         -
                            };
  876         -
                            ::pretty_assertions::assert_eq!(input, expected);
  877         -
                            let response = crate::output::HttpPayloadTraits2Output {
  878         -
                                foo: ::std::option::Option::None,
  879         -
                                blob: ::std::option::Option::None,
  880         -
                            };
  881         -
                            Ok(response)
  882         -
                        };
  883         -
                        sender.send(()).await.expect("receiver dropped early");
  884         -
                        result
  885         -
                    }
  886         -
                })
  887         -
                .build_unchecked();
  888         -
        let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  889         -
            .await
  890         -
            .expect("unable to make an HTTP request");
  891         -
        assert!(
  892         -
            receiver.recv().await.is_some(),
  893         -
            "we expected operation handler to be invoked but it was not entered"
  894         -
        );
  895         -
    }
  896         -
    /// Upper case error modeled lower case.
  897         -
    /// Test ID: ServiceLevelErrorServer
  898         -
    #[::tokio::test]
  899         -
    #[::tracing_test::traced_test]
  900         -
    async fn service_level_error_server_response() {
  901         -
        let output = crate::error::ExtraError {};
  902         -
        let output = crate::error::HttpPayloadTraits2Error::ExtraError(output);
  903         -
        use ::aws_smithy_http_server::response::IntoResponse;
  904         -
        let http_response = output.into_response();
  905         -
        ::pretty_assertions::assert_eq!(
  906         -
            http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
  907         -
            http_response.status()
  908         -
        );
  909         -
        let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
  910         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  911         -
            http_response.headers(),
  912         -
            expected_headers,
  913         -
        ));
  914         -
        let body = ::hyper::body::to_bytes(http_response.into_body())
  915         -
            .await
  916         -
            .expect("unable to extract body to bytes");
  917         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
  918         -
            &body,
  919         -
            "{}",
  920         -
            ::aws_smithy_protocol_test::MediaType::from("unknown"),
  921         -
        ));
  922         -
    }
  923         -
}
  924         -
  925      2   
const CONTENT_TYPE_QUERYPRECEDENCE: ::mime::Mime = ::mime::APPLICATION_JSON;
  926      3   
::pin_project_lite::pin_project! {
  927      4   
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
  928      5   
    /// [`QueryPrecedenceInput`](crate::input::QueryPrecedenceInput) using modelled bindings.
  929      6   
    pub struct QueryPrecedenceInputFuture {
  930      7   
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::QueryPrecedenceInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
  931      8   
    }
  932      9   
}
  933     10   
  934     11   
impl std::future::Future for QueryPrecedenceInputFuture {