Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,248 @@
           1  +
#![allow(deprecated)]
           2  +
#![allow(unknown_lints)]
           3  +
#![allow(clippy::module_inception)]
           4  +
#![allow(clippy::upper_case_acronyms)]
           5  +
#![allow(clippy::large_enum_variant)]
           6  +
#![allow(clippy::wrong_self_convention)]
           7  +
#![allow(clippy::should_implement_trait)]
           8  +
#![allow(clippy::disallowed_names)]
           9  +
#![allow(clippy::vec_init_then_push)]
          10  +
#![allow(clippy::type_complexity)]
          11  +
#![allow(clippy::needless_return)]
          12  +
#![allow(clippy::derive_partial_eq_without_eq)]
          13  +
#![allow(clippy::result_large_err)]
          14  +
#![allow(clippy::unnecessary_map_on_constructor)]
          15  +
#![allow(clippy::deprecated_semver)]
          16  +
#![allow(clippy::uninlined_format_args)]
          17  +
#![allow(rustdoc::bare_urls)]
          18  +
#![allow(rustdoc::redundant_explicit_links)]
          19  +
#![allow(rustdoc::invalid_html_tags)]
          20  +
#![forbid(unsafe_code)]
          21  +
#![cfg_attr(docsrs, feature(doc_cfg))]
          22  +
//! Confounds model generation machinery with lots of problematic names
          23  +
          24  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
          25  +
//! A fast and customizable Rust implementation of the NamingObstacleCourseStructs Smithy service.
          26  +
//!
          27  +
//! # Using NamingObstacleCourseStructs
          28  +
//!
          29  +
//! The primary entrypoint is [`NamingObstacleCourseStructs`]: it satisfies the [`Service<http::Request, Response = http::Response>`](::tower::Service)
          30  +
//! trait and therefore can be handed to a [`hyper` server](https://github.com/hyperium/hyper) via [`NamingObstacleCourseStructs::into_make_service`]
          31  +
//! or used in AWS Lambda
          32  +
#![cfg_attr(
          33  +
    feature = "aws-lambda",
          34  +
    doc = " via [`LambdaHandler`](crate::server::routing::LambdaHandler)."
          35  +
)]
          36  +
#![cfg_attr(
          37  +
    not(feature = "aws-lambda"),
          38  +
    doc = " by enabling the `aws-lambda` feature flag and utilizing the `LambdaHandler`."
          39  +
)]
          40  +
//! The [`crate::input`], and [`crate::output`],
          41  +
//! modules provide the types used in each operation.
          42  +
//!
          43  +
//! ### Running on Hyper
          44  +
//!
          45  +
//! ```rust,no_run
          46  +
//! # use std::net::SocketAddr;
          47  +
//! # async fn dummy() {
          48  +
//! use naming_test_structs_http0x::{NamingObstacleCourseStructs, NamingObstacleCourseStructsConfig};
          49  +
//!
          50  +
//! # let app = NamingObstacleCourseStructs::builder(
          51  +
//! #     NamingObstacleCourseStructsConfig::builder()
          52  +
//! #         .build()
          53  +
//! # ).build_unchecked();
          54  +
//! let server = app.into_make_service();
          55  +
//! let bind: SocketAddr = "127.0.0.1:6969".parse()
          56  +
//!     .expect("unable to parse the server bind address and port");
          57  +
//! ::hyper::Server::bind(&bind).serve(server).await.unwrap();
          58  +
//! # }
          59  +
//!
          60  +
//! ```
          61  +
//!
          62  +
//! ### Running on Lambda
          63  +
//!
          64  +
//! ```rust,ignore
          65  +
//! use naming_test_structs_http0x::server::routing::LambdaHandler;
          66  +
//! use naming_test_structs_http0x::NamingObstacleCourseStructs;
          67  +
//!
          68  +
//! # async fn dummy() {
          69  +
//! # let app = NamingObstacleCourseStructs::builder(
          70  +
//! #     NamingObstacleCourseStructsConfig::builder()
          71  +
//! #         .build()
          72  +
//! # ).build_unchecked();
          73  +
//! let handler = LambdaHandler::new(app);
          74  +
//! lambda_http::run(handler).await.unwrap();
          75  +
//! # }
          76  +
//! ```
          77  +
//!
          78  +
//! # Building the NamingObstacleCourseStructs
          79  +
//!
          80  +
//! To construct [`NamingObstacleCourseStructs`] we use [`NamingObstacleCourseStructsBuilder`] returned by [`NamingObstacleCourseStructs::builder`].
          81  +
//!
          82  +
//! ## Plugins
          83  +
//!
          84  +
//! The [`NamingObstacleCourseStructs::builder`] method, returning [`NamingObstacleCourseStructsBuilder`],
          85  +
//! accepts a config object on which plugins can be registered.
          86  +
//! Plugins allow you to build middleware which is aware of the operation it is being applied to.
          87  +
//!
          88  +
//! ```rust,no_run
          89  +
//! # use naming_test_structs_http0x::server::plugin::IdentityPlugin as LoggingPlugin;
          90  +
//! # use naming_test_structs_http0x::server::plugin::IdentityPlugin as MetricsPlugin;
          91  +
//! # use ::hyper::Body;
          92  +
//! use naming_test_structs_http0x::server::plugin::HttpPlugins;
          93  +
//! use naming_test_structs_http0x::{NamingObstacleCourseStructs, NamingObstacleCourseStructsConfig, NamingObstacleCourseStructsBuilder};
          94  +
//!
          95  +
//! let http_plugins = HttpPlugins::new()
          96  +
//!         .push(LoggingPlugin)
          97  +
//!         .push(MetricsPlugin);
          98  +
//! let config = NamingObstacleCourseStructsConfig::builder().build();
          99  +
//! let builder: NamingObstacleCourseStructsBuilder<::hyper::Body, _, _, _> = NamingObstacleCourseStructs::builder(config);
         100  +
//! ```
         101  +
//!
         102  +
//! Check out [`crate::server::plugin`] to learn more about plugins.
         103  +
//!
         104  +
//! ## Handlers
         105  +
//!
         106  +
//! [`NamingObstacleCourseStructsBuilder`] provides a setter method for each operation in your Smithy model. The setter methods expect an async function as input, matching the signature for the corresponding operation in your Smithy model.
         107  +
//! We call these async functions **handlers**. This is where your application business logic lives.
         108  +
//!
         109  +
//! Every handler must take an `Input`, and optional [`extractor arguments`](crate::server::request), while returning:
         110  +
//!
         111  +
//! * A `Result<Output, Error>` if your operation has modeled errors, or
         112  +
//! * An `Output` otherwise.
         113  +
//!
         114  +
//! ```rust,no_run
         115  +
//! # struct Input;
         116  +
//! # struct Output;
         117  +
//! # struct Error;
         118  +
//! async fn infallible_handler(input: Input) -> Output { todo!() }
         119  +
//!
         120  +
//! async fn fallible_handler(input: Input) -> Result<Output, Error> { todo!() }
         121  +
//! ```
         122  +
//!
         123  +
//! Handlers can accept up to 8 extractors:
         124  +
//!
         125  +
//! ```rust,no_run
         126  +
//! # struct Input;
         127  +
//! # struct Output;
         128  +
//! # struct Error;
         129  +
//! # struct State;
         130  +
//! # use std::net::SocketAddr;
         131  +
//! use naming_test_structs_http0x::server::request::{extension::Extension, connect_info::ConnectInfo};
         132  +
//!
         133  +
//! async fn handler_with_no_extensions(input: Input) -> Output {
         134  +
//!     todo!()
         135  +
//! }
         136  +
//!
         137  +
//! async fn handler_with_one_extractor(input: Input, ext: Extension<State>) -> Output {
         138  +
//!     todo!()
         139  +
//! }
         140  +
//!
         141  +
//! async fn handler_with_two_extractors(
         142  +
//!     input: Input,
         143  +
//!     ext0: Extension<State>,
         144  +
//!     ext1: ConnectInfo<SocketAddr>,
         145  +
//! ) -> Output {
         146  +
//!     todo!()
         147  +
//! }
         148  +
//! ```
         149  +
//!
         150  +
//! See the [`operation module`](crate::operation) for information on precisely what constitutes a handler.
         151  +
//!
         152  +
//! ## Build
         153  +
//!
         154  +
//! You can convert [`NamingObstacleCourseStructsBuilder`] into [`NamingObstacleCourseStructs`] using either [`NamingObstacleCourseStructsBuilder::build`] or [`NamingObstacleCourseStructsBuilder::build_unchecked`].
         155  +
//!
         156  +
//! [`NamingObstacleCourseStructsBuilder::build`] requires you to provide a handler for every single operation in your Smithy model. It will return an error if that is not the case.
         157  +
//!
         158  +
//! [`NamingObstacleCourseStructsBuilder::build_unchecked`], instead, does not require exhaustiveness. The server will automatically return 500 Internal Server Error to all requests for operations that do not have a registered handler.
         159  +
//! [`NamingObstacleCourseStructsBuilder::build_unchecked`] is particularly useful if you are deploying your Smithy service as a collection of Lambda functions, where each Lambda is only responsible for a subset of the operations in the Smithy service (or even a single one!).
         160  +
//!
         161  +
//! # Example
         162  +
//!
         163  +
//! ```rust,no_run
         164  +
//! # use std::net::SocketAddr;
         165  +
//! use naming_test_structs_http0x::{NamingObstacleCourseStructs, NamingObstacleCourseStructsConfig};
         166  +
//!
         167  +
//! #[::tokio::main]
         168  +
//! pub async fn main() {
         169  +
//!    let config = NamingObstacleCourseStructsConfig::builder().build();
         170  +
//!    let app = NamingObstacleCourseStructs::builder(config)
         171  +
//!        .structs(structs)
         172  +
//!        .build()
         173  +
//!        .expect("failed to build an instance of NamingObstacleCourseStructs");
         174  +
//!
         175  +
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
         176  +
//!        .expect("unable to parse the server bind address and port");
         177  +
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
         178  +
//!    # let server = async { Ok::<_, ()>(()) };
         179  +
//!
         180  +
//!    // Run your service!
         181  +
//!    if let Err(err) = server.await {
         182  +
//!        eprintln!("server error: {:?}", err);
         183  +
//!    }
         184  +
//! }
         185  +
//!
         186  +
//! use naming_test_structs_http0x::{input, output};
         187  +
//!
         188  +
//! async fn structs(input: input::StructsInput) -> output::StructsOutput {
         189  +
//!     todo!()
         190  +
//! }
         191  +
//!
         192  +
//! ```
         193  +
//!
         194  +
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
         195  +
//! [hyper server]: https://docs.rs/hyper/0.14.26/hyper/server/index.html
         196  +
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
         197  +
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
         198  +
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
         199  +
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         200  +
pub use crate::service::{
         201  +
    MissingOperationsError, NamingObstacleCourseStructs, NamingObstacleCourseStructsBuilder,
         202  +
    NamingObstacleCourseStructsConfig, NamingObstacleCourseStructsConfigBuilder,
         203  +
};
         204  +
         205  +
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
         206  +
pub mod server {
         207  +
    // Re-export all types from the `aws-smithy-http-server` crate.
         208  +
    pub use ::aws_smithy_legacy_http_server::*;
         209  +
}
         210  +
         211  +
/// Crate version number.
         212  +
pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
         213  +
         214  +
/// All error types that operations can return. Documentation on these types is copied from the model.
         215  +
pub mod error;
         216  +
         217  +
/// Input structures for operations. Documentation on these types is copied from the model.
         218  +
pub mod input;
         219  +
         220  +
/// Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
         221  +
pub mod model;
         222  +
         223  +
/// All operations that this crate can perform.
         224  +
pub mod operation;
         225  +
         226  +
/// A collection of types representing each operation defined in the service closure.
         227  +
///
         228  +
/// The [plugin system](::aws_smithy_legacy_http_server::plugin) makes use of these
         229  +
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
         230  +
/// parameterize [`Plugin`](::aws_smithy_legacy_http_server::plugin::Plugin) implementations. Their traits, such as
         231  +
/// [`OperationShape`](::aws_smithy_legacy_http_server::operation::OperationShape), can be used to provide
         232  +
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
         233  +
pub mod operation_shape;
         234  +
         235  +
/// Output structures for operations. Documentation on these types is copied from the model.
         236  +
pub mod output;
         237  +
         238  +
mod service;
         239  +
         240  +
/// Data primitives referenced by other data types.
         241  +
pub mod types;
         242  +
         243  +
/// Constrained types for constrained shapes.
         244  +
mod constrained;
         245  +
         246  +
mod mimes;
         247  +
         248  +
pub(crate) mod protocol_serde;

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/mimes.rs

@@ -0,1 +0,7 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) static CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1: std::sync::LazyLock<::mime::Mime> =
           3  +
    std::sync::LazyLock::new(|| {
           4  +
        "application/x-amz-json-1.1"
           5  +
            .parse::<::mime::Mime>()
           6  +
            .expect("BUG: MIME parsing failed, content_type is not valid")
           7  +
    });

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

@@ -0,1 +0,311 @@
           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 SomethingElse {
           7  +
    #[allow(missing_docs)] // documentation missing in model
           8  +
    pub result: ::std::option::Option<crate::model::Result>,
           9  +
    #[allow(missing_docs)] // documentation missing in model
          10  +
    pub result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          11  +
    #[allow(missing_docs)] // documentation missing in model
          12  +
    pub option: ::std::option::Option<crate::model::Option>,
          13  +
    #[allow(missing_docs)] // documentation missing in model
          14  +
    pub option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          15  +
    #[allow(missing_docs)] // documentation missing in model
          16  +
    pub some_union: ::std::option::Option<crate::model::SomeUnion>,
          17  +
}
          18  +
impl SomethingElse {
          19  +
    #[allow(missing_docs)] // documentation missing in model
          20  +
    pub fn result(&self) -> ::std::option::Option<&crate::model::Result> {
          21  +
        self.result.as_ref()
          22  +
    }
          23  +
    #[allow(missing_docs)] // documentation missing in model
          24  +
    pub fn result_list(&self) -> ::std::option::Option<&[crate::model::Result]> {
          25  +
        self.result_list.as_deref()
          26  +
    }
          27  +
    #[allow(missing_docs)] // documentation missing in model
          28  +
    pub fn option(&self) -> ::std::option::Option<&crate::model::Option> {
          29  +
        self.option.as_ref()
          30  +
    }
          31  +
    #[allow(missing_docs)] // documentation missing in model
          32  +
    pub fn option_list(&self) -> ::std::option::Option<&[crate::model::Result]> {
          33  +
        self.option_list.as_deref()
          34  +
    }
          35  +
    #[allow(missing_docs)] // documentation missing in model
          36  +
    pub fn some_union(&self) -> ::std::option::Option<&crate::model::SomeUnion> {
          37  +
        self.some_union.as_ref()
          38  +
    }
          39  +
}
          40  +
impl SomethingElse {
          41  +
    /// Creates a new builder-style object to manufacture [`SomethingElse`](crate::model::SomethingElse).
          42  +
    pub fn builder() -> crate::model::something_else::Builder {
          43  +
        crate::model::something_else::Builder::default()
          44  +
    }
          45  +
}
          46  +
impl crate::constrained::Constrained for crate::model::SomethingElse {
          47  +
    type Unconstrained = crate::model::something_else::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 enum SomeUnion {
          55  +
    #[allow(missing_docs)] // documentation missing in model
          56  +
    Option(crate::model::Option),
          57  +
    #[allow(missing_docs)] // documentation missing in model
          58  +
    Result(crate::model::Result),
          59  +
}
          60  +
impl SomeUnion {
          61  +
    /// Tries to convert the enum instance into [`Option`](crate::model::SomeUnion::Option), extracting the inner [`Option`](crate::model::Option).
          62  +
    /// Returns `Err(&Self)` if it can't be converted.
          63  +
    pub fn as_option(&self) -> ::std::result::Result<&crate::model::Option, &Self> {
          64  +
        if let SomeUnion::Option(val) = &self {
          65  +
            ::std::result::Result::Ok(val)
          66  +
        } else {
          67  +
            ::std::result::Result::Err(self)
          68  +
        }
          69  +
    }
          70  +
    /// Returns true if this is a [`Option`](crate::model::SomeUnion::Option).
          71  +
    pub fn is_option(&self) -> bool {
          72  +
        self.as_option().is_ok()
          73  +
    }
          74  +
    /// Tries to convert the enum instance into [`Result`](crate::model::SomeUnion::Result), extracting the inner [`Result`](crate::model::Result).
          75  +
    /// Returns `Err(&Self)` if it can't be converted.
          76  +
    pub fn as_result(&self) -> ::std::result::Result<&crate::model::Result, &Self> {
          77  +
        if let SomeUnion::Result(val) = &self {
          78  +
            ::std::result::Result::Ok(val)
          79  +
        } else {
          80  +
            ::std::result::Result::Err(self)
          81  +
        }
          82  +
    }
          83  +
    /// Returns true if this is a [`Result`](crate::model::SomeUnion::Result).
          84  +
    pub fn is_result(&self) -> bool {
          85  +
        self.as_result().is_ok()
          86  +
    }
          87  +
}
          88  +
          89  +
#[allow(missing_docs)] // documentation missing in model
          90  +
#[derive(
          91  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          92  +
)]
          93  +
pub struct Option {
          94  +
    #[allow(missing_docs)] // documentation missing in model
          95  +
    pub value: ::std::option::Option<::std::string::String>,
          96  +
}
          97  +
impl Option {
          98  +
    #[allow(missing_docs)] // documentation missing in model
          99  +
    pub fn value(&self) -> ::std::option::Option<&str> {
         100  +
        self.value.as_deref()
         101  +
    }
         102  +
}
         103  +
impl Option {
         104  +
    /// Creates a new builder-style object to manufacture [`Option`](crate::model::Option).
         105  +
    pub fn builder() -> crate::model::option::Builder {
         106  +
        crate::model::option::Builder::default()
         107  +
    }
         108  +
}
         109  +
impl crate::constrained::Constrained for crate::model::Option {
         110  +
    type Unconstrained = crate::model::option::Builder;
         111  +
}
         112  +
         113  +
#[allow(missing_docs)] // documentation missing in model
         114  +
#[derive(
         115  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         116  +
)]
         117  +
pub struct Result {
         118  +
    #[allow(missing_docs)] // documentation missing in model
         119  +
    pub value: ::std::option::Option<::std::string::String>,
         120  +
}
         121  +
impl Result {
         122  +
    #[allow(missing_docs)] // documentation missing in model
         123  +
    pub fn value(&self) -> ::std::option::Option<&str> {
         124  +
        self.value.as_deref()
         125  +
    }
         126  +
}
         127  +
impl Result {
         128  +
    /// Creates a new builder-style object to manufacture [`Result`](crate::model::Result).
         129  +
    pub fn builder() -> crate::model::result::Builder {
         130  +
        crate::model::result::Builder::default()
         131  +
    }
         132  +
}
         133  +
impl crate::constrained::Constrained for crate::model::Result {
         134  +
    type Unconstrained = crate::model::result::Builder;
         135  +
}
         136  +
/// See [`SomethingElse`](crate::model::SomethingElse).
         137  +
pub mod something_else {
         138  +
         139  +
    impl ::std::convert::From<Builder> for crate::model::SomethingElse {
         140  +
        fn from(builder: Builder) -> Self {
         141  +
            builder.build()
         142  +
        }
         143  +
    }
         144  +
    /// A builder for [`SomethingElse`](crate::model::SomethingElse).
         145  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         146  +
    pub struct Builder {
         147  +
        pub(crate) result: ::std::option::Option<crate::model::Result>,
         148  +
        pub(crate) result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         149  +
        pub(crate) option: ::std::option::Option<crate::model::Option>,
         150  +
        pub(crate) option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         151  +
        pub(crate) some_union: ::std::option::Option<crate::model::SomeUnion>,
         152  +
    }
         153  +
    impl Builder {
         154  +
        #[allow(missing_docs)] // documentation missing in model
         155  +
        pub fn result(mut self, input: ::std::option::Option<crate::model::Result>) -> Self {
         156  +
            self.result = input;
         157  +
            self
         158  +
        }
         159  +
        #[allow(missing_docs)] // documentation missing in model
         160  +
        pub(crate) fn set_result(
         161  +
            mut self,
         162  +
            input: Option<impl ::std::convert::Into<crate::model::Result>>,
         163  +
        ) -> Self {
         164  +
            self.result = input.map(|v| v.into());
         165  +
            self
         166  +
        }
         167  +
        #[allow(missing_docs)] // documentation missing in model
         168  +
        pub fn result_list(
         169  +
            mut self,
         170  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         171  +
        ) -> Self {
         172  +
            self.result_list = input;
         173  +
            self
         174  +
        }
         175  +
        #[allow(missing_docs)] // documentation missing in model
         176  +
        pub(crate) fn set_result_list(
         177  +
            mut self,
         178  +
            input: Option<impl ::std::convert::Into<::std::vec::Vec<crate::model::Result>>>,
         179  +
        ) -> Self {
         180  +
            self.result_list = input.map(|v| v.into());
         181  +
            self
         182  +
        }
         183  +
        #[allow(missing_docs)] // documentation missing in model
         184  +
        pub fn option(mut self, input: ::std::option::Option<crate::model::Option>) -> Self {
         185  +
            self.option = input;
         186  +
            self
         187  +
        }
         188  +
        #[allow(missing_docs)] // documentation missing in model
         189  +
        pub(crate) fn set_option(
         190  +
            mut self,
         191  +
            input: Option<impl ::std::convert::Into<crate::model::Option>>,
         192  +
        ) -> Self {
         193  +
            self.option = input.map(|v| v.into());
         194  +
            self
         195  +
        }
         196  +
        #[allow(missing_docs)] // documentation missing in model
         197  +
        pub fn option_list(
         198  +
            mut self,
         199  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         200  +
        ) -> Self {
         201  +
            self.option_list = input;
         202  +
            self
         203  +
        }
         204  +
        #[allow(missing_docs)] // documentation missing in model
         205  +
        pub(crate) fn set_option_list(
         206  +
            mut self,
         207  +
            input: Option<impl ::std::convert::Into<::std::vec::Vec<crate::model::Result>>>,
         208  +
        ) -> Self {
         209  +
            self.option_list = input.map(|v| v.into());
         210  +
            self
         211  +
        }
         212  +
        #[allow(missing_docs)] // documentation missing in model
         213  +
        pub fn some_union(mut self, input: ::std::option::Option<crate::model::SomeUnion>) -> Self {
         214  +
            self.some_union = input;
         215  +
            self
         216  +
        }
         217  +
        #[allow(missing_docs)] // documentation missing in model
         218  +
        pub(crate) fn set_some_union(
         219  +
            mut self,
         220  +
            input: Option<impl ::std::convert::Into<crate::model::SomeUnion>>,
         221  +
        ) -> Self {
         222  +
            self.some_union = input.map(|v| v.into());
         223  +
            self
         224  +
        }
         225  +
        /// Consumes the builder and constructs a [`SomethingElse`](crate::model::SomethingElse).
         226  +
        pub fn build(self) -> crate::model::SomethingElse {
         227  +
            self.build_enforcing_all_constraints()
         228  +
        }
         229  +
        fn build_enforcing_all_constraints(self) -> crate::model::SomethingElse {
         230  +
            crate::model::SomethingElse {
         231  +
                result: self.result,
         232  +
                result_list: self.result_list,
         233  +
                option: self.option,
         234  +
                option_list: self.option_list,
         235  +
                some_union: self.some_union,
         236  +
            }
         237  +
        }
         238  +
    }
         239  +
}
         240  +
/// See [`Option`](crate::model::Option).
         241  +
pub mod option {
         242  +
         243  +
    impl ::std::convert::From<Builder> for crate::model::Option {
         244  +
        fn from(builder: Builder) -> Self {
         245  +
            builder.build()
         246  +
        }
         247  +
    }
         248  +
    /// A builder for [`Option`](crate::model::Option).
         249  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         250  +
    pub struct Builder {
         251  +
        pub(crate) value: ::std::option::Option<::std::string::String>,
         252  +
    }
         253  +
    impl Builder {
         254  +
        #[allow(missing_docs)] // documentation missing in model
         255  +
        pub fn value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         256  +
            self.value = input;
         257  +
            self
         258  +
        }
         259  +
        #[allow(missing_docs)] // documentation missing in model
         260  +
        pub(crate) fn set_value(
         261  +
            mut self,
         262  +
            input: Option<impl ::std::convert::Into<::std::string::String>>,
         263  +
        ) -> Self {
         264  +
            self.value = input.map(|v| v.into());
         265  +
            self
         266  +
        }
         267  +
        /// Consumes the builder and constructs a [`Option`](crate::model::Option).
         268  +
        pub fn build(self) -> crate::model::Option {
         269  +
            self.build_enforcing_all_constraints()
         270  +
        }
         271  +
        fn build_enforcing_all_constraints(self) -> crate::model::Option {
         272  +
            crate::model::Option { value: self.value }
         273  +
        }
         274  +
    }
         275  +
}
         276  +
/// See [`Result`](crate::model::Result).
         277  +
pub mod result {
         278  +
         279  +
    impl ::std::convert::From<Builder> for crate::model::Result {
         280  +
        fn from(builder: Builder) -> Self {
         281  +
            builder.build()
         282  +
        }
         283  +
    }
         284  +
    /// A builder for [`Result`](crate::model::Result).
         285  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         286  +
    pub struct Builder {
         287  +
        pub(crate) value: ::std::option::Option<::std::string::String>,
         288  +
    }
         289  +
    impl Builder {
         290  +
        #[allow(missing_docs)] // documentation missing in model
         291  +
        pub fn value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         292  +
            self.value = input;
         293  +
            self
         294  +
        }
         295  +
        #[allow(missing_docs)] // documentation missing in model
         296  +
        pub(crate) fn set_value(
         297  +
            mut self,
         298  +
            input: Option<impl ::std::convert::Into<::std::string::String>>,
         299  +
        ) -> Self {
         300  +
            self.value = input.map(|v| v.into());
         301  +
            self
         302  +
        }
         303  +
        /// Consumes the builder and constructs a [`Result`](crate::model::Result).
         304  +
        pub fn build(self) -> crate::model::Result {
         305  +
            self.build_enforcing_all_constraints()
         306  +
        }
         307  +
        fn build_enforcing_all_constraints(self) -> crate::model::Result {
         308  +
            crate::model::Result { value: self.value }
         309  +
        }
         310  +
    }
         311  +
}

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

@@ -0,1 +0,76 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
::pin_project_lite::pin_project! {
           3  +
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
           4  +
    /// [`StructsInput`](crate::input::StructsInput) using modelled bindings.
           5  +
    pub struct StructsInputFuture {
           6  +
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StructsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
           7  +
    }
           8  +
}
           9  +
          10  +
impl std::future::Future for StructsInputFuture {
          11  +
    type Output = Result<
          12  +
        crate::input::StructsInput,
          13  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
          14  +
    >;
          15  +
          16  +
    fn poll(
          17  +
        self: std::pin::Pin<&mut Self>,
          18  +
        cx: &mut std::task::Context<'_>,
          19  +
    ) -> std::task::Poll<Self::Output> {
          20  +
        let this = self.project();
          21  +
        this.inner.as_mut().poll(cx)
          22  +
    }
          23  +
}
          24  +
          25  +
impl<B>
          26  +
    ::aws_smithy_legacy_http_server::request::FromRequest<
          27  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
          28  +
        B,
          29  +
    > for crate::input::StructsInput
          30  +
where
          31  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          32  +
    B: 'static,
          33  +
          34  +
    B::Data: Send,
          35  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          36  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          37  +
{
          38  +
    type Rejection =
          39  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
          40  +
    type Future = StructsInputFuture;
          41  +
          42  +
    fn from_request(request: ::http::Request<B>) -> Self::Future {
          43  +
        let fut = async move {
          44  +
            if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
          45  +
                request.headers(),
          46  +
                &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
          47  +
            ) {
          48  +
                return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
          49  +
            }
          50  +
            crate::protocol_serde::shape_structs::de_structs_http_request(request).await
          51  +
        };
          52  +
        use ::futures_util::future::TryFutureExt;
          53  +
        let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
          54  +
                        ::tracing::debug!(error = %e, "failed to deserialize request");
          55  +
                        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
          56  +
                    });
          57  +
        StructsInputFuture {
          58  +
            inner: Box::pin(fut),
          59  +
        }
          60  +
    }
          61  +
}
          62  +
impl
          63  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
          64  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
          65  +
    > for crate::output::StructsOutput
          66  +
{
          67  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
          68  +
        match crate::protocol_serde::shape_structs::ser_structs_http_response(self) {
          69  +
            Ok(response) => response,
          70  +
            Err(e) => {
          71  +
                ::tracing::error!(error = %e, "failed to serialize response");
          72  +
                ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
          73  +
            }
          74  +
        }
          75  +
    }
          76  +
}

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/operation_shape.rs

@@ -0,1 +0,31 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
pub struct Structs;
           4  +
           5  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for Structs {
           6  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
           7  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
           8  +
            "naming_obs_structs#Structs",
           9  +
            "naming_obs_structs",
          10  +
            "Structs",
          11  +
        );
          12  +
          13  +
    type Input = crate::input::StructsInput;
          14  +
    type Output = crate::output::StructsOutput;
          15  +
    type Error = std::convert::Infallible;
          16  +
}
          17  +
          18  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity for Structs {
          19  +
    type RequestFmt =
          20  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::DefaultRequestFmt;
          21  +
    type ResponseFmt =
          22  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::DefaultResponseFmt;
          23  +
          24  +
    fn request_fmt() -> Self::RequestFmt {
          25  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
          26  +
    }
          27  +
          28  +
    fn response_fmt() -> Self::ResponseFmt {
          29  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
          30  +
    }
          31  +
}

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/output.rs

@@ -0,1 +0,112 @@
           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 StructsOutput {
           7  +
    #[allow(missing_docs)] // documentation missing in model
           8  +
    pub result: ::std::option::Option<crate::model::Result>,
           9  +
    #[allow(missing_docs)] // documentation missing in model
          10  +
    pub result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          11  +
    #[allow(missing_docs)] // documentation missing in model
          12  +
    pub option: ::std::option::Option<crate::model::Option>,
          13  +
    #[allow(missing_docs)] // documentation missing in model
          14  +
    pub option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          15  +
    #[allow(missing_docs)] // documentation missing in model
          16  +
    pub something_else: ::std::option::Option<crate::model::SomethingElse>,
          17  +
}
          18  +
impl StructsOutput {
          19  +
    #[allow(missing_docs)] // documentation missing in model
          20  +
    pub fn result(&self) -> ::std::option::Option<&crate::model::Result> {
          21  +
        self.result.as_ref()
          22  +
    }
          23  +
    #[allow(missing_docs)] // documentation missing in model
          24  +
    pub fn result_list(&self) -> ::std::option::Option<&[crate::model::Result]> {
          25  +
        self.result_list.as_deref()
          26  +
    }
          27  +
    #[allow(missing_docs)] // documentation missing in model
          28  +
    pub fn option(&self) -> ::std::option::Option<&crate::model::Option> {
          29  +
        self.option.as_ref()
          30  +
    }
          31  +
    #[allow(missing_docs)] // documentation missing in model
          32  +
    pub fn option_list(&self) -> ::std::option::Option<&[crate::model::Result]> {
          33  +
        self.option_list.as_deref()
          34  +
    }
          35  +
    #[allow(missing_docs)] // documentation missing in model
          36  +
    pub fn something_else(&self) -> ::std::option::Option<&crate::model::SomethingElse> {
          37  +
        self.something_else.as_ref()
          38  +
    }
          39  +
}
          40  +
impl StructsOutput {
          41  +
    /// Creates a new builder-style object to manufacture [`StructsOutput`](crate::output::StructsOutput).
          42  +
    pub fn builder() -> crate::output::structs_output::Builder {
          43  +
        crate::output::structs_output::Builder::default()
          44  +
    }
          45  +
}
          46  +
/// See [`StructsOutput`](crate::output::StructsOutput).
          47  +
pub mod structs_output {
          48  +
          49  +
    impl ::std::convert::From<Builder> for crate::output::StructsOutput {
          50  +
        fn from(builder: Builder) -> Self {
          51  +
            builder.build()
          52  +
        }
          53  +
    }
          54  +
    /// A builder for [`StructsOutput`](crate::output::StructsOutput).
          55  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          56  +
    pub struct Builder {
          57  +
        pub(crate) result: ::std::option::Option<crate::model::Result>,
          58  +
        pub(crate) result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          59  +
        pub(crate) option: ::std::option::Option<crate::model::Option>,
          60  +
        pub(crate) option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          61  +
        pub(crate) something_else: ::std::option::Option<crate::model::SomethingElse>,
          62  +
    }
          63  +
    impl Builder {
          64  +
        #[allow(missing_docs)] // documentation missing in model
          65  +
        pub fn result(mut self, input: ::std::option::Option<crate::model::Result>) -> Self {
          66  +
            self.result = input;
          67  +
            self
          68  +
        }
          69  +
        #[allow(missing_docs)] // documentation missing in model
          70  +
        pub fn result_list(
          71  +
            mut self,
          72  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          73  +
        ) -> Self {
          74  +
            self.result_list = input;
          75  +
            self
          76  +
        }
          77  +
        #[allow(missing_docs)] // documentation missing in model
          78  +
        pub fn option(mut self, input: ::std::option::Option<crate::model::Option>) -> Self {
          79  +
            self.option = input;
          80  +
            self
          81  +
        }
          82  +
        #[allow(missing_docs)] // documentation missing in model
          83  +
        pub fn option_list(
          84  +
            mut self,
          85  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          86  +
        ) -> Self {
          87  +
            self.option_list = input;
          88  +
            self
          89  +
        }
          90  +
        #[allow(missing_docs)] // documentation missing in model
          91  +
        pub fn something_else(
          92  +
            mut self,
          93  +
            input: ::std::option::Option<crate::model::SomethingElse>,
          94  +
        ) -> Self {
          95  +
            self.something_else = input;
          96  +
            self
          97  +
        }
          98  +
        /// Consumes the builder and constructs a [`StructsOutput`](crate::output::StructsOutput).
          99  +
        pub fn build(self) -> crate::output::StructsOutput {
         100  +
            self.build_enforcing_all_constraints()
         101  +
        }
         102  +
        fn build_enforcing_all_constraints(self) -> crate::output::StructsOutput {
         103  +
            crate::output::StructsOutput {
         104  +
                result: self.result,
         105  +
                result_list: self.result_list,
         106  +
                option: self.option,
         107  +
                option_list: self.option_list,
         108  +
                something_else: self.something_else,
         109  +
            }
         110  +
        }
         111  +
    }
         112  +
}

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

@@ -0,1 +0,24 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) mod shape_structs;
           3  +
           4  +
pub(crate) fn or_empty_doc(data: &[u8]) -> &[u8] {
           5  +
    if data.is_empty() {
           6  +
        b"{}"
           7  +
    } else {
           8  +
        data
           9  +
    }
          10  +
}
          11  +
          12  +
pub(crate) mod shape_structs_output;
          13  +
          14  +
pub(crate) mod shape_option;
          15  +
          16  +
pub(crate) mod shape_option_list;
          17  +
          18  +
pub(crate) mod shape_result;
          19  +
          20  +
pub(crate) mod shape_result_list;
          21  +
          22  +
pub(crate) mod shape_something_else;
          23  +
          24  +
pub(crate) mod shape_some_union;

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/protocol_serde/shape_option.rs

@@ -0,1 +0,65 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_option<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::Option>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    match tokens.next().transpose()? {
          17  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          18  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          19  +
            #[allow(unused_mut)]
          20  +
            let mut builder = crate::model::option::Builder::default();
          21  +
            loop {
          22  +
                match tokens.next().transpose()? {
          23  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          24  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          25  +
                        match key.to_unescaped()?.as_ref() {
          26  +
                            "value" => {
          27  +
                                builder = builder.set_value(
          28  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
          29  +
                                        tokens.next(),
          30  +
                                    )?
          31  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          32  +
                                    .transpose()?,
          33  +
                                );
          34  +
                            }
          35  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          36  +
                        }
          37  +
                    }
          38  +
                    other => {
          39  +
                        return Err(
          40  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          41  +
                                format!("expected object key or end object, found: {other:?}"),
          42  +
                            ),
          43  +
                        )
          44  +
                    }
          45  +
                }
          46  +
            }
          47  +
            Ok(Some(builder.build()))
          48  +
        }
          49  +
        _ => Err(
          50  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                "expected start object or null",
          52  +
            ),
          53  +
        ),
          54  +
    }
          55  +
}
          56  +
          57  +
pub fn ser_option(
          58  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          59  +
    input: &crate::model::Option,
          60  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          61  +
    if let Some(var_1) = &input.value {
          62  +
        object.key("value").string(var_1.as_str());
          63  +
    }
          64  +
    Ok(())
          65  +
}

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/protocol_serde/shape_option_list.rs

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

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/protocol_serde/shape_result.rs

@@ -0,1 +0,65 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_result<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::Result>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    match tokens.next().transpose()? {
          17  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          18  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          19  +
            #[allow(unused_mut)]
          20  +
            let mut builder = crate::model::result::Builder::default();
          21  +
            loop {
          22  +
                match tokens.next().transpose()? {
          23  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          24  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          25  +
                        match key.to_unescaped()?.as_ref() {
          26  +
                            "value" => {
          27  +
                                builder = builder.set_value(
          28  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
          29  +
                                        tokens.next(),
          30  +
                                    )?
          31  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          32  +
                                    .transpose()?,
          33  +
                                );
          34  +
                            }
          35  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          36  +
                        }
          37  +
                    }
          38  +
                    other => {
          39  +
                        return Err(
          40  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          41  +
                                format!("expected object key or end object, found: {other:?}"),
          42  +
                            ),
          43  +
                        )
          44  +
                    }
          45  +
                }
          46  +
            }
          47  +
            Ok(Some(builder.build()))
          48  +
        }
          49  +
        _ => Err(
          50  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                "expected start object or null",
          52  +
            ),
          53  +
        ),
          54  +
    }
          55  +
}
          56  +
          57  +
pub fn ser_result(
          58  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          59  +
    input: &crate::model::Result,
          60  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          61  +
    if let Some(var_1) = &input.value {
          62  +
        object.key("value").string(var_1.as_str());
          63  +
    }
          64  +
    Ok(())
          65  +
}

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/protocol_serde/shape_result_list.rs

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