From f2053d52a2676923d7cd24efbd9a68ddc9b212b8 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Thu, 12 Sep 2024 07:03:58 -0700 Subject: [PATCH] feat: Positional support on rust (#579) Follows #410 in keeping the same input builder style on the Rust side for positional input structures. Also removes the checked in but generated code from Constructor and Resource since it changes slightly. --- .../Constructor/runtimes/rust/src/client.rs | 38 -- .../rust/src/client/get_constructor.rs | 20 - .../runtimes/rust/src/conversions.rs | 10 - .../runtimes/rust/src/conversions/client.rs | 24 -- .../runtimes/rust/src/conversions/error.rs | 66 ---- .../rust/src/conversions/get_constructor.rs | 8 - .../get_constructor/_get_constructor_input.rs | 24 -- .../_get_constructor_output.rs | 34 -- .../conversions/simple_constructor_config.rs | 4 - .../_simple_constructor_config.rs | 52 --- .../Constructor/runtimes/rust/src/error.rs | 16 - .../rust/src/error/sealed_unhandled.rs | 32 -- .../runtimes/rust/src/operation.rs | 5 - .../rust/src/operation/get_constructor.rs | 49 --- .../get_constructor/_get_constructor_input.rs | 58 --- .../_get_constructor_output.rs | 168 -------- .../src/operation/get_constructor/builders.rs | 75 ---- .../rust/src/standard_library_conversions.rs | 266 ------------- .../rust/src/standard_library_externs.rs | 80 ---- .../Constructor/runtimes/rust/src/types.rs | 16 - .../runtimes/rust/src/types/error.rs | 24 -- .../src/types/simple_constructor_config.rs | 146 ------- .../Constructor/runtimes/rust/src/wrapped.rs | 15 - .../runtimes/rust/src/wrapped/client.rs | 88 ----- TestModels/Positional/Makefile | 2 +- .../Positional/runtimes/rust/src/client.rs | 12 +- .../runtimes/rust/src/client/get_resource.rs | 14 +- .../src/client/get_resource_positional.rs | 19 +- .../runtimes/rust/src/conversions.rs | 20 +- .../runtimes/rust/src/conversions/client.rs | 4 +- .../runtimes/rust/src/conversions/error.rs | 84 ++-- .../runtimes/rust/src/conversions/get_name.rs | 36 +- .../conversions/get_name/_get_name_input.rs | 2 + .../conversions/get_name/_get_name_output.rs | 4 +- .../rust/src/conversions/get_resource.rs | 36 +- .../get_resource/_get_resource_input.rs | 25 +- .../conversions/get_resource_positional.rs | 34 +- .../_get_resource_positional_input.rs | 29 -- .../conversions/simple_positional_config.rs | 5 +- .../_simple_positional_config.rs | 37 +- .../rust/src/conversions/simple_resource.rs | 6 +- .../Positional/runtimes/rust/src/error.rs | 4 +- .../rust/src/error/sealed_unhandled.rs | 6 +- .../Positional/runtimes/rust/src/lib.rs | 22 -- .../Positional/runtimes/rust/src/operation.rs | 9 +- .../runtimes/rust/src/operation/get_name.rs | 100 +---- .../src/operation/get_name/_get_name_input.rs | 5 + .../operation/get_name/_get_name_output.rs | 4 +- .../rust/src/operation/get_name/builders.rs | 18 +- .../rust/src/operation/get_resource.rs | 116 +----- .../get_resource/_get_resource_input.rs | 45 +-- .../get_resource/_get_resource_output.rs | 6 +- .../src/operation/get_resource/builders.rs | 65 ++-- .../src/operation/get_resource_positional.rs | 121 +----- .../_get_resource_positional_input.rs | 57 ++- .../_get_resource_positional_output.rs} | 24 +- .../get_resource_positional/builders.rs | 79 ++-- .../rust/src/standard_library_conversions.rs | 358 +++++++++--------- .../Positional/runtimes/rust/src/types.rs | 15 +- .../runtimes/rust/src/types/builders.rs | 0 .../runtimes/rust/src/types/error.rs | 2 +- .../src/types/simple_positional_config.rs | 39 +- .../rust/src/types/simple_resource.rs | 14 +- .../src/types/simple_resource/get_name.rs | 3 +- .../Positional/runtimes/rust/src/wrapped.rs | 16 +- .../runtimes/rust/src/wrapped/client.rs | 131 ++++--- .../Resource/runtimes/rust/src/client.rs | 38 -- .../runtimes/rust/src/client/get_resources.rs | 15 - .../Resource/runtimes/rust/src/conversions.rs | 14 - .../runtimes/rust/src/conversions/error.rs | 72 ---- .../rust/src/conversions/get_resource_data.rs | 8 - .../_get_resource_data_input.rs | 32 -- .../_get_resource_data_output.rs | 32 -- .../rust/src/conversions/get_resources.rs | 8 - .../get_resources/_get_resources_input.rs | 24 -- .../get_resources/_get_resources_output.rs | 26 -- .../rust/src/conversions/simple_resource.rs | 109 ------ .../conversions/simple_resources_config.rs | 4 - .../_simple_resources_config.rs | 44 --- .../Resource/runtimes/rust/src/error.rs | 16 - .../rust/src/error/sealed_unhandled.rs | 32 -- .../Resource/runtimes/rust/src/operation.rs | 8 - .../rust/src/operation/get_resource_data.rs | 33 -- .../_get_resource_data_input.rs | 146 ------- .../_get_resource_data_output.rs | 146 ------- .../operation/get_resource_data/builders.rs | 131 ------- .../rust/src/operation/get_resources.rs | 49 --- .../get_resources/_get_resources_input.rs | 58 --- .../src/operation/get_resources/builders.rs | 75 ---- .../rust/src/standard_library_conversions.rs | 266 ------------- .../rust/src/standard_library_externs.rs | 80 ---- .../Resource/runtimes/rust/src/types.rs | 17 - .../runtimes/rust/src/types/builders.rs | 3 - .../rust/src/types/simple_resource.rs | 32 -- .../simple_resource/get_resource_data.rs | 23 -- .../rust/src/types/simple_resources_config.rs | 58 --- .../Resource/runtimes/rust/src/wrapped.rs | 15 - .../runtimes/rust/src/wrapped/client.rs | 88 ----- .../generator/AbstractRustShimGenerator.java | 274 ++++++++++++++ .../generator/RustLibraryShimGenerator.java | 342 +++++++++-------- .../rust/conversions/resource_operation.rs | 4 +- .../runtimes/rust/operation/builders.rs | 4 +- .../runtimes/rust/operation/outer.rs | 4 +- .../rust/operation/outer_send_body.rs | 6 +- .../wrapped/client_operation_impl.part.rs | 15 +- 105 files changed, 1136 insertions(+), 4161 deletions(-) delete mode 100644 TestModels/Constructor/runtimes/rust/src/client.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/client/get_constructor.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/client.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/error.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/error.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/operation.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_input.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_output.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/operation/get_constructor/builders.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/standard_library_externs.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/types.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/types/error.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/types/simple_constructor_config.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/wrapped.rs delete mode 100644 TestModels/Constructor/runtimes/rust/src/wrapped/client.rs rename TestModels/{Resource => Positional}/runtimes/rust/src/conversions/client.rs (78%) delete mode 100644 TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional/_get_resource_positional_input.rs delete mode 100644 TestModels/Positional/runtimes/rust/src/lib.rs rename TestModels/{Resource/runtimes/rust/src/operation/get_resources/_get_resources_output.rs => Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_output.rs} (67%) rename TestModels/{Constructor => Positional}/runtimes/rust/src/types/builders.rs (100%) rename TestModels/{Resource => Positional}/runtimes/rust/src/types/error.rs (95%) delete mode 100644 TestModels/Resource/runtimes/rust/src/client.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/client/get_resources.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/error.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/simple_resource.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/error.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resource_data.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resources.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_input.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/operation/get_resources/builders.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/standard_library_externs.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/types.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/types/builders.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/types/simple_resource.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/types/simple_resource/get_resource_data.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/types/simple_resources_config.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/wrapped.rs delete mode 100644 TestModels/Resource/runtimes/rust/src/wrapped/client.rs diff --git a/TestModels/Constructor/runtimes/rust/src/client.rs b/TestModels/Constructor/runtimes/rust/src/client.rs deleted file mode 100644 index a72259bc2..000000000 --- a/TestModels/Constructor/runtimes/rust/src/client.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use aws_smithy_types::error::operation::BuildError; - -#[derive(::std::clone::Clone, ::std::fmt::Debug, ::std::cmp::PartialEq)] -pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object -} - -impl Client { - /// Creates a new client from the service [`Config`](crate::Config). - #[track_caller] - pub fn from_conf( - conf: crate::types::simple_constructor_config::SimpleConstructorConfig, - ) -> Result { - let inner = - crate::simple::constructor::internaldafny::_default::SimpleConstructor( - &crate::conversions::simple_constructor_config::_simple_constructor_config::to_dafny(conf), - ); - if matches!( - inner.as_ref(), - crate::_Wrappers_Compile::Result::Failure { .. } - ) { - // TODO: convert error - the potential types are not modeled! - return Err(BuildError::other( - ::aws_smithy_types::error::metadata::ErrorMetadata::builder() - .message("Invalid client config") - .build(), - )); - } - Ok(Self { - dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()) - }) - } -} - -mod get_constructor; diff --git a/TestModels/Constructor/runtimes/rust/src/client/get_constructor.rs b/TestModels/Constructor/runtimes/rust/src/client/get_constructor.rs deleted file mode 100644 index 95bed2f40..000000000 --- a/TestModels/Constructor/runtimes/rust/src/client/get_constructor.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -impl crate::client::Client { - /// Constructs a fluent builder for the [`GetConstructor`](crate::operation::get_constructor::builders::GetConstructorFluentBuilder) operation. - /// - /// - The fluent builder is configurable: - /// - [`value(impl Into>)`](crate::operation::get_constructor::builders::GetConstructorFluentBuilder::value) / [`set_value(Option<::std::string::String>)`](crate::operation::get_constructor::builders::GetConstructorFluentBuilder::set_value): (undocumented)
- /// - On success, responds with [`GetConstructorOutput`](crate::operation::get_constructor::GetConstructorOutput) with field(s): - /// - [`blob_value(Option<::aws_smithy_types::Blob>)`](crate::operation::get_constructor::GetConstructorOutput::blob_value): (undocumented) - /// - [`boolean_value(Option<::std::primitive::bool>)`](crate::operation::get_constructor::GetConstructorOutput::boolean_value): (undocumented) - /// - [`integer_value(Option<::std::primitive::i32>)`](crate::operation::get_constructor::GetConstructorOutput::integer_value): (undocumented) - /// - [`internal_config_string(Option<::std::string::String>)`](crate::operation::get_constructor::GetConstructorOutput::internal_config_string): (undocumented) - /// - [`long_value(Option<::std::primitive::i64>)`](crate::operation::get_constructor::GetConstructorOutput::long_value): (undocumented) - /// - [`string_value(Option<::std::string::String>)`](crate::operation::get_constructor::GetConstructorOutput::string_value): (undocumented) - /// - On failure, responds with [`SdkError`](crate::operation::get_constructor::GetConstructorError) - pub fn get_constructor(&self) -> crate::operation::get_constructor::builders::GetConstructorFluentBuilder { - crate::operation::get_constructor::builders::GetConstructorFluentBuilder::new(self.clone()) - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/conversions.rs b/TestModels/Constructor/runtimes/rust/src/conversions.rs deleted file mode 100644 index 348dae32e..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub mod client; - - pub mod error; - - pub mod get_constructor; - -pub mod simple_constructor_config; diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/client.rs b/TestModels/Constructor/runtimes/rust/src/conversions/client.rs deleted file mode 100644 index 86b771b82..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/client.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] - -pub fn to_dafny( - value: &crate::client::Client, -) -> - ::dafny_runtime::Object -{ - value.dafny_client.clone() -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::dafny_runtime::Object< - dyn crate::r#simple::constructor::internaldafny::types::ISimpleConstructorClient - >, -) -> crate::client::Client { - crate::client::Client { dafny_client: dafny_value } -} diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/error.rs b/TestModels/Constructor/runtimes/rust/src/conversions/error.rs deleted file mode 100644 index 649f20f42..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/error.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Wraps up an arbitrary Rust Error value as a Dafny Error -pub fn to_opaque_error(value: E) -> - ::std::rc::Rc -{ - let error_obj: ::dafny_runtime::Object = ::dafny_runtime::Object(Some( - ::std::rc::Rc::new(::std::cell::UnsafeCell::new(value)), - )); - ::std::rc::Rc::new( - crate::r#simple::constructor::internaldafny::types::Error::Opaque { - obj: error_obj, - }, - ) -} - -/// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure -pub fn to_opaque_error_result(value: E) -> - ::std::rc::Rc< - crate::_Wrappers_Compile::Result< - T, - ::std::rc::Rc - > - > -{ - ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Failure { - error: to_opaque_error(value), - }) -} -pub fn to_dafny( - value: crate::types::error::Error, -) -> ::std::rc::Rc { - ::std::rc::Rc::new(match value { - - crate::types::error::Error::CollectionOfErrors { list, message } => - crate::r#simple::constructor::internaldafny::types::Error::CollectionOfErrors { - message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&message), - list: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&list, |e| to_dafny(e.clone())) - }, - crate::types::error::Error::Opaque { obj } => - crate::r#simple::constructor::internaldafny::types::Error::Opaque { - obj: ::dafny_runtime::Object(obj.0) - }, - }) -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::Error, - >, -) -> crate::types::error::Error { - match ::std::borrow::Borrow::borrow(&dafny_value) { - - crate::r#simple::constructor::internaldafny::types::Error::CollectionOfErrors { list, message } => - crate::types::error::Error::CollectionOfErrors { - message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&message), - list: ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&list, |e| from_dafny(e.clone())) - }, - crate::r#simple::constructor::internaldafny::types::Error::Opaque { obj } => - crate::types::error::Error::Opaque { - obj: obj.clone() - }, - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs deleted file mode 100644 index 0b5dd29ca..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::any::Any; - -pub mod _get_constructor_input; - -pub mod _get_constructor_output; diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs deleted file mode 100644 index 2bc1e5b20..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_constructor::GetConstructorInput, -) -> ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::GetConstructorInput, ->{ - ::std::rc::Rc::new(crate::r#simple::constructor::internaldafny::types::GetConstructorInput::GetConstructorInput { - value: crate::standard_library_conversions::ostring_to_dafny(&value.value), - }) -} - #[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::GetConstructorInput, - >, -) -> crate::operation::get_constructor::GetConstructorInput { - crate::operation::get_constructor::GetConstructorInput::builder() - .set_value(crate::standard_library_conversions::ostring_from_dafny(dafny_value.value().clone())) - .build() - .unwrap() -} diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs deleted file mode 100644 index fbf3d4689..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_constructor::GetConstructorOutput, -) -> ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::GetConstructorOutput, ->{ - ::std::rc::Rc::new(crate::r#simple::constructor::internaldafny::types::GetConstructorOutput::GetConstructorOutput { - internalConfigString: crate::standard_library_conversions::ostring_to_dafny(&value.internal_config_string), - blobValue: crate::standard_library_conversions::oblob_to_dafny(&value.blob_value), - booleanValue: crate::standard_library_conversions::obool_to_dafny(&value.boolean_value), - stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), - integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), - longValue: crate::standard_library_conversions::olong_to_dafny(&value.long_value), - }) -} - #[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::GetConstructorOutput, - >, -) -> crate::operation::get_constructor::GetConstructorOutput { - crate::operation::get_constructor::GetConstructorOutput::builder() - .set_internal_config_string(crate::standard_library_conversions::ostring_from_dafny(dafny_value.internalConfigString().clone())) - .set_blob_value(crate::standard_library_conversions::oblob_from_dafny(dafny_value.blobValue().clone())) - .set_boolean_value(crate::standard_library_conversions::obool_from_dafny(dafny_value.booleanValue().clone())) - .set_string_value(crate::standard_library_conversions::ostring_from_dafny(dafny_value.stringValue().clone())) - .set_integer_value(crate::standard_library_conversions::oint_from_dafny(dafny_value.integerValue().clone())) - .set_long_value(crate::standard_library_conversions::olong_from_dafny(dafny_value.longValue().clone())) - .build() - .unwrap() -} diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config.rs b/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config.rs deleted file mode 100644 index f4b5d1121..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config.rs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub mod _simple_constructor_config; diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs b/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs deleted file mode 100644 index 886a352ab..000000000 --- a/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] - -pub fn to_dafny( - value: crate::types::simple_constructor_config::SimpleConstructorConfig, -) -> ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig, -> { - ::std::rc::Rc::new(to_dafny_plain(value)) -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig, - >, -) -> crate::types::simple_constructor_config::SimpleConstructorConfig { - plain_from_dafny(&*dafny_value) -} - - -#[allow(dead_code)] -pub fn to_dafny_plain( - value: crate::types::simple_constructor_config::SimpleConstructorConfig, -) -> crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig { - crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig::SimpleConstructorConfig { - blobValue: crate::standard_library_conversions::oblob_to_dafny(&value.blob_value), - booleanValue: crate::standard_library_conversions::obool_to_dafny(&value.boolean_value), - stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), - integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), - longValue: crate::standard_library_conversions::olong_to_dafny(&value.long_value), - } -} - -#[allow(dead_code)] -pub fn plain_from_dafny( - dafny_value: &crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig, -) -> crate::types::simple_constructor_config::SimpleConstructorConfig { - match dafny_value { - crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig::SimpleConstructorConfig {..} => - crate::types::simple_constructor_config::SimpleConstructorConfig::builder() - .set_blob_value(crate::standard_library_conversions::oblob_from_dafny(dafny_value.blobValue().clone())) - .set_boolean_value(crate::standard_library_conversions::obool_from_dafny(dafny_value.booleanValue().clone())) - .set_string_value(crate::standard_library_conversions::ostring_from_dafny(dafny_value.stringValue().clone())) - .set_integer_value(crate::standard_library_conversions::oint_from_dafny(dafny_value.integerValue().clone())) - .set_long_value(crate::standard_library_conversions::olong_from_dafny(dafny_value.longValue().clone())) - .build() - .unwrap() - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/error.rs b/TestModels/Constructor/runtimes/rust/src/error.rs deleted file mode 100644 index 4cddaa7c3..000000000 --- a/TestModels/Constructor/runtimes/rust/src/error.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub use ::aws_smithy_runtime_api::box_error::BoxError; - -/// Error type returned by the client. -pub type SdkError = - ::aws_smithy_runtime_api::client::result::SdkError; -pub use ::aws_smithy_runtime_api::client::result::ConnectorError; -pub use ::aws_smithy_types::error::operation::BuildError; - -pub use ::aws_smithy_types::error::display::DisplayErrorContext; -pub use ::aws_smithy_types::error::metadata::ErrorMetadata; -pub use ::aws_smithy_types::error::metadata::ProvideErrorMetadata; - -pub(crate) mod sealed_unhandled; diff --git a/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs deleted file mode 100644 index eae800729..000000000 --- a/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::any::Any; - -use dafny_runtime::UpcastObject; - -/// This struct is not intended to be used. -/// -/// This struct holds information about an unhandled error, -/// but that information should be obtained by using the -/// [`ProvideErrorMetadata`](::aws_smithy_types::error::metadata::ProvideErrorMetadata) trait -/// on the error type. -/// -/// This struct intentionally doesn't yield any useful information itself. -#[deprecated( - note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \ -variable wildcard pattern and check `.code()`: - \ -   `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }` - \ -See [`ProvideErrorMetadata`](::aws_smithy_types::error::metadata::ProvideErrorMetadata) for what information is available for the error." -)] -#[derive(Debug)] -pub struct Unhandled { - pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, - pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, -} - -impl UpcastObject for Unhandled { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} diff --git a/TestModels/Constructor/runtimes/rust/src/operation.rs b/TestModels/Constructor/runtimes/rust/src/operation.rs deleted file mode 100644 index 18b01b68f..000000000 --- a/TestModels/Constructor/runtimes/rust/src/operation.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Types for the `GetConstructor` operation. -pub mod get_constructor; diff --git a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs deleted file mode 100644 index 685b37669..000000000 --- a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Orchestration and serialization glue logic for `GetConstructor`. -#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)] -#[non_exhaustive] -pub struct GetConstructor; -impl GetConstructor { - /// Creates a new `GetConstructor` - pub fn new() -> Self { - Self - } - pub(crate) async fn send( - client: &crate::client::Client, - input: crate::operation::get_constructor::GetConstructorInput, - ) -> ::std::result::Result< - crate::operation::get_constructor::GetConstructorOutput, - crate::types::error::Error, - > { - let inner_input = crate::conversions::get_constructor::_get_constructor_input::to_dafny(input); - let inner_result = - ::dafny_runtime::md!(client.dafny_client.clone()).GetConstructor(&inner_input); - if matches!( - inner_result.as_ref(), - crate::r#_Wrappers_Compile::Result::Success { .. } - ) { - Ok( - crate::conversions::get_constructor::_get_constructor_output::from_dafny( - inner_result.value().clone(), - ), - ) - } else { - Err(crate::conversions::error::from_dafny( - inner_result.error().clone(), - )) - } - } -} - -pub use crate::operation::get_constructor::_get_constructor_output::GetConstructorOutput; - -pub use crate::operation::get_constructor::_get_constructor_input::GetConstructorInput; - -pub(crate) mod _get_constructor_output; - -pub(crate) mod _get_constructor_input; - -/// Builders -pub mod builders; diff --git a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_input.rs b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_input.rs deleted file mode 100644 index 14a55c942..000000000 --- a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_input.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct GetConstructorInput { - #[allow(missing_docs)] // documentation missing in model -pub value: ::std::option::Option<::std::string::String>, -} -impl GetConstructorInput { - #[allow(missing_docs)] // documentation missing in model -pub fn value(&self) -> &::std::option::Option<::std::string::String> { - &self.value -} -} -impl GetConstructorInput { - /// Creates a new builder-style object to manufacture [`GetConstructorInput`](crate::operation::get_constructor::builders::GetConstructorInput). - pub fn builder() -> crate::operation::get_constructor::builders::GetConstructorInputBuilder { - crate::operation::get_constructor::builders::GetConstructorInputBuilder::default() - } -} - -/// A builder for [`GetConstructorInput`](crate::operation::operation::GetConstructorInput). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct GetConstructorInputBuilder { - pub(crate) value: ::std::option::Option<::std::string::String>, -} -impl GetConstructorInputBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_value(&self) -> &::std::option::Option<::std::string::String> { - &self.value -} - /// Consumes the builder and constructs a [`GetConstructorInput`](crate::operation::operation::GetConstructorInput). - pub fn build( - self, - ) -> ::std::result::Result< - crate::operation::get_constructor::GetConstructorInput, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::operation::get_constructor::GetConstructorInput { - value: self.value, - }) - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_output.rs b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_output.rs deleted file mode 100644 index 59c2e3caf..000000000 --- a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/_get_constructor_output.rs +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct GetConstructorOutput { - #[allow(missing_docs)] // documentation missing in model -pub blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -#[allow(missing_docs)] // documentation missing in model -pub boolean_value: ::std::option::Option<::std::primitive::bool>, -#[allow(missing_docs)] // documentation missing in model -pub integer_value: ::std::option::Option<::std::primitive::i32>, -#[allow(missing_docs)] // documentation missing in model -pub internal_config_string: ::std::option::Option<::std::string::String>, -#[allow(missing_docs)] // documentation missing in model -pub long_value: ::std::option::Option<::std::primitive::i64>, -#[allow(missing_docs)] // documentation missing in model -pub string_value: ::std::option::Option<::std::string::String>, -} -impl GetConstructorOutput { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn internal_config_string(&self) -> &::std::option::Option<::std::string::String> { - &self.internal_config_string -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} -} -impl GetConstructorOutput { - /// Creates a new builder-style object to manufacture [`GetConstructorOutput`](crate::operation::get_constructor::builders::GetConstructorOutput). - pub fn builder() -> crate::operation::get_constructor::builders::GetConstructorOutputBuilder { - crate::operation::get_constructor::builders::GetConstructorOutputBuilder::default() - } -} - -/// A builder for [`GetConstructorOutput`](crate::operation::operation::GetConstructorOutput). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct GetConstructorOutputBuilder { - pub(crate) blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -pub(crate) boolean_value: ::std::option::Option<::std::primitive::bool>, -pub(crate) integer_value: ::std::option::Option<::std::primitive::i32>, -pub(crate) internal_config_string: ::std::option::Option<::std::string::String>, -pub(crate) long_value: ::std::option::Option<::std::primitive::i64>, -pub(crate) string_value: ::std::option::Option<::std::string::String>, -} -impl GetConstructorOutputBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(mut self, input: impl ::std::convert::Into<::aws_smithy_types::Blob>) -> Self { - self.blob_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_blob_value(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self { - self.blob_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(mut self, input: impl ::std::convert::Into<::std::primitive::bool>) -> Self { - self.boolean_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_boolean_value(mut self, input: ::std::option::Option<::std::primitive::bool>) -> Self { - self.boolean_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(mut self, input: impl ::std::convert::Into<::std::primitive::i32>) -> Self { - self.integer_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_integer_value(mut self, input: ::std::option::Option<::std::primitive::i32>) -> Self { - self.integer_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn internal_config_string(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.internal_config_string = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_internal_config_string(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.internal_config_string = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_internal_config_string(&self) -> &::std::option::Option<::std::string::String> { - &self.internal_config_string -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(mut self, input: impl ::std::convert::Into<::std::primitive::i64>) -> Self { - self.long_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_long_value(mut self, input: ::std::option::Option<::std::primitive::i64>) -> Self { - self.long_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.string_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_string_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.string_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} - /// Consumes the builder and constructs a [`GetConstructorOutput`](crate::operation::operation::GetConstructorOutput). - pub fn build( - self, - ) -> ::std::result::Result< - crate::operation::get_constructor::GetConstructorOutput, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::operation::get_constructor::GetConstructorOutput { - blob_value: self.blob_value, -boolean_value: self.boolean_value, -integer_value: self.integer_value, -internal_config_string: self.internal_config_string, -long_value: self.long_value, -string_value: self.string_value, - }) - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/builders.rs b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/builders.rs deleted file mode 100644 index 83d012e00..000000000 --- a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor/builders.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub use crate::operation::get_constructor::_get_constructor_output::GetConstructorOutputBuilder; - -pub use crate::operation::get_constructor::_get_constructor_input::GetConstructorInputBuilder; - -impl GetConstructorInputBuilder { - /// Sends a request with this input using the given client. - pub async fn send_with( - self, - client: &crate::client::Client, - ) -> ::std::result::Result< - crate::operation::get_constructor::GetConstructorOutput, - crate::types::error::Error, - > { - let mut fluent_builder = client.get_constructor(); - fluent_builder.inner = self; - fluent_builder.send().await - } -} -/// Fluent builder constructing a request to `GetConstructor`. -/// -#[derive(::std::clone::Clone, ::std::fmt::Debug)] -pub struct GetConstructorFluentBuilder { - client: crate::client::Client, - pub(crate) inner: crate::operation::get_constructor::builders::GetConstructorInputBuilder, -} -impl GetConstructorFluentBuilder { - /// Creates a new `GetConstructor`. - pub(crate) fn new(client: crate::client::Client) -> Self { - Self { - client, - inner: ::std::default::Default::default(), - } - } - /// Access the GetConstructor as a reference. - pub fn as_input(&self) -> &crate::operation::get_constructor::builders::GetConstructorInputBuilder { - &self.inner - } - /// Sends the request and returns the response. - pub async fn send( - self, - ) -> ::std::result::Result< - crate::operation::get_constructor::GetConstructorOutput, - crate::types::error::Error, - > { - let input = self - .inner - .build() - // Using Opaque since we don't have a validation-specific error yet. - // Operations' models don't declare their own validation error, - // and smithy-rs seems to not generate a ValidationError case unless there is. - // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError. - .map_err(|mut e| crate::types::error::Error::Opaque { - obj: ::dafny_runtime::Object::from_ref(&mut e as &mut dyn ::std::any::Any) - })?; - crate::operation::get_constructor::GetConstructor::send(&self.client, input).await - } - - #[allow(missing_docs)] // documentation missing in model -pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.inner = self.inner.value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.inner = self.inner.set_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_value(&self) -> &::std::option::Option<::std::string::String> { - self.inner.get_value() -} -} diff --git a/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs deleted file mode 100644 index 6bf8297d8..000000000 --- a/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs +++ /dev/null @@ -1,266 +0,0 @@ -pub fn ostring_to_dafny( - input: &Option, -) -> ::std::rc::Rc< - crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, -> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&b) - }, - None => crate::_Wrappers_Compile::Option::None {}, -}; - ::std::rc::Rc::new(dafny_value) -} - -pub fn ostring_from_dafny( - input: ::std::rc::Rc< - crate::_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some( - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - &input.Extract(), - ), - ) - } else { - None - } -} - -pub fn obool_to_dafny( - input: &Option, -) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: *b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn obool_from_dafny( - input: ::std::rc::Rc>, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(input.Extract()) - } else { - None - } -} - -pub fn oint_to_dafny(input: Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn oint_from_dafny(input: ::std::rc::Rc>) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(input.Extract()) - } else { - None - } -} - -pub fn olong_to_dafny(input: &Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: *b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn olong_from_dafny( - input: ::std::rc::Rc>, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(input.Extract()) - } else { - None - } -} - -pub fn blob_to_dafny(input: &::aws_smithy_types::Blob) -> ::dafny_runtime::Sequence { - ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&input.clone().into_inner(), |x| *x) -} - -pub fn oblob_to_dafny( - input: &Option<::aws_smithy_types::Blob>, -) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { - value: blob_to_dafny(&b), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn blob_from_dafny(input: ::dafny_runtime::Sequence) -> ::aws_smithy_types::Blob { - ::aws_smithy_types::Blob::new( - ::std::rc::Rc::try_unwrap(input.to_array()).unwrap_or_else(|rc| (*rc).clone()), - ) -} - -pub fn oblob_from_dafny( - input: ::std::rc::Rc>>, -) -> Option<::aws_smithy_types::Blob> { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(blob_from_dafny(input.Extract())) - } else { - None - } -} - -pub fn double_to_dafny(input: f64) -> ::dafny_runtime::Sequence { - ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence( - &f64::to_be_bytes(input).to_vec(), - |x| *x, - ) -} - -pub fn odouble_to_dafny( - input: &Option, -) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(f) => crate::_Wrappers_Compile::Option::Some { - value: double_to_dafny(*f), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn double_from_dafny(input: &::dafny_runtime::Sequence) -> f64 { - let v = ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(input, |x| *x); - f64::from_be_bytes(v.try_into().expect("Error converting Sequence to f64")) -} - -pub fn odouble_from_dafny( - input: ::std::rc::Rc>>, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(double_from_dafny(&input.Extract())) - } else { - None - } -} - -pub fn timestamp_to_dafny( - input: &::aws_smithy_types::DateTime, -) -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &input.to_string(), - ) -} - -pub fn otimestamp_to_dafny( - input: &Option<::aws_smithy_types::DateTime>, -) -> ::std::rc::Rc< - crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, -> { - let dafny_value = match input { - Some(f) => crate::_Wrappers_Compile::Option::Some { - value: timestamp_to_dafny(f), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn timestamp_from_dafny( - input: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -) -> ::aws_smithy_types::DateTime { - let s = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - &input, - ); - ::aws_smithy_types::DateTime::from_str(&s, aws_smithy_types::date_time::Format::DateTime) - .unwrap() -} - -pub fn otimestamp_from_dafny( - input: ::std::rc::Rc< - crate::_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, -) -> Option<::aws_smithy_types::DateTime> { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(timestamp_from_dafny(input.Extract())) - } else { - None - } -} - -pub fn option_from_dafny( - input: ::std::rc::Rc>, - converter: fn(&T) -> TR, -) -> Option { - match &*input { - crate::_Wrappers_Compile::Option::Some { value } => Some(converter(value)), - crate::_Wrappers_Compile::Option::None {} => None, - } -} - -pub fn option_to_dafny( - input: &Option, - converter: fn(&TR) -> T, -) -> ::std::rc::Rc> { - match input { - Some(value) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Option::Some { - value: converter(&value), - }), - None => ::std::rc::Rc::new(crate::_Wrappers_Compile::Option::None {}), - } -} - -pub fn result_from_dafny( - input: ::std::rc::Rc>, - converter_t: fn(&T) -> TR, - converter_e: fn(&E) -> ER, -) -> Result { - match &*input { - crate::_Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), - crate::_Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), - } -} - -pub fn result_to_dafny( - input: &Result, - converter_t: fn(&TR) -> T, - converter_e: fn(&ER) -> E, -) -> ::std::rc::Rc> { - match input { - Ok(value) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Success { - value: converter_t(&value), - }), - Err(error) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Failure { - error: converter_e(&error), - }), - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/standard_library_externs.rs b/TestModels/Constructor/runtimes/rust/src/standard_library_externs.rs deleted file mode 100644 index eca6a2980..000000000 --- a/TestModels/Constructor/runtimes/rust/src/standard_library_externs.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Annotation to ignore the case of this module -use crate::r#_Wrappers_Compile; -use crate::UTF8; - -impl crate::UTF8::_default { - pub fn Encode( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - r#_Wrappers_Compile::Result< - UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - let v = s.to_array(); - let mut _accumulator: Vec = vec![]; - // Use of .encode_utf8 method. - let mut surrogate: Option = None; - for c in v.iter() { - let s = if let Some(s) = surrogate { - String::from_utf16(&[s, c.0]) - } else { - String::from_utf16(&[c.0]) - }; - surrogate = None; - match s { - Ok(value) => { - _accumulator.extend(value.as_bytes()); - continue; - } - Err(e) => { - if 0xD800 <= c.0 && c.0 <= 0xDFFF { - surrogate = Some(c.0); - continue; - } - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &e.to_string()) - }); - } - } - } - if let Some(s) = surrogate { - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &format!("Surrogate pair missing: 0x{:04x}", s)) - }); - } - ::std::rc::Rc::new(r#_Wrappers_Compile::Result::< - UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Success { - value: ::dafny_runtime::Sequence::from_array_owned(_accumulator), - }) - } - pub fn Decode( - b: &::dafny_runtime::Sequence, - ) -> ::std::rc::Rc< - r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - let b = String::from_utf8(b.to_array().as_ref().clone()); - match b { - Ok(s) => { - ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success { - value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) - }) - }, - Err(e) => { - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &e.to_string()) - }) - } - } - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/types.rs b/TestModels/Constructor/runtimes/rust/src/types.rs deleted file mode 100644 index 0f4da7bb4..000000000 --- a/TestModels/Constructor/runtimes/rust/src/types.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Types for the `SimpleConstructorConfig` -pub mod simple_constructor_config; - -pub mod builders; - - - - - -pub mod error; - - - diff --git a/TestModels/Constructor/runtimes/rust/src/types/error.rs b/TestModels/Constructor/runtimes/rust/src/types/error.rs deleted file mode 100644 index 37ca2596f..000000000 --- a/TestModels/Constructor/runtimes/rust/src/types/error.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[derive(::std::clone::Clone, ::std::fmt::Debug, ::std::cmp::PartialEq)] -pub enum Error { - - CollectionOfErrors { - list: ::std::vec::Vec, - message: ::std::string::String, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, -} - -impl ::std::cmp::Eq for Error {} - -impl ::std::fmt::Display for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f, "{:?}", self) - } -} - -impl ::std::error::Error for Error {} diff --git a/TestModels/Constructor/runtimes/rust/src/types/simple_constructor_config.rs b/TestModels/Constructor/runtimes/rust/src/types/simple_constructor_config.rs deleted file mode 100644 index 20c71bba9..000000000 --- a/TestModels/Constructor/runtimes/rust/src/types/simple_constructor_config.rs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct SimpleConstructorConfig { - #[allow(missing_docs)] // documentation missing in model -pub blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -#[allow(missing_docs)] // documentation missing in model -pub boolean_value: ::std::option::Option<::std::primitive::bool>, -#[allow(missing_docs)] // documentation missing in model -pub integer_value: ::std::option::Option<::std::primitive::i32>, -#[allow(missing_docs)] // documentation missing in model -pub long_value: ::std::option::Option<::std::primitive::i64>, -#[allow(missing_docs)] // documentation missing in model -pub string_value: ::std::option::Option<::std::string::String>, -} -impl SimpleConstructorConfig { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} -} -impl SimpleConstructorConfig { - /// Creates a new builder-style object to manufacture [`SimpleConstructorConfig`](crate::types::SimpleConstructorConfig). - pub fn builder() -> crate::types::simple_constructor_config::SimpleConstructorConfigBuilder { - crate::types::simple_constructor_config::SimpleConstructorConfigBuilder::default() - } -} - -/// A builder for [`SimpleConstructorConfig`](crate::types::SimpleConstructorConfig). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct SimpleConstructorConfigBuilder { - pub(crate) blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -pub(crate) boolean_value: ::std::option::Option<::std::primitive::bool>, -pub(crate) integer_value: ::std::option::Option<::std::primitive::i32>, -pub(crate) long_value: ::std::option::Option<::std::primitive::i64>, -pub(crate) string_value: ::std::option::Option<::std::string::String>, -} -impl SimpleConstructorConfigBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(mut self, input: impl ::std::convert::Into<::aws_smithy_types::Blob>) -> Self { - self.blob_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_blob_value(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self { - self.blob_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(mut self, input: impl ::std::convert::Into<::std::primitive::bool>) -> Self { - self.boolean_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_boolean_value(mut self, input: ::std::option::Option<::std::primitive::bool>) -> Self { - self.boolean_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(mut self, input: impl ::std::convert::Into<::std::primitive::i32>) -> Self { - self.integer_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_integer_value(mut self, input: ::std::option::Option<::std::primitive::i32>) -> Self { - self.integer_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(mut self, input: impl ::std::convert::Into<::std::primitive::i64>) -> Self { - self.long_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_long_value(mut self, input: ::std::option::Option<::std::primitive::i64>) -> Self { - self.long_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.string_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_string_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.string_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} - /// Consumes the builder and constructs a [`SimpleConstructorConfig`](crate::types::SimpleConstructorConfig). - pub fn build( - self, - ) -> ::std::result::Result< - crate::types::simple_constructor_config::SimpleConstructorConfig, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::types::simple_constructor_config::SimpleConstructorConfig { - blob_value: self.blob_value, -boolean_value: self.boolean_value, -integer_value: self.integer_value, -long_value: self.long_value, -string_value: self.string_value, - }) - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/wrapped.rs b/TestModels/Constructor/runtimes/rust/src/wrapped.rs deleted file mode 100644 index 65c5a9616..000000000 --- a/TestModels/Constructor/runtimes/rust/src/wrapped.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub mod client; - -impl crate::r#simple::constructor::internaldafny::wrapped::_default { - pub fn WrappedSimpleConstructor(config: &::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig, - >) -> ::std::rc::Rc, - ::std::rc::Rc - >>{ - crate::wrapped::client::Client::from_conf(config) - } -} diff --git a/TestModels/Constructor/runtimes/rust/src/wrapped/client.rs b/TestModels/Constructor/runtimes/rust/src/wrapped/client.rs deleted file mode 100644 index 6903cfa18..000000000 --- a/TestModels/Constructor/runtimes/rust/src/wrapped/client.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::sync::LazyLock; - -pub struct Client { - wrapped: crate::client::Client -} - -/// A runtime for executing operations on the asynchronous client in a blocking manner. -/// Necessary because Dafny only generates synchronous code. -static dafny_tokio_runtime: LazyLock = LazyLock::new(|| { - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap() -}); - -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn crate::r#simple::constructor::internaldafny::types::ISimpleConstructorClient); -} - -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} - -impl Client { - pub fn from_conf(config: &::std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::SimpleConstructorConfig, - >) -> -::std::rc::Rc, - ::std::rc::Rc ->> { - let result = crate::client::Client::from_conf( - crate::conversions::simple_constructor_config::_simple_constructor_config::from_dafny( - config.clone(), - ), - ); - match result { - Ok(client) => { - let wrap = crate::wrapped::client::Client { - wrapped: client - }; - std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Success { - value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) - } - ) - }, - Err(error) => crate::conversions::error::to_opaque_error_result(error) - } - } -} - -impl crate::r#simple::constructor::internaldafny::types::ISimpleConstructorClient for Client { - fn GetConstructor( - &mut self, - input: &std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::GetConstructorInput, - >, - ) -> std::rc::Rc< - crate::r#_Wrappers_Compile::Result< - std::rc::Rc< - crate::r#simple::constructor::internaldafny::types::GetConstructorOutput, - >, - std::rc::Rc, - >, - >{ - let inner_input = - crate::conversions::get_constructor::_get_constructor_input::from_dafny(input.clone()); - let result = tokio::task::block_in_place(|| { - dafny_tokio_runtime.block_on(crate::operation::get_constructor::GetConstructor::send(&self.wrapped, inner_input)) - }); - match result { - Err(error) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Failure { - error: crate::conversions::error::to_dafny(error), - }, - ), - Ok(client) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Success { - value: crate::conversions::get_constructor::_get_constructor_output::to_dafny(client), - }, - ), - } - } -} diff --git a/TestModels/Positional/Makefile b/TestModels/Positional/Makefile index 0f3cca8e8..e65bbaa7f 100644 --- a/TestModels/Positional/Makefile +++ b/TestModels/Positional/Makefile @@ -4,7 +4,7 @@ CORES=2 ENABLE_EXTERN_PROCESSING=1 -RUST_BENERATED=1 +TRANSPILE_TESTS_IN_RUST=1 include ../SharedMakefile.mk diff --git a/TestModels/Positional/runtimes/rust/src/client.rs b/TestModels/Positional/runtimes/rust/src/client.rs index fc2c7155c..0e3092d92 100644 --- a/TestModels/Positional/runtimes/rust/src/client.rs +++ b/TestModels/Positional/runtimes/rust/src/client.rs @@ -1,10 +1,11 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. use aws_smithy_types::error::operation::BuildError; -#[derive(::std::clone::Clone, ::std::fmt::Debug)] +#[derive(::std::clone::Clone, ::std::fmt::Debug, ::std::cmp::PartialEq)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -29,10 +30,11 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()) }) } } mod get_resource; + mod get_resource_positional; diff --git a/TestModels/Positional/runtimes/rust/src/client/get_resource.rs b/TestModels/Positional/runtimes/rust/src/client/get_resource.rs index 8bfb12475..d544b8739 100644 --- a/TestModels/Positional/runtimes/rust/src/client/get_resource.rs +++ b/TestModels/Positional/runtimes/rust/src/client/get_resource.rs @@ -1,15 +1,15 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. -impl super::Client { +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +impl crate::client::Client { /// Constructs a fluent builder for the [`GetResource`](crate::operation::get_resource::builders::GetResourceFluentBuilder) operation. /// /// - The fluent builder is configurable: - /// - [`name(impl Into)`](crate::operation::get_resource::builders::GetResourceFluentBuilder::name) / [`set_name(Option)`](crate::operation::get_resource::builders::GetResourceFluentBuilder::set_name):
required: **true**
(undocumented)
+ /// - [`name(impl Into>)`](crate::operation::get_resource::builders::GetResourceFluentBuilder::name) / [`set_name(Option<::std::string::String>)`](crate::operation::get_resource::builders::GetResourceFluentBuilder::set_name): (undocumented)
/// - On success, responds with [`GetResourceOutput`](crate::operation::get_resource::GetResourceOutput) with field(s): - /// - [`output(SimpleResourceReference)`](crate::operation::get_resource::GetResourceOutput::output): (undocumented) + /// - [`output(Option)`](crate::operation::get_resource::GetResourceOutput::output): (undocumented) /// - On failure, responds with [`SdkError`](crate::operation::get_resource::GetResourceError) - pub fn get_resource( - &self, - ) -> crate::operation::get_resource::builders::GetResourceFluentBuilder { + pub fn get_resource(&self) -> crate::operation::get_resource::builders::GetResourceFluentBuilder { crate::operation::get_resource::builders::GetResourceFluentBuilder::new(self.clone()) } } diff --git a/TestModels/Positional/runtimes/rust/src/client/get_resource_positional.rs b/TestModels/Positional/runtimes/rust/src/client/get_resource_positional.rs index da1a21a41..3d30beb2c 100644 --- a/TestModels/Positional/runtimes/rust/src/client/get_resource_positional.rs +++ b/TestModels/Positional/runtimes/rust/src/client/get_resource_positional.rs @@ -1,18 +1,15 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. -impl super::Client { +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +impl crate::client::Client { /// Constructs a fluent builder for the [`GetResourcePositional`](crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder) operation. /// /// - The fluent builder is configurable: - /// - [`name(impl Into)`](crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder::name) / [`set_name(Option)`](crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder::set_name):
required: **true**
(undocumented)
+ /// - [`name(impl Into>)`](crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder::name) / [`set_name(Option<::std::string::String>)`](crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder::set_name): (undocumented)
/// - On success, responds with [`GetResourcePositionalOutput`](crate::operation::get_resource_positional::GetResourcePositionalOutput) with field(s): - /// - [`output(SimpleResourceReference)`](crate::operation::get_resource_positional::GetResourcePositionalOutput::output): (undocumented) + /// - [`output(Option)`](crate::operation::get_resource_positional::GetResourcePositionalOutput::output): (undocumented) /// - On failure, responds with [`SdkError`](crate::operation::get_resource_positional::GetResourcePositionalError) - pub fn get_resource_positional( - &self - ) -> crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder - { - crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder::new( - self.clone(), - ) + pub fn get_resource_positional(&self) -> crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder { + crate::operation::get_resource_positional::builders::GetResourcePositionalFluentBuilder::new(self.clone()) } } diff --git a/TestModels/Positional/runtimes/rust/src/conversions.rs b/TestModels/Positional/runtimes/rust/src/conversions.rs index 479f6cfff..72b05936c 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions.rs @@ -1,10 +1,16 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. -pub mod get_resource; -pub mod get_resource_positional; -pub mod get_name; +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +pub mod client; -pub mod simple_positional_config; + pub mod error; + + pub mod get_name; + + pub mod get_resource; -pub mod simple_resource; + pub mod get_resource_positional; -pub(crate) mod error; + pub mod simple_resource; + +pub mod simple_positional_config; diff --git a/TestModels/Resource/runtimes/rust/src/conversions/client.rs b/TestModels/Positional/runtimes/rust/src/conversions/client.rs similarity index 78% rename from TestModels/Resource/runtimes/rust/src/conversions/client.rs rename to TestModels/Positional/runtimes/rust/src/conversions/client.rs index ec29411cb..fe6212bc3 100644 --- a/TestModels/Resource/runtimes/rust/src/conversions/client.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/client.rs @@ -9,7 +9,7 @@ pub fn to_dafny( value: &crate::client::Client, ) -> - ::dafny_runtime::Object + ::dafny_runtime::Object { value.dafny_client.clone() } @@ -17,7 +17,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::dafny_runtime::Object< - dyn crate::r#simple::resources::internaldafny::types::ISimpleResourcesClient + dyn crate::r#simple::positional::internaldafny::types::ISimplePositionalClient >, ) -> crate::client::Client { crate::client::Client { dafny_client: dafny_value } diff --git a/TestModels/Positional/runtimes/rust/src/conversions/error.rs b/TestModels/Positional/runtimes/rust/src/conversions/error.rs index 2cf8b64cd..e405b691a 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/error.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/error.rs @@ -1,32 +1,72 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. /// Wraps up an arbitrary Rust Error value as a Dafny Error -pub fn to_opaque_error( - value: E, -) -> ::std::rc::Rc +pub fn to_opaque_error(value: E) -> + ::std::rc::Rc { - let error_obj: ::dafny_runtime::Object = ::dafny_runtime::Object(Some( + let error_obj: ::dafny_runtime::Object = ::dafny_runtime::Object(Some( ::std::rc::Rc::new(::std::cell::UnsafeCell::new(value)), )); ::std::rc::Rc::new( - crate::simple::positional::internaldafny::types::Error::Opaque { - obj: error_obj, - }, - ) + crate::r#simple::positional::internaldafny::types::Error::Opaque { + obj: error_obj, + }, + ) } /// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure -pub fn to_opaque_error_result( - value: E, -) -> ::std::rc::Rc< - crate::_Wrappers_Compile::Result< - T, - ::std::rc::Rc< - crate::simple::positional::internaldafny::types::Error, - >, +pub fn to_opaque_error_result(value: E) -> + ::std::rc::Rc< + crate::_Wrappers_Compile::Result< + T, + ::std::rc::Rc + > + > +{ + ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Failure { + error: to_opaque_error(value), + }) +} +pub fn to_dafny( + value: crate::types::error::Error, +) -> ::std::rc::Rc { + ::std::rc::Rc::new(match value { + crate::types::error::Error::SimplePositionalException { message } => + crate::r#simple::positional::internaldafny::types::Error::SimplePositionalException { + message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&message), + }, + crate::types::error::Error::CollectionOfErrors { list, message } => + crate::r#simple::positional::internaldafny::types::Error::CollectionOfErrors { + message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&message), + list: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&list, |e| to_dafny(e.clone())) + }, + crate::types::error::Error::Opaque { obj } => + crate::r#simple::positional::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::Object(obj.0) + }, + }) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< + crate::r#simple::positional::internaldafny::types::Error, >, -> { - ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Failure { - error: to_opaque_error(value), - }, - ) +) -> crate::types::error::Error { + match ::std::borrow::Borrow::borrow(&dafny_value) { + crate::r#simple::positional::internaldafny::types::Error::SimplePositionalException { message } => + crate::types::error::Error::SimplePositionalException { + message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&message), + }, + crate::r#simple::positional::internaldafny::types::Error::CollectionOfErrors { list, message } => + crate::types::error::Error::CollectionOfErrors { + message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&message), + list: ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&list, |e| from_dafny(e.clone())) + }, + crate::r#simple::positional::internaldafny::types::Error::Opaque { obj } => + crate::types::error::Error::Opaque { + obj: obj.clone() + }, + } } diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_name.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_name.rs index 09af086b0..7acc20499 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_name.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/get_name.rs @@ -1,34 +1,6 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - -use std::any::Any; - -#[allow(dead_code)] -pub fn to_dafny_error( - value: crate::operation::get_name::GetNameError, -) -> ::std::rc::Rc< - crate::r#simple::positional::internaldafny::types::Error, -> { - match value { - crate::operation::get_name::GetNameError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::r#simple::positional::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) - } -} - -#[allow(dead_code)] -pub fn from_dafny_error( - dafny_value: ::std::rc::Rc< - crate::r#simple::positional::internaldafny::types::Error, - >, -) -> crate::operation::get_name::GetNameError { - // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), crate::r#simple::positional::internaldafny::types::Error::CollectionOfErrors { .. }) { - let error_message = "TODO: can't get message yet"; - crate::operation::get_name::GetNameError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) - } else { - crate::operation::get_name::GetNameError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message("Opaque error").build()) - } -} - +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. pub mod _get_name_input; -pub mod _get_name_output; + pub mod _get_name_output; diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_input.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_input.rs index 96bb24b8f..7688e4a01 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_input.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_input.rs @@ -8,6 +8,7 @@ pub fn to_dafny( crate::r#simple::positional::internaldafny::types::GetNameInput, >{ ::std::rc::Rc::new(crate::r#simple::positional::internaldafny::types::GetNameInput::GetNameInput { + }) } #[allow(dead_code)] @@ -17,6 +18,7 @@ pub fn from_dafny( >, ) -> crate::operation::get_name::GetNameInput { crate::operation::get_name::GetNameInput::builder() + .build() .unwrap() } diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_output.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_output.rs index 6427e1cd4..e16c795df 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_output.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/get_name/_get_name_output.rs @@ -8,7 +8,7 @@ pub fn to_dafny( crate::r#simple::positional::internaldafny::types::GetNameOutput, >{ ::std::rc::Rc::new(crate::r#simple::positional::internaldafny::types::GetNameOutput::GetNameOutput { - name: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&value.name.unwrap()), + name: crate::standard_library_conversions::ostring_to_dafny(&value.name) .Extract(), }) } #[allow(dead_code)] @@ -18,7 +18,7 @@ pub fn from_dafny( >, ) -> crate::operation::get_name::GetNameOutput { crate::operation::get_name::GetNameOutput::builder() - .set_name(Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(dafny_value.name()))) + .set_name(Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(dafny_value.name()) )) .build() .unwrap() } diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_resource.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_resource.rs index bc65a7f3f..b7f471d0c 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_resource.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/get_resource.rs @@ -1,34 +1,6 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - -use std::any::Any; - -#[allow(dead_code)] -pub fn to_dafny_error( - value: crate::operation::get_resource::GetResourceError, -) -> ::std::rc::Rc< - crate::r#simple::positional::internaldafny::types::Error, -> { - match value { - crate::operation::get_resource::GetResourceError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::r#simple::positional::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) - } -} - -#[allow(dead_code)] -pub fn from_dafny_error( - dafny_value: ::std::rc::Rc< - crate::r#simple::positional::internaldafny::types::Error, - >, -) -> crate::operation::get_resource::GetResourceError { - // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), crate::r#simple::positional::internaldafny::types::Error::CollectionOfErrors { .. }) { - let error_message = "TODO: can't get message yet"; - crate::operation::get_resource::GetResourceError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) - } else { - crate::operation::get_resource::GetResourceError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message("Opaque error").build()) - } -} - +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. pub mod _get_resource_input; -pub mod _get_resource_output; + pub mod _get_resource_output; diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_resource/_get_resource_input.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_resource/_get_resource_input.rs index 81f7f94e4..6f2319daa 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_resource/_get_resource_input.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/get_resource/_get_resource_input.rs @@ -1,29 +1,24 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_resource::GetResourceInput, ) -> ::std::rc::Rc< crate::r#simple::positional::internaldafny::types::GetResourceInput, -> { - let name = value.name().unwrap(); - let name = - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(name); - +>{ ::std::rc::Rc::new(crate::r#simple::positional::internaldafny::types::GetResourceInput::GetResourceInput { - name, + name: crate::standard_library_conversions::ostring_to_dafny(&value.name) .Extract(), }) } - -#[allow(dead_code)] + #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< crate::r#simple::positional::internaldafny::types::GetResourceInput, >, ) -> crate::operation::get_resource::GetResourceInput { - let name = - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - dafny_value.name(), - ); - - crate::operation::get_resource::GetResourceInput { name: Some(name) } + crate::operation::get_resource::GetResourceInput::builder() + .set_name(Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(dafny_value.name()) )) + .build() + .unwrap() } diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional.rs index 873f61631..5fbbbaa0f 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional.rs @@ -1,31 +1,3 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - -use std::any::Any; - -#[allow(dead_code)] -pub fn to_dafny_error( - value: crate::operation::get_resource_positional::GetResourcePositionalError, -) -> ::std::rc::Rc -{ - match value { - crate::operation::get_resource_positional::GetResourcePositionalError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::simple::positional::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) - } -} - -#[allow(dead_code)] -pub fn from_dafny_error( - dafny_value: ::std::rc::Rc< - crate::simple::positional::internaldafny::types::Error, - >, -) -> crate::operation::get_resource_positional::GetResourcePositionalError { - // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), crate::simple::positional::internaldafny::types::Error::CollectionOfErrors { .. }) { - let error_message = "TODO: can't get message yet"; - crate::operation::get_resource_positional::GetResourcePositionalError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) - } else { - crate::operation::get_resource_positional::GetResourcePositionalError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message("Opaque error").build()) - } -} - -pub mod _get_resource_positional_input; +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. diff --git a/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional/_get_resource_positional_input.rs b/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional/_get_resource_positional_input.rs deleted file mode 100644 index ba5bab229..000000000 --- a/TestModels/Positional/runtimes/rust/src/conversions/get_resource_positional/_get_resource_positional_input.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_resource_positional::GetResourcePositionalInput, -) -> ::std::rc::Rc< - crate::r#simple::positional::internaldafny::types::GetResourceInput, -> { - let name = value.name().unwrap(); - let name = - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(name); - - ::std::rc::Rc::new(crate::r#simple::positional::internaldafny::types::GetResourceInput::GetResourceInput { - name, - }) -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::positional::internaldafny::types::GetResourceInput, - >, -) -> crate::operation::get_resource_positional::GetResourcePositionalInput { - let name = - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - dafny_value.name(), - ); - - crate::operation::get_resource_positional::GetResourcePositionalInput { name: Some(name) } -} diff --git a/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config.rs b/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config.rs index 42fe23be6..a119c8127 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config.rs @@ -1,3 +1,4 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. pub mod _simple_positional_config; diff --git a/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config/_simple_positional_config.rs b/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config/_simple_positional_config.rs index f642ca550..e80603837 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config/_simple_positional_config.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/simple_positional_config/_simple_positional_config.rs @@ -1,19 +1,44 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. #[allow(dead_code)] pub fn to_dafny( value: crate::types::simple_positional_config::SimplePositionalConfig, ) -> ::std::rc::Rc< - crate::simple::positional::internaldafny::types::SimplePositionalConfig, ->{ - ::std::rc::Rc::new(crate::simple::positional::internaldafny::types::SimplePositionalConfig::SimplePositionalConfig {}) + crate::r#simple::positional::internaldafny::types::SimplePositionalConfig, +> { + ::std::rc::Rc::new(to_dafny_plain(value)) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::simple::positional::internaldafny::types::SimplePositionalConfig, + crate::r#simple::positional::internaldafny::types::SimplePositionalConfig, >, ) -> crate::types::simple_positional_config::SimplePositionalConfig { - crate::types::simple_positional_config::SimplePositionalConfig {} + plain_from_dafny(&*dafny_value) +} + + +#[allow(dead_code)] +pub fn to_dafny_plain( + value: crate::types::simple_positional_config::SimplePositionalConfig, +) -> crate::r#simple::positional::internaldafny::types::SimplePositionalConfig { + crate::r#simple::positional::internaldafny::types::SimplePositionalConfig::SimplePositionalConfig { + + } +} + +#[allow(dead_code)] +pub fn plain_from_dafny( + dafny_value: &crate::r#simple::positional::internaldafny::types::SimplePositionalConfig, +) -> crate::types::simple_positional_config::SimplePositionalConfig { + match dafny_value { + crate::r#simple::positional::internaldafny::types::SimplePositionalConfig::SimplePositionalConfig {..} => + crate::types::simple_positional_config::SimplePositionalConfig::builder() + + .build() + .unwrap() + } } diff --git a/TestModels/Positional/runtimes/rust/src/conversions/simple_resource.rs b/TestModels/Positional/runtimes/rust/src/conversions/simple_resource.rs index 37f1177c3..b3125aa99 100644 --- a/TestModels/Positional/runtimes/rust/src/conversions/simple_resource.rs +++ b/TestModels/Positional/runtimes/rust/src/conversions/simple_resource.rs @@ -73,7 +73,7 @@ impl crate::simple::positional::internaldafny::types::ISimpleResource ), }, Err(x) => crate::r#_Wrappers_Compile::Result::Failure { - error: crate::conversions::get_name::to_dafny_error(x), + error: crate::conversions::error::to_dafny(x), }, }; ::std::rc::Rc::new(result) @@ -86,7 +86,7 @@ impl crate::types::simple_resource::SimpleResource for ISimpleResourceDafnyWrapp input: crate::operation::get_name::GetNameInput, ) -> Result< crate::operation::get_name::GetNameOutput, - crate::operation::get_name::GetNameError, + crate::types::error::Error, > { let inner_input = crate::conversions::get_name::_get_name_input::to_dafny(input); @@ -101,7 +101,7 @@ impl crate::types::simple_resource::SimpleResource for ISimpleResourceDafnyWrapp ), ) } else { - Err(crate::conversions::get_name::from_dafny_error( + Err(crate::conversions::error::from_dafny( inner_result.error().clone(), )) } diff --git a/TestModels/Positional/runtimes/rust/src/error.rs b/TestModels/Positional/runtimes/rust/src/error.rs index ec89cbecc..4cddaa7c3 100644 --- a/TestModels/Positional/runtimes/rust/src/error.rs +++ b/TestModels/Positional/runtimes/rust/src/error.rs @@ -1,4 +1,6 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. pub use ::aws_smithy_runtime_api::box_error::BoxError; /// Error type returned by the client. diff --git a/TestModels/Positional/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Positional/runtimes/rust/src/error/sealed_unhandled.rs index 4d66eb2ea..eae800729 100644 --- a/TestModels/Positional/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/Positional/runtimes/rust/src/error/sealed_unhandled.rs @@ -1,8 +1,10 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. use std::any::Any; use dafny_runtime::UpcastObject; -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. /// This struct is not intended to be used. /// /// This struct holds information about an unhandled error, @@ -27,4 +29,4 @@ pub struct Unhandled { impl UpcastObject for Unhandled { ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} \ No newline at end of file +} diff --git a/TestModels/Positional/runtimes/rust/src/lib.rs b/TestModels/Positional/runtimes/rust/src/lib.rs deleted file mode 100644 index 2b3564bda..000000000 --- a/TestModels/Positional/runtimes/rust/src/lib.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![allow(deprecated)] - -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - -pub mod client; -pub mod types; - -/// Common errors and error handling utilities. -pub mod error; - -/// All operations that this crate can perform. -pub mod operation; - -mod conversions; - -pub mod implementation_from_dafny; - -#[cfg(feature = "wrapped-client")] -pub mod wrapped; - -pub use client::Client; -pub use types::_simple_resource_reference::SimpleResourceReference; diff --git a/TestModels/Positional/runtimes/rust/src/operation.rs b/TestModels/Positional/runtimes/rust/src/operation.rs index a6d4b5f64..3fbef49ff 100644 --- a/TestModels/Positional/runtimes/rust/src/operation.rs +++ b/TestModels/Positional/runtimes/rust/src/operation.rs @@ -1,10 +1,11 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +/// Types for the `GetName` operation. +pub mod get_name; /// Types for the `GetResource` operation. pub mod get_resource; /// Types for the `GetResourcePositional` operation. pub mod get_resource_positional; - -/// Types for the `GetName` operation. -pub mod get_name; \ No newline at end of file diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_name.rs b/TestModels/Positional/runtimes/rust/src/operation/get_name.rs index 963e924d7..f23b3967e 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_name.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_name.rs @@ -15,110 +15,12 @@ impl GetName { input: crate::operation::get_name::GetNameInput, ) -> ::std::result::Result< crate::operation::get_name::GetNameOutput, - crate::operation::get_name::GetNameError, + crate::types::error::Error, > { simple_resource.inner.borrow_mut().get_name(input) } } -/// Error type for the `GetName` operation. -#[non_exhaustive] -#[derive(::std::fmt::Debug)] -pub enum GetNameError { - /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code). - #[deprecated( - note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \ - variable wildcard pattern and check `.code()`: - \ -    `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }` - \ - See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetNameError) for what information is available for the error." - )] - Unhandled(crate::error::sealed_unhandled::Unhandled), -} -impl GetNameError { - /// Creates the `GetNameError::Unhandled` variant from any error type. - pub fn unhandled( - err: impl ::std::convert::Into< - ::std::boxed::Box< - dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static, - >, - >, - ) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source: err.into(), - meta: ::std::default::Default::default(), - }) - } - - /// Creates the `GetNameError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata). - pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source: err.clone().into(), - meta: err, - }) - } - /// - /// Returns error metadata, which includes the error code, message, - /// request ID, and potentially additional information. - /// - pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata { - match self { - Self::Unhandled(e) => &e.meta, - } - } -} -impl ::std::error::Error for GetNameError { - fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { - match self { - Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source), - } - } -} -impl ::std::fmt::Display for GetNameError { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match self { - Self::Unhandled(_inner) => { - if let ::std::option::Option::Some(code) = - ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) - { - write!(f, "unhandled error ({code})") - } else { - f.write_str("unhandled error") - } - } - } - } -} -impl ::aws_smithy_types::retry::ProvideErrorKind for GetNameError { - fn code(&self) -> ::std::option::Option<&str> { - ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) - } - fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> { - ::std::option::Option::None - } -} -impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetNameError { - fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata { - match self { - Self::Unhandled(_inner) => &_inner.meta, - } - } -} -impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetNameError { - fn create_unhandled_error( - source: ::std::boxed::Box< - dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static, - >, - meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>, - ) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source, - meta: meta.unwrap_or_default(), - }) - } -} - pub use crate::operation::get_name::_get_name_output::GetNameOutput; pub use crate::operation::get_name::_get_name_input::GetNameInput; diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_input.rs b/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_input.rs index ea55f7a37..7b8ed07bf 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_input.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_input.rs @@ -5,8 +5,10 @@ #[non_exhaustive] #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] pub struct GetNameInput { + } impl GetNameInput { + } impl GetNameInput { /// Creates a new builder-style object to manufacture [`GetNameInput`](crate::operation::get_name::builders::GetNameInput). @@ -21,8 +23,10 @@ impl GetNameInput { ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, )] pub struct GetNameInputBuilder { + } impl GetNameInputBuilder { + /// Consumes the builder and constructs a [`GetNameInput`](crate::operation::operation::GetNameInput). pub fn build( self, @@ -31,6 +35,7 @@ impl GetNameInputBuilder { ::aws_smithy_types::error::operation::BuildError, > { ::std::result::Result::Ok(crate::operation::get_name::GetNameInput { + }) } } diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_output.rs b/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_output.rs index 0d1943788..4934d169f 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_output.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_name/_get_name_output.rs @@ -9,7 +9,7 @@ pub struct GetNameOutput { pub name: ::std::option::Option<::std::string::String>, } impl GetNameOutput { -#[allow(missing_docs)] // documentation missing in model + #[allow(missing_docs)] // documentation missing in model pub fn name(&self) -> &::std::option::Option<::std::string::String> { &self.name } @@ -30,7 +30,7 @@ pub struct GetNameOutputBuilder { pub(crate) name: ::std::option::Option<::std::string::String>, } impl GetNameOutputBuilder { -#[allow(missing_docs)] // documentation missing in model + #[allow(missing_docs)] // documentation missing in model pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { self.name = ::std::option::Option::Some(input.into()); self diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_name/builders.rs b/TestModels/Positional/runtimes/rust/src/operation/get_name/builders.rs index 5b803fc7a..76d401021 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_name/builders.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_name/builders.rs @@ -12,7 +12,7 @@ impl GetNameInputBuilder { simple_resource: &crate::types::simple_resource::SimpleResourceRef, ) -> ::std::result::Result< crate::operation::get_name::GetNameOutput, - crate::operation::get_name::GetNameError, + crate::types::error::Error, > { let mut fluent_builder = simple_resource.get_name(); fluent_builder.inner = self; @@ -43,18 +43,20 @@ impl GetNameFluentBuilder { self, ) -> ::std::result::Result< crate::operation::get_name::GetNameOutput, - crate::operation::get_name::GetNameError, + crate::types::error::Error, > { let input = self .inner .build() - // Using unhandled since GetName doesn't declare any validation, - // and smithy-rs seems to not generate a ValidationError case unless there is - // (but isn't that a backwards compatibility problem for output structures?) - // Vanilla smithy-rs uses SdkError::construction_failure, - // but we aren't using SdkError. - .map_err(crate::operation::get_name::GetNameError::unhandled)?; + // Using Opaque since we don't have a validation-specific error yet. + // Operations' models don't declare their own validation error, + // and smithy-rs seems to not generate a ValidationError case unless there is. + // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError. + .map_err(|mut e| crate::types::error::Error::Opaque { + obj: ::dafny_runtime::Object::from_ref(&mut e as &mut dyn ::std::any::Any) + })?; crate::operation::get_name::GetName::send(&self.simple_resource, input).await } + } diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource.rs index 37a984d92..40abe7006 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource.rs @@ -1,4 +1,6 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. /// Orchestration and serialization glue logic for `GetResource`. #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)] #[non_exhaustive] @@ -13,9 +15,9 @@ impl GetResource { input: crate::operation::get_resource::GetResourceInput, ) -> ::std::result::Result< crate::operation::get_resource::GetResourceOutput, - crate::operation::get_resource::GetResourceError, + crate::types::error::Error, > { - let inner_input = crate::conversions::get_resource::_get_resource_input::to_dafny(input); + let inner_input = crate::conversions::get_resource::_get_resource_input::to_dafny(input); let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetResource(&inner_input); if matches!( @@ -23,123 +25,23 @@ impl GetResource { crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( - crate::conversions::get_resource::_get_resource_output::from_dafny( - inner_result.value().clone(), - ), + crate::conversions::get_resource::_get_resource_output::from_dafny(inner_result.value().clone()), ) } else { - Err(crate::conversions::get_resource::from_dafny_error( + Err(crate::conversions::error::from_dafny( inner_result.error().clone(), )) } } } -/// Error type for the `GetResource` operation. -#[non_exhaustive] -#[derive(::std::fmt::Debug)] -pub enum GetResourceError { - /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code). - #[deprecated( - note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \ - variable wildcard pattern and check `.code()`: - \ -    `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }` - \ - See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetResourceError) for what information is available for the error." - )] - Unhandled(crate::error::sealed_unhandled::Unhandled), -} -impl GetResourceError { - /// Creates the `GetResourceError::Unhandled` variant from any error type. - pub fn unhandled( - err: impl ::std::convert::Into< - ::std::boxed::Box< - dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static, - >, - >, - ) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source: err.into(), - meta: ::std::default::Default::default(), - }) - } - - /// Creates the `GetResourceError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata). - pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source: err.clone().into(), - meta: err, - }) - } - /// - /// Returns error metadata, which includes the error code, message, - /// request ID, and potentially additional information. - /// - pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata { - match self { - Self::Unhandled(e) => &e.meta, - } - } -} -impl ::std::error::Error for GetResourceError { - fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { - match self { - Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source), - } - } -} -impl ::std::fmt::Display for GetResourceError { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match self { - Self::Unhandled(_inner) => { - if let ::std::option::Option::Some(code) = - ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) - { - write!(f, "unhandled error ({code})") - } else { - f.write_str("unhandled error") - } - } - } - } -} -impl ::aws_smithy_types::retry::ProvideErrorKind for GetResourceError { - fn code(&self) -> ::std::option::Option<&str> { - ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) - } - fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> { - ::std::option::Option::None - } -} -impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetResourceError { - fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata { - match self { - Self::Unhandled(_inner) => &_inner.meta, - } - } -} -impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetResourceError { - fn create_unhandled_error( - source: ::std::boxed::Box< - dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static, - >, - meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>, - ) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source, - meta: meta.unwrap_or_default(), - }) - } -} - pub use crate::operation::get_resource::_get_resource_output::GetResourceOutput; pub use crate::operation::get_resource::_get_resource_input::GetResourceInput; -mod _get_resource_input; +pub(crate) mod _get_resource_output; -mod _get_resource_output; +pub(crate) mod _get_resource_input; /// Builders pub mod builders; diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_input.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_input.rs index 02ddc7a9c..b6f3a7c3c 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_input.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_input.rs @@ -1,25 +1,27 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. #[allow(missing_docs)] // documentation missing in model #[non_exhaustive] #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] pub struct GetResourceInput { #[allow(missing_docs)] // documentation missing in model - pub name: ::std::option::Option<::std::string::String>, +pub name: ::std::option::Option<::std::string::String>, } impl GetResourceInput { #[allow(missing_docs)] // documentation missing in model - pub fn name(&self) -> ::std::option::Option<&str> { - self.name.as_deref() - } +pub fn name(&self) -> &::std::option::Option<::std::string::String> { + &self.name +} } impl GetResourceInput { - /// Creates a new builder-style object to manufacture [`GetResourceInput`](crate::operation::get_resource::GetResourceInput). + /// Creates a new builder-style object to manufacture [`GetResourceInput`](crate::operation::get_resource::builders::GetResourceInput). pub fn builder() -> crate::operation::get_resource::builders::GetResourceInputBuilder { crate::operation::get_resource::builders::GetResourceInputBuilder::default() } } -/// A builder for [`GetResourceInput`](crate::operation::get_resource::GetResourceInput). +/// A builder for [`GetResourceInput`](crate::operation::operation::GetResourceInput). #[non_exhaustive] #[derive( ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, @@ -29,21 +31,20 @@ pub struct GetResourceInputBuilder { } impl GetResourceInputBuilder { #[allow(missing_docs)] // documentation missing in model - /// This field is required. - pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.name = ::std::option::Option::Some(input.into()); - self - } - #[allow(missing_docs)] // documentation missing in model - pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.name = input; - self - } - #[allow(missing_docs)] // documentation missing in model - pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { - &self.name - } - /// Consumes the builder and constructs a [`GetResourceInput`](crate::operation::get_resource::GetResourceInput). +pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { + self.name = ::std::option::Option::Some(input.into()); + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { + self.name = input; + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { + &self.name +} + /// Consumes the builder and constructs a [`GetResourceInput`](crate::operation::operation::GetResourceInput). pub fn build( self, ) -> ::std::result::Result< diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_output.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_output.rs index e9a02deea..be413f1e2 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_output.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource/_get_resource_output.rs @@ -15,13 +15,13 @@ pub fn output(&self) -> &::std::option::Option crate::operation::get_resource::builders::GetResourceOutputBuilder { crate::operation::get_resource::builders::GetResourceOutputBuilder::default() } } -/// A builder for [`GetResourcesOutput`](crate::operation::operation::GetResourcesOutput). +/// A builder for [`GetResourceOutput`](crate::operation::operation::GetResourceOutput). #[non_exhaustive] #[derive( ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, @@ -44,7 +44,7 @@ pub fn set_output(mut self, input: ::std::option::Option &::std::option::Option { &self.output } - /// Consumes the builder and constructs a [`GetResourcesOutput`](crate::operation::operation::GetResourcesOutput). + /// Consumes the builder and constructs a [`GetResourceOutput`](crate::operation::operation::GetResourceOutput). pub fn build( self, ) -> ::std::result::Result< diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource/builders.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource/builders.rs index a18ac4eae..55991c469 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource/builders.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource/builders.rs @@ -1,16 +1,18 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. pub use crate::operation::get_resource::_get_resource_output::GetResourceOutputBuilder; pub use crate::operation::get_resource::_get_resource_input::GetResourceInputBuilder; -impl crate::operation::get_resource::builders::GetResourceInputBuilder { +impl GetResourceInputBuilder { /// Sends a request with this input using the given client. pub async fn send_with( self, - client: &crate::Client, + client: &crate::client::Client, ) -> ::std::result::Result< crate::operation::get_resource::GetResourceOutput, - crate::operation::get_resource::GetResourceError, + crate::types::error::Error, > { let mut fluent_builder = client.get_resource(); fluent_builder.inner = self; @@ -21,12 +23,11 @@ impl crate::operation::get_resource::builders::GetResourceInputBuilder { /// #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct GetResourceFluentBuilder { - client: crate::Client, - inner: crate::operation::get_resource::builders::GetResourceInputBuilder, + client: crate::client::Client, + pub(crate) inner: crate::operation::get_resource::builders::GetResourceInputBuilder, } - impl GetResourceFluentBuilder { - /// Creates a new `GetResourceFluentBuilder`. + /// Creates a new `GetResource`. pub(crate) fn new(client: crate::client::Client) -> Self { Self { client, @@ -38,43 +39,37 @@ impl GetResourceFluentBuilder { &self.inner } /// Sends the request and returns the response. - /// - /// If an error occurs, an `SdkError` will be returned with additional details that - /// can be matched against. - /// - /// By default, any retryable failures will be retried twice. Retry behavior - /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be - /// set when configuring the client. pub async fn send( self, ) -> ::std::result::Result< crate::operation::get_resource::GetResourceOutput, - crate::operation::get_resource::GetResourceError, + crate::types::error::Error, > { let input = self .inner .build() - // Using unhandled since GetResource doesn't declare any validation, - // and smithy-rs seems to not generate a ValidationError case unless there is - // (but isn't that a backwards compatibility problem for output structures?) - // Vanilla smithy-rs uses SdkError::construction_failure, - // but we aren't using SdkError. - .map_err(crate::operation::get_resource::GetResourceError::unhandled)?; + // Using Opaque since we don't have a validation-specific error yet. + // Operations' models don't declare their own validation error, + // and smithy-rs seems to not generate a ValidationError case unless there is. + // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError. + .map_err(|mut e| crate::types::error::Error::Opaque { + obj: ::dafny_runtime::Object::from_ref(&mut e as &mut dyn ::std::any::Any) + })?; crate::operation::get_resource::GetResource::send(&self.client, input).await } #[allow(missing_docs)] // documentation missing in model - pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.inner = self.inner.name(input.into()); - self - } - #[allow(missing_docs)] // documentation missing in model - pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.inner = self.inner.set_name(input); - self - } - #[allow(missing_docs)] // documentation missing in model - pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { - self.inner.get_name() - } +pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { + self.inner = self.inner.name(input.into()); + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { + self.inner = self.inner.set_name(input); + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { + self.inner.get_name() +} } diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional.rs index 26cef2f06..4176e439b 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional.rs @@ -1,4 +1,6 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. /// Orchestration and serialization glue logic for `GetResourcePositional`. #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)] #[non_exhaustive] @@ -13,129 +15,34 @@ impl GetResourcePositional { input: crate::operation::get_resource_positional::GetResourcePositionalInput, ) -> ::std::result::Result< crate::types::simple_resource::SimpleResourceRef, - crate::operation::get_resource_positional::GetResourcePositionalError, + crate::types::error::Error, > { - let inner_input = crate::conversions::get_resource_positional::_get_resource_positional_input::to_dafny(input); + let inner_input = crate::standard_library_conversions::ostring_to_dafny(&input.name) .Extract(); let inner_result = - ::dafny_runtime::md!(client.dafny_client.clone()).GetResourcePositional(&inner_input.name()); + ::dafny_runtime::md!(client.dafny_client.clone()).GetResourcePositional(&inner_input); if matches!( inner_result.as_ref(), crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::simple_resource::from_dafny(inner_result.value().clone()) +, ) } else { - Err( - crate::conversions::get_resource_positional::from_dafny_error( - inner_result.error().clone(), - ), - ) + Err(crate::conversions::error::from_dafny( + inner_result.error().clone(), + )) } } } -/// Error type for the `GetResourcePositional` operation. -#[non_exhaustive] -#[derive(::std::fmt::Debug)] -pub enum GetResourcePositionalError { - /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code). - #[deprecated( - note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \ - variable wildcard pattern and check `.code()`: - \ -    `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }` - \ - See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetResourcePositionalError) for what information is available for the error." - )] - Unhandled(crate::error::sealed_unhandled::Unhandled), -} -impl GetResourcePositionalError { - /// Creates the `GetResourcePositionalError::Unhandled` variant from any error type. - pub fn unhandled( - err: impl ::std::convert::Into< - ::std::boxed::Box< - dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static, - >, - >, - ) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source: err.into(), - meta: ::std::default::Default::default(), - }) - } - - /// Creates the `GetResourcePositionalError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata). - pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source: err.clone().into(), - meta: err, - }) - } - /// - /// Returns error metadata, which includes the error code, message, - /// request ID, and potentially additional information. - /// - pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata { - match self { - Self::Unhandled(e) => &e.meta, - } - } -} -impl ::std::error::Error for GetResourcePositionalError { - fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { - match self { - Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source), - } - } -} -impl ::std::fmt::Display for GetResourcePositionalError { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match self { - Self::Unhandled(_inner) => { - if let ::std::option::Option::Some(code) = - ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) - { - write!(f, "unhandled error ({code})") - } else { - f.write_str("unhandled error") - } - } - } - } -} -impl ::aws_smithy_types::retry::ProvideErrorKind for GetResourcePositionalError { - fn code(&self) -> ::std::option::Option<&str> { - ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) - } - fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> { - ::std::option::Option::None - } -} -impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetResourcePositionalError { - fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata { - match self { - Self::Unhandled(_inner) => &_inner.meta, - } - } -} -impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetResourcePositionalError { - fn create_unhandled_error( - source: ::std::boxed::Box< - dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static, - >, - meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>, - ) -> Self { - Self::Unhandled(crate::error::sealed_unhandled::Unhandled { - source, - meta: meta.unwrap_or_default(), - }) - } -} +pub use crate::operation::get_resource_positional::_get_resource_positional_output::GetResourcePositionalOutput; pub use crate::operation::get_resource_positional::_get_resource_positional_input::GetResourcePositionalInput; -mod _get_resource_positional_input; +pub(crate) mod _get_resource_positional_output; + +pub(crate) mod _get_resource_positional_input; /// Builders pub mod builders; diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_input.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_input.rs index f1ba26353..4979acb65 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_input.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_input.rs @@ -1,27 +1,27 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. #[allow(missing_docs)] // documentation missing in model #[non_exhaustive] #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] pub struct GetResourcePositionalInput { #[allow(missing_docs)] // documentation missing in model - pub name: ::std::option::Option<::std::string::String>, +pub name: ::std::option::Option<::std::string::String>, } impl GetResourcePositionalInput { #[allow(missing_docs)] // documentation missing in model - pub fn name(&self) -> ::std::option::Option<&str> { - self.name.as_deref() - } +pub fn name(&self) -> &::std::option::Option<::std::string::String> { + &self.name +} } impl GetResourcePositionalInput { - /// Creates a new builder-style object to manufacture [`GetResourcePositionalInput`](crate::operation::get_resource_positional::GetResourcePositionalInput). - pub fn builder( - ) -> crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder - { + /// Creates a new builder-style object to manufacture [`GetResourcePositionalInput`](crate::operation::get_resource_positional::builders::GetResourcePositionalInput). + pub fn builder() -> crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder { crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder::default() } } -/// A builder for [`GetResourcePositionalInput`](crate::operation::get_resource_positional::GetResourcePositionalInput). +/// A builder for [`GetResourcePositionalInput`](crate::operation::operation::GetResourcePositionalInput). #[non_exhaustive] #[derive( ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, @@ -31,31 +31,28 @@ pub struct GetResourcePositionalInputBuilder { } impl GetResourcePositionalInputBuilder { #[allow(missing_docs)] // documentation missing in model - /// This field is required. - pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.name = ::std::option::Option::Some(input.into()); - self - } - #[allow(missing_docs)] // documentation missing in model - pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.name = input; - self - } - #[allow(missing_docs)] // documentation missing in model - pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { - &self.name - } - /// Consumes the builder and constructs a [`GetResourcePositionalInput`](crate::operation::get_resource_positional::GetResourcePositionalInput). +pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { + self.name = ::std::option::Option::Some(input.into()); + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { + self.name = input; + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { + &self.name +} + /// Consumes the builder and constructs a [`GetResourcePositionalInput`](crate::operation::operation::GetResourcePositionalInput). pub fn build( self, ) -> ::std::result::Result< crate::operation::get_resource_positional::GetResourcePositionalInput, ::aws_smithy_types::error::operation::BuildError, > { - ::std::result::Result::Ok( - crate::operation::get_resource_positional::GetResourcePositionalInput { - name: self.name, - }, - ) + ::std::result::Result::Ok(crate::operation::get_resource_positional::GetResourcePositionalInput { + name: self.name, + }) } } diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_output.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_output.rs similarity index 67% rename from TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_output.rs rename to TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_output.rs index 951c20f98..1deb9a7be 100644 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_output.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/_get_resource_positional_output.rs @@ -4,32 +4,32 @@ #[allow(missing_docs)] // documentation missing in model #[non_exhaustive] #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct GetResourcesOutput { +pub struct GetResourcePositionalOutput { #[allow(missing_docs)] // documentation missing in model pub output: ::std::option::Option, } -impl GetResourcesOutput { +impl GetResourcePositionalOutput { #[allow(missing_docs)] // documentation missing in model pub fn output(&self) -> &::std::option::Option { &self.output } } -impl GetResourcesOutput { - /// Creates a new builder-style object to manufacture [`GetResourcesOutput`](crate::operation::get_resources::builders::GetResourcesOutput). - pub fn builder() -> crate::operation::get_resources::builders::GetResourcesOutputBuilder { - crate::operation::get_resources::builders::GetResourcesOutputBuilder::default() +impl GetResourcePositionalOutput { + /// Creates a new builder-style object to manufacture [`GetResourcePositionalOutput`](crate::operation::get_resource_positional::builders::GetResourcePositionalOutput). + pub fn builder() -> crate::operation::get_resource_positional::builders::GetResourcePositionalOutputBuilder { + crate::operation::get_resource_positional::builders::GetResourcePositionalOutputBuilder::default() } } -/// A builder for [`GetResourcesOutput`](crate::operation::operation::GetResourcesOutput). +/// A builder for [`GetResourcePositionalOutput`](crate::operation::operation::GetResourcePositionalOutput). #[non_exhaustive] #[derive( ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, )] -pub struct GetResourcesOutputBuilder { +pub struct GetResourcePositionalOutputBuilder { pub(crate) output: ::std::option::Option, } -impl GetResourcesOutputBuilder { +impl GetResourcePositionalOutputBuilder { #[allow(missing_docs)] // documentation missing in model pub fn output(mut self, input: impl ::std::convert::Into) -> Self { self.output = ::std::option::Option::Some(input.into()); @@ -44,14 +44,14 @@ pub fn set_output(mut self, input: ::std::option::Option &::std::option::Option { &self.output } - /// Consumes the builder and constructs a [`GetResourcesOutput`](crate::operation::operation::GetResourcesOutput). + /// Consumes the builder and constructs a [`GetResourcePositionalOutput`](crate::operation::operation::GetResourcePositionalOutput). pub fn build( self, ) -> ::std::result::Result< - crate::operation::get_resources::GetResourcesOutput, + crate::operation::get_resource_positional::GetResourcePositionalOutput, ::aws_smithy_types::error::operation::BuildError, > { - ::std::result::Result::Ok(crate::operation::get_resources::GetResourcesOutput { + ::std::result::Result::Ok(crate::operation::get_resource_positional::GetResourcePositionalOutput { output: self.output, }) } diff --git a/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/builders.rs b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/builders.rs index 994885e8a..5d8e41c8d 100644 --- a/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/builders.rs +++ b/TestModels/Positional/runtimes/rust/src/operation/get_resource_positional/builders.rs @@ -1,14 +1,18 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +pub use crate::operation::get_resource_positional::_get_resource_positional_output::GetResourcePositionalOutputBuilder; + pub use crate::operation::get_resource_positional::_get_resource_positional_input::GetResourcePositionalInputBuilder; -impl crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder { +impl GetResourcePositionalInputBuilder { /// Sends a request with this input using the given client. pub async fn send_with( self, - client: &crate::Client, + client: &crate::client::Client, ) -> ::std::result::Result< crate::types::simple_resource::SimpleResourceRef, - crate::operation::get_resource_positional::GetResourcePositionalError, + crate::types::error::Error, > { let mut fluent_builder = client.get_resource_positional(); fluent_builder.inner = self; @@ -19,12 +23,11 @@ impl crate::operation::get_resource_positional::builders::GetResourcePositionalI /// #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct GetResourcePositionalFluentBuilder { - client: crate::Client, - inner: crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder, + client: crate::client::Client, + pub(crate) inner: crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder, } - impl GetResourcePositionalFluentBuilder { - /// Creates a new `GetResourcePositionalFluentBuilder`. + /// Creates a new `GetResourcePositional`. pub(crate) fn new(client: crate::client::Client) -> Self { Self { client, @@ -32,55 +35,41 @@ impl GetResourcePositionalFluentBuilder { } } /// Access the GetResourcePositional as a reference. - pub fn as_input( - &self, - ) -> &crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder - { + pub fn as_input(&self) -> &crate::operation::get_resource_positional::builders::GetResourcePositionalInputBuilder { &self.inner } /// Sends the request and returns the response. - /// - /// If an error occurs, an `SdkError` will be returned with additional details that - /// can be matched against. - /// - /// By default, any retryable failures will be retried twice. Retry behavior - /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be - /// set when configuring the client. pub async fn send( self, ) -> ::std::result::Result< crate::types::simple_resource::SimpleResourceRef, - crate::operation::get_resource_positional::GetResourcePositionalError, + crate::types::error::Error, > { let input = self .inner .build() - // Using unhandled since GetResourcePositional doesn't declare any validation, - // and smithy-rs seems to not generate a ValidationError case unless there is - // (but isn't that a backwards compatibility problem for output structures?) - // Vanilla smithy-rs uses SdkError::construction_failure, - // but we aren't using SdkError. - .map_err( - crate::operation::get_resource_positional::GetResourcePositionalError::unhandled, - )?; - crate::operation::get_resource_positional::GetResourcePositional::send(&self.client, input) - .await - } - - #[allow(missing_docs)] // documentation missing in model - pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.inner = self.inner.name(input.into()); - self - } - - #[allow(missing_docs)] // documentation missing in model - pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.inner = self.inner.set_name(input); - self + // Using Opaque since we don't have a validation-specific error yet. + // Operations' models don't declare their own validation error, + // and smithy-rs seems to not generate a ValidationError case unless there is. + // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError. + .map_err(|mut e| crate::types::error::Error::Opaque { + obj: ::dafny_runtime::Object::from_ref(&mut e as &mut dyn ::std::any::Any) + })?; + crate::operation::get_resource_positional::GetResourcePositional::send(&self.client, input).await } #[allow(missing_docs)] // documentation missing in model - pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { - self.inner.get_name() - } +pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { + self.inner = self.inner.name(input.into()); + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { + self.inner = self.inner.set_name(input); + self +} +#[allow(missing_docs)] // documentation missing in model +pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { + self.inner.get_name() +} } diff --git a/TestModels/Positional/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Positional/runtimes/rust/src/standard_library_conversions.rs index 3a51134c6..6bf8297d8 100644 --- a/TestModels/Positional/runtimes/rust/src/standard_library_conversions.rs +++ b/TestModels/Positional/runtimes/rust/src/standard_library_conversions.rs @@ -1,246 +1,266 @@ pub fn ostring_to_dafny( - input: &Option, + input: &Option, ) -> ::std::rc::Rc< - crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, + crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, > { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&b) - }, - None => crate::_Wrappers_Compile::Option::None {}, + let dafny_value = match input { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&b) + }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(dafny_value) + ::std::rc::Rc::new(dafny_value) } pub fn ostring_from_dafny( - input: ::std::rc::Rc< - crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, - >, + input: ::std::rc::Rc< + crate::_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, ) -> Option { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some( - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - &input.Extract(), - ), - ) - } else { - None - } + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( + &input.Extract(), + ), + ) + } else { + None + } } -pub fn obool_to_dafny(input: Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) +pub fn obool_to_dafny( + input: &Option, +) -> ::std::rc::Rc> { + let dafny_value = match input { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: *b }, + None => crate::_Wrappers_Compile::Option::None {}, + }; + ::std::rc::Rc::new(dafny_value) } -pub fn obool_from_dafny(input: ::std::rc::Rc>) -> Option { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some(input.Extract()) - } else { - None - } +pub fn obool_from_dafny( + input: ::std::rc::Rc>, +) -> Option { + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(input.Extract()) + } else { + None + } } pub fn oint_to_dafny(input: Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) + let dafny_value = match input { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, + }; + ::std::rc::Rc::new(dafny_value) } pub fn oint_from_dafny(input: ::std::rc::Rc>) -> Option { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some(input.Extract()) - } else { - None - } + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(input.Extract()) + } else { + None + } } -pub fn olong_to_dafny(input: Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) +pub fn olong_to_dafny(input: &Option) -> ::std::rc::Rc> { + let dafny_value = match input { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: *b }, + None => crate::_Wrappers_Compile::Option::None {}, + }; + ::std::rc::Rc::new(dafny_value) } -pub fn olong_from_dafny(input: ::std::rc::Rc>) -> Option { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some(input.Extract()) - } else { - None - } +pub fn olong_from_dafny( + input: ::std::rc::Rc>, +) -> Option { + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(input.Extract()) + } else { + None + } } -pub fn blob_to_dafny( - input: &::aws_smithy_types::Blob, -) -> ::dafny_runtime::Sequence { - ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&input.clone().into_inner(), |x| *x) +pub fn blob_to_dafny(input: &::aws_smithy_types::Blob) -> ::dafny_runtime::Sequence { + ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&input.clone().into_inner(), |x| *x) } pub fn oblob_to_dafny( - input: &Option<::aws_smithy_types::Blob>, + input: &Option<::aws_smithy_types::Blob>, ) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { - value: blob_to_dafny(&b), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) + let dafny_value = match input { + Some(b) => crate::_Wrappers_Compile::Option::Some { + value: blob_to_dafny(&b), + }, + None => crate::_Wrappers_Compile::Option::None {}, + }; + ::std::rc::Rc::new(dafny_value) } -pub fn blob_from_dafny( - input: ::dafny_runtime::Sequence, -) -> ::aws_smithy_types::Blob { - - ::aws_smithy_types::Blob::new( - ::std::rc::Rc::try_unwrap(input.to_array()) - .unwrap_or_else(|rc| (*rc).clone()), - ) +pub fn blob_from_dafny(input: ::dafny_runtime::Sequence) -> ::aws_smithy_types::Blob { + ::aws_smithy_types::Blob::new( + ::std::rc::Rc::try_unwrap(input.to_array()).unwrap_or_else(|rc| (*rc).clone()), + ) } pub fn oblob_from_dafny( - input: ::std::rc::Rc>>, + input: ::std::rc::Rc>>, ) -> Option<::aws_smithy_types::Blob> { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some(blob_from_dafny(input.Extract())) - } else { - None - } + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(blob_from_dafny(input.Extract())) + } else { + None + } } -pub fn double_to_dafny( - input: f64, -) -> ::dafny_runtime::Sequence { - ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence( - &f64::to_be_bytes(input).to_vec(), - |x| *x) +pub fn double_to_dafny(input: f64) -> ::dafny_runtime::Sequence { + ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence( + &f64::to_be_bytes(input).to_vec(), + |x| *x, + ) } pub fn odouble_to_dafny( - input: &Option, + input: &Option, ) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(f) => crate::_Wrappers_Compile::Option::Some { - value: double_to_dafny(*f), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) + let dafny_value = match input { + Some(f) => crate::_Wrappers_Compile::Option::Some { + value: double_to_dafny(*f), + }, + None => crate::_Wrappers_Compile::Option::None {}, + }; + ::std::rc::Rc::new(dafny_value) } -pub fn double_from_dafny( - input: &::dafny_runtime::Sequence, -) -> f64 { - let v = ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(input, |x| *x); - f64::from_be_bytes(v.try_into().expect("Error converting Sequence to f64")) +pub fn double_from_dafny(input: &::dafny_runtime::Sequence) -> f64 { + let v = ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(input, |x| *x); + f64::from_be_bytes(v.try_into().expect("Error converting Sequence to f64")) } pub fn odouble_from_dafny( - input: ::std::rc::Rc>>, + input: ::std::rc::Rc>>, ) -> Option { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some(double_from_dafny(&input.Extract())) - } else { - None - } + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(double_from_dafny(&input.Extract())) + } else { + None + } } pub fn timestamp_to_dafny( - input: ::aws_smithy_types::DateTime, + input: &::aws_smithy_types::DateTime, ) -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&input.to_string()) + ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( + &input.to_string(), + ) } pub fn otimestamp_to_dafny( - input: &Option<::aws_smithy_types::DateTime>, -) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(f) => crate::_Wrappers_Compile::Option::Some { - value: timestamp_to_dafny(*f), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) + input: &Option<::aws_smithy_types::DateTime>, +) -> ::std::rc::Rc< + crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, +> { + let dafny_value = match input { + Some(f) => crate::_Wrappers_Compile::Option::Some { + value: timestamp_to_dafny(f), + }, + None => crate::_Wrappers_Compile::Option::None {}, + }; + ::std::rc::Rc::new(dafny_value) } pub fn timestamp_from_dafny( - input: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + input: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ) -> ::aws_smithy_types::DateTime { - let s = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&input); - ::aws_smithy_types::DateTime::from_str( - &s, - aws_smithy_types::date_time::Format::DateTime, - ).unwrap() + let s = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( + &input, + ); + ::aws_smithy_types::DateTime::from_str(&s, aws_smithy_types::date_time::Format::DateTime) + .unwrap() } pub fn otimestamp_from_dafny( - input: ::std::rc::Rc>>, + input: ::std::rc::Rc< + crate::_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, ) -> Option<::aws_smithy_types::DateTime> { - if matches!(input.as_ref(), crate::_Wrappers_Compile::Option::Some { .. }) { - Some(timestamp_from_dafny(input.Extract())) - } else { - None - } + if matches!( + input.as_ref(), + crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(timestamp_from_dafny(input.Extract())) + } else { + None + } } pub fn option_from_dafny( - input: ::std::rc::Rc>, - converter: fn(&T) -> TR, + input: ::std::rc::Rc>, + converter: fn(&T) -> TR, ) -> Option { - match &*input { - crate::_Wrappers_Compile::Option::Some { value } => Some(converter(value)), - crate::_Wrappers_Compile::Option::None { } => None, - } + match &*input { + crate::_Wrappers_Compile::Option::Some { value } => Some(converter(value)), + crate::_Wrappers_Compile::Option::None {} => None, + } } pub fn option_to_dafny( - input: &Option, - converter: fn(&TR) -> T, + input: &Option, + converter: fn(&TR) -> T, ) -> ::std::rc::Rc> { - match input { - Some(value) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Option::Some { - value: converter(&value) - } - ), - None => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Option::None {} - ), - } + match input { + Some(value) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Option::Some { + value: converter(&value), + }), + None => ::std::rc::Rc::new(crate::_Wrappers_Compile::Option::None {}), + } } pub fn result_from_dafny( - input: ::std::rc::Rc>, - converter_t: fn(&T) -> TR, - converter_e: fn(&E) -> ER, + input: ::std::rc::Rc>, + converter_t: fn(&T) -> TR, + converter_e: fn(&E) -> ER, ) -> Result { - match &*input { - crate::_Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), - crate::_Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), - } + match &*input { + crate::_Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), + crate::_Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), + } } pub fn result_to_dafny( - input: &Result, - converter_t: fn(&TR) -> T, - converter_e: fn(&ER) -> E, + input: &Result, + converter_t: fn(&TR) -> T, + converter_e: fn(&ER) -> E, ) -> ::std::rc::Rc> { - match input { - Ok(value) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Success { - value: converter_t(&value) - } - ), - Err(error) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Failure { - error: converter_e(&error) - } - ), - } -} \ No newline at end of file + match input { + Ok(value) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Success { + value: converter_t(&value), + }), + Err(error) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Failure { + error: converter_e(&error), + }), + } +} diff --git a/TestModels/Positional/runtimes/rust/src/types.rs b/TestModels/Positional/runtimes/rust/src/types.rs index 392118d8b..4f80ec298 100644 --- a/TestModels/Positional/runtimes/rust/src/types.rs +++ b/TestModels/Positional/runtimes/rust/src/types.rs @@ -1,6 +1,17 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. - +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. /// Types for the `SimplePositionalConfig` pub mod simple_positional_config; +pub mod builders; + pub mod simple_resource; +pub use simple_resource::SimpleResource; + + + +pub mod error; + + + diff --git a/TestModels/Constructor/runtimes/rust/src/types/builders.rs b/TestModels/Positional/runtimes/rust/src/types/builders.rs similarity index 100% rename from TestModels/Constructor/runtimes/rust/src/types/builders.rs rename to TestModels/Positional/runtimes/rust/src/types/builders.rs diff --git a/TestModels/Resource/runtimes/rust/src/types/error.rs b/TestModels/Positional/runtimes/rust/src/types/error.rs similarity index 95% rename from TestModels/Resource/runtimes/rust/src/types/error.rs rename to TestModels/Positional/runtimes/rust/src/types/error.rs index 67cb2262b..347e32214 100644 --- a/TestModels/Resource/runtimes/rust/src/types/error.rs +++ b/TestModels/Positional/runtimes/rust/src/types/error.rs @@ -3,7 +3,7 @@ // Do not modify this file. This file is machine generated, and any changes to it will be overwritten. #[derive(::std::clone::Clone, ::std::fmt::Debug, ::std::cmp::PartialEq)] pub enum Error { - SimpleResourcesException { + SimplePositionalException { message: ::std::string::String, }, CollectionOfErrors { diff --git a/TestModels/Positional/runtimes/rust/src/types/simple_positional_config.rs b/TestModels/Positional/runtimes/rust/src/types/simple_positional_config.rs index 4454ac334..fabdf061b 100644 --- a/TestModels/Positional/runtimes/rust/src/types/simple_positional_config.rs +++ b/TestModels/Positional/runtimes/rust/src/types/simple_positional_config.rs @@ -1,28 +1,41 @@ -// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +#[allow(missing_docs)] // documentation missing in model +#[non_exhaustive] +#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] +pub struct SimplePositionalConfig { -#[derive(::std::clone::Clone, ::std::fmt::Debug)] -pub struct SimplePositionalConfig {} +} +impl SimplePositionalConfig { +} impl SimplePositionalConfig { - pub fn builder() -> SimplePositionalConfigBuilder { - SimplePositionalConfigBuilder::new() + /// Creates a new builder-style object to manufacture [`SimplePositionalConfig`](crate::types::SimplePositionalConfig). + pub fn builder() -> crate::types::simple_positional_config::SimplePositionalConfigBuilder { + crate::types::simple_positional_config::SimplePositionalConfigBuilder::default() } } -#[derive(::std::clone::Clone, ::std::fmt::Debug)] -pub struct SimplePositionalConfigBuilder {} +/// A builder for [`SimplePositionalConfig`](crate::types::SimplePositionalConfig). +#[non_exhaustive] +#[derive( + ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, +)] +pub struct SimplePositionalConfigBuilder { +} impl SimplePositionalConfigBuilder { - /// Creates a new `SimplePositionalConfigBuilder`. - pub(crate) fn new() -> Self { - Self {} - } + + /// Consumes the builder and constructs a [`SimplePositionalConfig`](crate::types::SimplePositionalConfig). pub fn build( self, ) -> ::std::result::Result< - SimplePositionalConfig, + crate::types::simple_positional_config::SimplePositionalConfig, ::aws_smithy_types::error::operation::BuildError, > { - ::std::result::Result::Ok(SimplePositionalConfig {}) + ::std::result::Result::Ok(crate::types::simple_positional_config::SimplePositionalConfig { + + }) } } diff --git a/TestModels/Positional/runtimes/rust/src/types/simple_resource.rs b/TestModels/Positional/runtimes/rust/src/types/simple_resource.rs index b159e3704..736abe4ca 100644 --- a/TestModels/Positional/runtimes/rust/src/types/simple_resource.rs +++ b/TestModels/Positional/runtimes/rust/src/types/simple_resource.rs @@ -4,12 +4,12 @@ pub trait SimpleResource { fn get_name( - &mut self, - input: crate::operation::get_name::GetNameInput, - ) -> Result< - crate::operation::get_name::GetNameOutput, - crate::operation::get_name::GetNameError, - >; + &mut self, + input: crate::operation::get_name::GetNameInput, + ) -> Result< + crate::operation::get_name::GetNameOutput, + crate::types::error::Error, + >; } #[derive(::std::clone::Clone)] @@ -29,4 +29,4 @@ impl ::std::fmt::Debug for SimpleResourceRef { } } -pub mod get_name; \ No newline at end of file +mod get_name; diff --git a/TestModels/Positional/runtimes/rust/src/types/simple_resource/get_name.rs b/TestModels/Positional/runtimes/rust/src/types/simple_resource/get_name.rs index 96e07f1c5..b8d9830dc 100644 --- a/TestModels/Positional/runtimes/rust/src/types/simple_resource/get_name.rs +++ b/TestModels/Positional/runtimes/rust/src/types/simple_resource/get_name.rs @@ -5,8 +5,9 @@ impl crate::types::simple_resource::SimpleResourceRef { /// Constructs a fluent builder for the [`GetName`](crate::operation::get_name::builders::GetNameFluentBuilder) operation. /// /// - The fluent builder is configurable: + /// - On success, responds with [`GetNameOutput`](crate::operation::get_name::GetNameOutput) with field(s): - /// - [`blob_value(Option<::aws_smithy_types::Blob>)`](crate::operation::get_name::GetNameOutput::blob_value): (undocumented) + /// - [`name(Option<::std::string::String>)`](crate::operation::get_name::GetNameOutput::name): (undocumented) /// - On failure, responds with [`SdkError`](crate::operation::get_name::GetNameError) pub fn get_name(&self) -> crate::operation::get_name::builders::GetNameFluentBuilder { crate::operation::get_name::builders::GetNameFluentBuilder::new(self.clone()) diff --git a/TestModels/Positional/runtimes/rust/src/wrapped.rs b/TestModels/Positional/runtimes/rust/src/wrapped.rs index 393551766..1825cf913 100644 --- a/TestModels/Positional/runtimes/rust/src/wrapped.rs +++ b/TestModels/Positional/runtimes/rust/src/wrapped.rs @@ -1 +1,15 @@ -pub mod client; \ No newline at end of file +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +pub mod client; + +impl crate::r#simple::positional::internaldafny::wrapped::_default { + pub fn WrappedSimplePositional(config: &::std::rc::Rc< + crate::r#simple::positional::internaldafny::types::SimplePositionalConfig, + >) -> ::std::rc::Rc, + ::std::rc::Rc + >>{ + crate::wrapped::client::Client::from_conf(config) + } +} diff --git a/TestModels/Positional/runtimes/rust/src/wrapped/client.rs b/TestModels/Positional/runtimes/rust/src/wrapped/client.rs index 70f35e28e..afb989813 100644 --- a/TestModels/Positional/runtimes/rust/src/wrapped/client.rs +++ b/TestModels/Positional/runtimes/rust/src/wrapped/client.rs @@ -1,15 +1,23 @@ -use tokio::runtime::Runtime; +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +use std::sync::LazyLock; pub struct Client { - wrapped: crate::client::Client, - - /// A `current_thread` runtime for executing operations on the - /// asynchronous client in a blocking manner. - rt: Runtime, + wrapped: crate::client::Client } -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::positional::internaldafny::types::ISimplePositionalClient); +/// A runtime for executing operations on the asynchronous client in a blocking manner. +/// Necessary because Dafny only generates synchronous code. +static dafny_tokio_runtime: LazyLock = LazyLock::new(|| { + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() +}); + +impl dafny_runtime::UpcastObject for Client { + ::dafny_runtime::UpcastObjectFn!(dyn crate::r#simple::positional::internaldafny::types::ISimplePositionalClient); } impl dafny_runtime::UpcastObject for Client { @@ -17,70 +25,57 @@ impl dafny_runtime::UpcastObject for Client { } impl Client { - pub fn from_conf(config: &::std::rc::Rc< - crate::simple::positional::internaldafny::types::SimplePositionalConfig, + pub fn from_conf(config: &::std::rc::Rc< + crate::r#simple::positional::internaldafny::types::SimplePositionalConfig, >) -> ::std::rc::Rc, - ::std::rc::Rc - >>{ - let rt_result = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build(); - let rt = match rt_result { - Ok(x) => x, - Err(error) => return crate::conversions::error::to_opaque_error_result(error), + ::dafny_runtime::Object, + ::std::rc::Rc +>> { + let result = crate::client::Client::from_conf( + crate::conversions::simple_positional_config::_simple_positional_config::from_dafny( + config.clone(), + ), + ); + match result { + Ok(client) => { + let wrap = crate::wrapped::client::Client { + wrapped: client }; - let result = crate::client::Client::from_conf( - crate::conversions::simple_positional_config::_simple_positional_config::from_dafny( - config.clone(), - ), - ); - match result { - Ok(client) => { - let wrap = crate::wrapped::client::Client { - wrapped: client, - rt, - }; - std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Success { - value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)), - }, - ) - } - Err(error) => crate::conversions::error::to_opaque_error_result(error), - } + std::rc::Rc::new( + crate::_Wrappers_Compile::Result::Success { + value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) + } + ) + }, + Err(error) => crate::conversions::error::to_opaque_error_result(error) } + } } -impl crate::simple::positional::internaldafny::types::ISimplePositionalClient - for Client -{ +impl crate::r#simple::positional::internaldafny::types::ISimplePositionalClient for Client { fn GetResource( &mut self, - input: &std::rc::Rc< - crate::simple::positional::internaldafny::types::GetResourceInput, - >, + input: &::std::rc::Rc, ) -> std::rc::Rc< crate::r#_Wrappers_Compile::Result< - std::rc::Rc< - crate::simple::positional::internaldafny::types::GetResourceOutput, - >, - std::rc::Rc, + ::std::rc::Rc, + std::rc::Rc, >, >{ - let inner_input = - crate::conversions::get_resource::_get_resource_input::from_dafny(input.clone()); - let result = self.rt.block_on(crate::operation::get_resource::GetResource::send(&self.wrapped, inner_input)); + let inner_input = crate::conversions::get_resource::_get_resource_input::from_dafny(input.clone()); + let result = tokio::task::block_in_place(|| { + dafny_tokio_runtime.block_on(crate::operation::get_resource::GetResource::send(&self.wrapped, inner_input)) + }); match result { Err(error) => ::std::rc::Rc::new( crate::_Wrappers_Compile::Result::Failure { - error: crate::conversions::get_resource::to_dafny_error(error), + error: crate::conversions::error::to_dafny(error), }, ), - Ok(client) => ::std::rc::Rc::new( + Ok(inner_result) => ::std::rc::Rc::new( crate::_Wrappers_Compile::Result::Success { - value: crate::conversions::get_resource::_get_resource_output::to_dafny(client), + value: crate::conversions::get_resource::_get_resource_output::to_dafny(inner_result), }, ), } @@ -88,15 +83,31 @@ impl crate::simple::positional::internaldafny::types::ISimplePositionalClient fn GetResourcePositional( &mut self, - input: &dafny_runtime::Sequence, + input: &::dafny_runtime::dafny_runtime_conversions::DafnySequence<::dafny_runtime::dafny_runtime_conversions::DafnyCharUTF16>, ) -> std::rc::Rc< crate::r#_Wrappers_Compile::Result< - dafny_runtime::Object< - dyn crate::r#simple::positional::internaldafny::types::ISimpleResource, - >, + ::dafny_runtime::Object, std::rc::Rc, >, - > { - todo!() + >{ + let inner_input = crate::operation::get_resource_positional::_get_resource_positional_input::GetResourcePositionalInput { + name: Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(input) ) +}; + let result = tokio::task::block_in_place(|| { + dafny_tokio_runtime.block_on(crate::operation::get_resource_positional::GetResourcePositional::send(&self.wrapped, inner_input)) + }); + match result { + Err(error) => ::std::rc::Rc::new( + crate::_Wrappers_Compile::Result::Failure { + error: crate::conversions::error::to_dafny(error), + }, + ), + Ok(inner_result) => ::std::rc::Rc::new( + crate::_Wrappers_Compile::Result::Success { + value: crate::conversions::simple_resource::to_dafny(inner_result.clone()) +, + }, + ), + } } } diff --git a/TestModels/Resource/runtimes/rust/src/client.rs b/TestModels/Resource/runtimes/rust/src/client.rs deleted file mode 100644 index b1b169cc9..000000000 --- a/TestModels/Resource/runtimes/rust/src/client.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use aws_smithy_types::error::operation::BuildError; - -#[derive(::std::clone::Clone, ::std::fmt::Debug, ::std::cmp::PartialEq)] -pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object -} - -impl Client { - /// Creates a new client from the service [`Config`](crate::Config). - #[track_caller] - pub fn from_conf( - conf: crate::types::simple_resources_config::SimpleResourcesConfig, - ) -> Result { - let inner = - crate::simple::resources::internaldafny::_default::SimpleResources( - &crate::conversions::simple_resources_config::_simple_resources_config::to_dafny(conf), - ); - if matches!( - inner.as_ref(), - crate::_Wrappers_Compile::Result::Failure { .. } - ) { - // TODO: convert error - the potential types are not modeled! - return Err(BuildError::other( - ::aws_smithy_types::error::metadata::ErrorMetadata::builder() - .message("Invalid client config") - .build(), - )); - } - Ok(Self { - dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()) - }) - } -} - -mod get_resources; diff --git a/TestModels/Resource/runtimes/rust/src/client/get_resources.rs b/TestModels/Resource/runtimes/rust/src/client/get_resources.rs deleted file mode 100644 index 95382be39..000000000 --- a/TestModels/Resource/runtimes/rust/src/client/get_resources.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -impl crate::client::Client { - /// Constructs a fluent builder for the [`GetResources`](crate::operation::get_resources::builders::GetResourcesFluentBuilder) operation. - /// - /// - The fluent builder is configurable: - /// - [`value(impl Into>)`](crate::operation::get_resources::builders::GetResourcesFluentBuilder::value) / [`set_value(Option<::std::string::String>)`](crate::operation::get_resources::builders::GetResourcesFluentBuilder::set_value): (undocumented)
- /// - On success, responds with [`GetResourcesOutput`](crate::operation::get_resources::GetResourcesOutput) with field(s): - /// - [`output(Option)`](crate::operation::get_resources::GetResourcesOutput::output): (undocumented) - /// - On failure, responds with [`SdkError`](crate::operation::get_resources::GetResourcesError) - pub fn get_resources(&self) -> crate::operation::get_resources::builders::GetResourcesFluentBuilder { - crate::operation::get_resources::builders::GetResourcesFluentBuilder::new(self.clone()) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions.rs b/TestModels/Resource/runtimes/rust/src/conversions.rs deleted file mode 100644 index cc3d008ca..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub mod client; - - pub mod error; - - pub mod get_resource_data; - - pub mod get_resources; - - pub mod simple_resource; - -pub mod simple_resources_config; diff --git a/TestModels/Resource/runtimes/rust/src/conversions/error.rs b/TestModels/Resource/runtimes/rust/src/conversions/error.rs deleted file mode 100644 index 1ff9b2759..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/error.rs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Wraps up an arbitrary Rust Error value as a Dafny Error -pub fn to_opaque_error(value: E) -> - ::std::rc::Rc -{ - let error_obj: ::dafny_runtime::Object = ::dafny_runtime::Object(Some( - ::std::rc::Rc::new(::std::cell::UnsafeCell::new(value)), - )); - ::std::rc::Rc::new( - crate::r#simple::resources::internaldafny::types::Error::Opaque { - obj: error_obj, - }, - ) -} - -/// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure -pub fn to_opaque_error_result(value: E) -> - ::std::rc::Rc< - crate::_Wrappers_Compile::Result< - T, - ::std::rc::Rc - > - > -{ - ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Failure { - error: to_opaque_error(value), - }) -} -pub fn to_dafny( - value: crate::types::error::Error, -) -> ::std::rc::Rc { - ::std::rc::Rc::new(match value { - crate::types::error::Error::SimpleResourcesException { message } => - crate::r#simple::resources::internaldafny::types::Error::SimpleResourcesException { - message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&message), - }, - crate::types::error::Error::CollectionOfErrors { list, message } => - crate::r#simple::resources::internaldafny::types::Error::CollectionOfErrors { - message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&message), - list: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&list, |e| to_dafny(e.clone())) - }, - crate::types::error::Error::Opaque { obj } => - crate::r#simple::resources::internaldafny::types::Error::Opaque { - obj: ::dafny_runtime::Object(obj.0) - }, - }) -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::Error, - >, -) -> crate::types::error::Error { - match ::std::borrow::Borrow::borrow(&dafny_value) { - crate::r#simple::resources::internaldafny::types::Error::SimpleResourcesException { message } => - crate::types::error::Error::SimpleResourcesException { - message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&message), - }, - crate::r#simple::resources::internaldafny::types::Error::CollectionOfErrors { list, message } => - crate::types::error::Error::CollectionOfErrors { - message: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&message), - list: ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&list, |e| from_dafny(e.clone())) - }, - crate::r#simple::resources::internaldafny::types::Error::Opaque { obj } => - crate::types::error::Error::Opaque { - obj: obj.clone() - }, - } -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs deleted file mode 100644 index a460399dc..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::any::Any; - -pub mod _get_resource_data_input; - -pub mod _get_resource_data_output; diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs deleted file mode 100644 index 5785a8f55..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_resource_data::GetResourceDataInput, -) -> ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourceDataInput, ->{ - ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourceDataInput::GetResourceDataInput { - blobValue: crate::standard_library_conversions::oblob_to_dafny(&value.blob_value), - booleanValue: crate::standard_library_conversions::obool_to_dafny(&value.boolean_value), - stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), - integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), - longValue: crate::standard_library_conversions::olong_to_dafny(&value.long_value), - }) -} - #[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourceDataInput, - >, -) -> crate::operation::get_resource_data::GetResourceDataInput { - crate::operation::get_resource_data::GetResourceDataInput::builder() - .set_blob_value(crate::standard_library_conversions::oblob_from_dafny(dafny_value.blobValue().clone())) - .set_boolean_value(crate::standard_library_conversions::obool_from_dafny(dafny_value.booleanValue().clone())) - .set_string_value(crate::standard_library_conversions::ostring_from_dafny(dafny_value.stringValue().clone())) - .set_integer_value(crate::standard_library_conversions::oint_from_dafny(dafny_value.integerValue().clone())) - .set_long_value(crate::standard_library_conversions::olong_from_dafny(dafny_value.longValue().clone())) - .build() - .unwrap() -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs deleted file mode 100644 index dda4c84dc..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_resource_data::GetResourceDataOutput, -) -> ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, ->{ - ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourceDataOutput::GetResourceDataOutput { - blobValue: crate::standard_library_conversions::oblob_to_dafny(&value.blob_value), - booleanValue: crate::standard_library_conversions::obool_to_dafny(&value.boolean_value), - stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), - integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), - longValue: crate::standard_library_conversions::olong_to_dafny(&value.long_value), - }) -} - #[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, - >, -) -> crate::operation::get_resource_data::GetResourceDataOutput { - crate::operation::get_resource_data::GetResourceDataOutput::builder() - .set_blob_value(crate::standard_library_conversions::oblob_from_dafny(dafny_value.blobValue().clone())) - .set_boolean_value(crate::standard_library_conversions::obool_from_dafny(dafny_value.booleanValue().clone())) - .set_string_value(crate::standard_library_conversions::ostring_from_dafny(dafny_value.stringValue().clone())) - .set_integer_value(crate::standard_library_conversions::oint_from_dafny(dafny_value.integerValue().clone())) - .set_long_value(crate::standard_library_conversions::olong_from_dafny(dafny_value.longValue().clone())) - .build() - .unwrap() -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs deleted file mode 100644 index d1a5d9701..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::any::Any; - -pub mod _get_resources_input; - -pub mod _get_resources_output; diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs deleted file mode 100644 index 87f5b4a8f..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_resources::GetResourcesInput, -) -> ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourcesInput, ->{ - ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourcesInput::GetResourcesInput { - value: crate::standard_library_conversions::ostring_to_dafny(&value.value), - }) -} - #[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourcesInput, - >, -) -> crate::operation::get_resources::GetResourcesInput { - crate::operation::get_resources::GetResourcesInput::builder() - .set_value(crate::standard_library_conversions::ostring_from_dafny(dafny_value.value().clone())) - .build() - .unwrap() -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs deleted file mode 100644 index c1bf7f79e..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::operation::get_resources::GetResourcesOutput, -) -> ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourcesOutput, ->{ - ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourcesOutput::GetResourcesOutput { - output: crate::conversions::simple_resource::to_dafny(value.output.clone().unwrap()) -, - }) -} - #[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourcesOutput, - >, -) -> crate::operation::get_resources::GetResourcesOutput { - crate::operation::get_resources::GetResourcesOutput::builder() - .set_output(Some( crate::conversions::simple_resource::from_dafny(dafny_value.output().clone()) - )) - .build() - .unwrap() -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions/simple_resource.rs b/TestModels/Resource/runtimes/rust/src/conversions/simple_resource.rs deleted file mode 100644 index 3c69c4fe4..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/simple_resource.rs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] -pub fn to_dafny( - value: crate::types::simple_resource::SimpleResourceRef, -) -> ::dafny_runtime::Object< - dyn crate::r#simple::resources::internaldafny::types::ISimpleResource, -> { - let wrap = SimpleResourceWrapper { - obj: value.clone(), - }; - let inner = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); - ::dafny_runtime::Object (Some(inner) ) -} - -pub struct SimpleResourceWrapper { - obj: crate::types::simple_resource::SimpleResourceRef, -} - -impl ::dafny_runtime::UpcastObject for SimpleResourceWrapper { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::dafny_runtime::Object< - dyn crate::r#simple::resources::internaldafny::types::ISimpleResource, - >, -) -> crate::types::simple_resource::SimpleResourceRef { - let wrap = ISimpleResourceDafnyWrapper { - obj: dafny_value.clone(), - }; - crate::types::simple_resource::SimpleResourceRef { - inner: ::std::rc::Rc::new(::std::cell::RefCell::new(wrap)) - } -} - -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct ISimpleResourceDafnyWrapper { - pub(crate) obj: ::dafny_runtime::Object< - dyn crate::r#simple::resources::internaldafny::types::ISimpleResource, - >, -} - - -impl crate::simple::resources::internaldafny::types::ISimpleResource - for SimpleResourceWrapper -{ - fn r#_GetResourceData_k( - &mut self, - input: &::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourceDataInput, - >, - ) -> ::std::rc::Rc< - crate::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, - >, - ::std::rc::Rc, - >, - > - { - let inner_input = - crate::conversions::get_resource_data::_get_resource_data_input::from_dafny( - input.clone(), - ); - let inner_result = self.obj.inner.borrow_mut().get_resource_data(inner_input); - let result = match inner_result { - Ok(x) => crate::r#_Wrappers_Compile::Result::Success { - value: crate::conversions::get_resource_data::_get_resource_data_output::to_dafny( - x, - ), - }, - Err(x) => crate::r#_Wrappers_Compile::Result::Failure { - error: crate::conversions::error::to_dafny(x), - }, - }; - ::std::rc::Rc::new(result) - } -} - -impl crate::types::simple_resource::SimpleResource for ISimpleResourceDafnyWrapper { - fn get_resource_data( - &mut self, - input: crate::operation::get_resource_data::GetResourceDataInput, - ) -> Result< - crate::operation::get_resource_data::GetResourceDataOutput, - crate::types::error::Error, - > { - let inner_input = - crate::conversions::get_resource_data::_get_resource_data_input::to_dafny(input); - let inner_result = ::dafny_runtime::md!(self.obj.clone()).GetResourceData(&inner_input); - if matches!( - inner_result.as_ref(), - crate::r#_Wrappers_Compile::Result::Success { .. } - ) { - Ok( - crate::conversions::get_resource_data::_get_resource_data_output::from_dafny( - inner_result.value().clone(), - ), - ) - } else { - Err(crate::conversions::error::from_dafny( - inner_result.error().clone(), - )) - } - } -} diff --git a/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config.rs b/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config.rs deleted file mode 100644 index 5c42cba41..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config.rs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub mod _simple_resources_config; diff --git a/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs b/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs deleted file mode 100644 index f6220a434..000000000 --- a/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(dead_code)] - -pub fn to_dafny( - value: crate::types::simple_resources_config::SimpleResourcesConfig, -) -> ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, -> { - ::std::rc::Rc::new(to_dafny_plain(value)) -} - -#[allow(dead_code)] -pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, - >, -) -> crate::types::simple_resources_config::SimpleResourcesConfig { - plain_from_dafny(&*dafny_value) -} - - -#[allow(dead_code)] -pub fn to_dafny_plain( - value: crate::types::simple_resources_config::SimpleResourcesConfig, -) -> crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig { - crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig::SimpleResourcesConfig { - name: crate::standard_library_conversions::ostring_to_dafny(&value.name) .Extract(), - } -} - -#[allow(dead_code)] -pub fn plain_from_dafny( - dafny_value: &crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, -) -> crate::types::simple_resources_config::SimpleResourcesConfig { - match dafny_value { - crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig::SimpleResourcesConfig {..} => - crate::types::simple_resources_config::SimpleResourcesConfig::builder() - .set_name(Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(dafny_value.name()) )) - .build() - .unwrap() - } -} diff --git a/TestModels/Resource/runtimes/rust/src/error.rs b/TestModels/Resource/runtimes/rust/src/error.rs deleted file mode 100644 index 4cddaa7c3..000000000 --- a/TestModels/Resource/runtimes/rust/src/error.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub use ::aws_smithy_runtime_api::box_error::BoxError; - -/// Error type returned by the client. -pub type SdkError = - ::aws_smithy_runtime_api::client::result::SdkError; -pub use ::aws_smithy_runtime_api::client::result::ConnectorError; -pub use ::aws_smithy_types::error::operation::BuildError; - -pub use ::aws_smithy_types::error::display::DisplayErrorContext; -pub use ::aws_smithy_types::error::metadata::ErrorMetadata; -pub use ::aws_smithy_types::error::metadata::ProvideErrorMetadata; - -pub(crate) mod sealed_unhandled; diff --git a/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs deleted file mode 100644 index eae800729..000000000 --- a/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::any::Any; - -use dafny_runtime::UpcastObject; - -/// This struct is not intended to be used. -/// -/// This struct holds information about an unhandled error, -/// but that information should be obtained by using the -/// [`ProvideErrorMetadata`](::aws_smithy_types::error::metadata::ProvideErrorMetadata) trait -/// on the error type. -/// -/// This struct intentionally doesn't yield any useful information itself. -#[deprecated( - note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \ -variable wildcard pattern and check `.code()`: - \ -   `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }` - \ -See [`ProvideErrorMetadata`](::aws_smithy_types::error::metadata::ProvideErrorMetadata) for what information is available for the error." -)] -#[derive(Debug)] -pub struct Unhandled { - pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, - pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, -} - -impl UpcastObject for Unhandled { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} diff --git a/TestModels/Resource/runtimes/rust/src/operation.rs b/TestModels/Resource/runtimes/rust/src/operation.rs deleted file mode 100644 index 215d8086d..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Types for the `GetResourceData` operation. -pub mod get_resource_data; - -/// Types for the `GetResources` operation. -pub mod get_resources; diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data.rs deleted file mode 100644 index 10f735077..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Orchestration and serialization glue logic for `GetResourceData`. -#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)] -#[non_exhaustive] -pub struct GetResourceData; -impl GetResourceData { - /// Creates a new `GetResourceData` - pub fn new() -> Self { - Self - } - pub(crate) async fn send( - simple_resource: &crate::types::simple_resource::SimpleResourceRef, - input: crate::operation::get_resource_data::GetResourceDataInput, - ) -> ::std::result::Result< - crate::operation::get_resource_data::GetResourceDataOutput, - crate::types::error::Error, - > { - simple_resource.inner.borrow_mut().get_resource_data(input) - } -} - -pub use crate::operation::get_resource_data::_get_resource_data_output::GetResourceDataOutput; - -pub use crate::operation::get_resource_data::_get_resource_data_input::GetResourceDataInput; - -pub(crate) mod _get_resource_data_output; - -pub(crate) mod _get_resource_data_input; - -/// Builders -pub mod builders; diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs deleted file mode 100644 index 4fdf71b56..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct GetResourceDataInput { - #[allow(missing_docs)] // documentation missing in model -pub blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -#[allow(missing_docs)] // documentation missing in model -pub boolean_value: ::std::option::Option<::std::primitive::bool>, -#[allow(missing_docs)] // documentation missing in model -pub integer_value: ::std::option::Option<::std::primitive::i32>, -#[allow(missing_docs)] // documentation missing in model -pub long_value: ::std::option::Option<::std::primitive::i64>, -#[allow(missing_docs)] // documentation missing in model -pub string_value: ::std::option::Option<::std::string::String>, -} -impl GetResourceDataInput { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} -} -impl GetResourceDataInput { - /// Creates a new builder-style object to manufacture [`GetResourceDataInput`](crate::operation::get_resource_data::builders::GetResourceDataInput). - pub fn builder() -> crate::operation::get_resource_data::builders::GetResourceDataInputBuilder { - crate::operation::get_resource_data::builders::GetResourceDataInputBuilder::default() - } -} - -/// A builder for [`GetResourceDataInput`](crate::operation::operation::GetResourceDataInput). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct GetResourceDataInputBuilder { - pub(crate) blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -pub(crate) boolean_value: ::std::option::Option<::std::primitive::bool>, -pub(crate) integer_value: ::std::option::Option<::std::primitive::i32>, -pub(crate) long_value: ::std::option::Option<::std::primitive::i64>, -pub(crate) string_value: ::std::option::Option<::std::string::String>, -} -impl GetResourceDataInputBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(mut self, input: impl ::std::convert::Into<::aws_smithy_types::Blob>) -> Self { - self.blob_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_blob_value(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self { - self.blob_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(mut self, input: impl ::std::convert::Into<::std::primitive::bool>) -> Self { - self.boolean_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_boolean_value(mut self, input: ::std::option::Option<::std::primitive::bool>) -> Self { - self.boolean_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(mut self, input: impl ::std::convert::Into<::std::primitive::i32>) -> Self { - self.integer_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_integer_value(mut self, input: ::std::option::Option<::std::primitive::i32>) -> Self { - self.integer_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(mut self, input: impl ::std::convert::Into<::std::primitive::i64>) -> Self { - self.long_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_long_value(mut self, input: ::std::option::Option<::std::primitive::i64>) -> Self { - self.long_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.string_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_string_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.string_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} - /// Consumes the builder and constructs a [`GetResourceDataInput`](crate::operation::operation::GetResourceDataInput). - pub fn build( - self, - ) -> ::std::result::Result< - crate::operation::get_resource_data::GetResourceDataInput, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::operation::get_resource_data::GetResourceDataInput { - blob_value: self.blob_value, -boolean_value: self.boolean_value, -integer_value: self.integer_value, -long_value: self.long_value, -string_value: self.string_value, - }) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs deleted file mode 100644 index 548987f0f..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct GetResourceDataOutput { - #[allow(missing_docs)] // documentation missing in model -pub blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -#[allow(missing_docs)] // documentation missing in model -pub boolean_value: ::std::option::Option<::std::primitive::bool>, -#[allow(missing_docs)] // documentation missing in model -pub integer_value: ::std::option::Option<::std::primitive::i32>, -#[allow(missing_docs)] // documentation missing in model -pub long_value: ::std::option::Option<::std::primitive::i64>, -#[allow(missing_docs)] // documentation missing in model -pub string_value: ::std::option::Option<::std::string::String>, -} -impl GetResourceDataOutput { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} -} -impl GetResourceDataOutput { - /// Creates a new builder-style object to manufacture [`GetResourceDataOutput`](crate::operation::get_resource_data::builders::GetResourceDataOutput). - pub fn builder() -> crate::operation::get_resource_data::builders::GetResourceDataOutputBuilder { - crate::operation::get_resource_data::builders::GetResourceDataOutputBuilder::default() - } -} - -/// A builder for [`GetResourceDataOutput`](crate::operation::operation::GetResourceDataOutput). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct GetResourceDataOutputBuilder { - pub(crate) blob_value: ::std::option::Option<::aws_smithy_types::Blob>, -pub(crate) boolean_value: ::std::option::Option<::std::primitive::bool>, -pub(crate) integer_value: ::std::option::Option<::std::primitive::i32>, -pub(crate) long_value: ::std::option::Option<::std::primitive::i64>, -pub(crate) string_value: ::std::option::Option<::std::string::String>, -} -impl GetResourceDataOutputBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(mut self, input: impl ::std::convert::Into<::aws_smithy_types::Blob>) -> Self { - self.blob_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_blob_value(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self { - self.blob_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - &self.blob_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(mut self, input: impl ::std::convert::Into<::std::primitive::bool>) -> Self { - self.boolean_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_boolean_value(mut self, input: ::std::option::Option<::std::primitive::bool>) -> Self { - self.boolean_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - &self.boolean_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(mut self, input: impl ::std::convert::Into<::std::primitive::i32>) -> Self { - self.integer_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_integer_value(mut self, input: ::std::option::Option<::std::primitive::i32>) -> Self { - self.integer_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - &self.integer_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(mut self, input: impl ::std::convert::Into<::std::primitive::i64>) -> Self { - self.long_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_long_value(mut self, input: ::std::option::Option<::std::primitive::i64>) -> Self { - self.long_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - &self.long_value -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.string_value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_string_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.string_value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_string_value(&self) -> &::std::option::Option<::std::string::String> { - &self.string_value -} - /// Consumes the builder and constructs a [`GetResourceDataOutput`](crate::operation::operation::GetResourceDataOutput). - pub fn build( - self, - ) -> ::std::result::Result< - crate::operation::get_resource_data::GetResourceDataOutput, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::operation::get_resource_data::GetResourceDataOutput { - blob_value: self.blob_value, -boolean_value: self.boolean_value, -integer_value: self.integer_value, -long_value: self.long_value, -string_value: self.string_value, - }) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs deleted file mode 100644 index f54ccef25..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub use crate::operation::get_resource_data::_get_resource_data_output::GetResourceDataOutputBuilder; - -pub use crate::operation::get_resource_data::_get_resource_data_input::GetResourceDataInputBuilder; - -impl GetResourceDataInputBuilder { - /// Sends a request with this input using the given client. - pub async fn send_with( - self, - simple_resource: &crate::types::simple_resource::SimpleResourceRef, - ) -> ::std::result::Result< - crate::operation::get_resource_data::GetResourceDataOutput, - crate::types::error::Error, - > { - let mut fluent_builder = simple_resource.get_resource_data(); - fluent_builder.inner = self; - fluent_builder.send().await - } -} -/// Fluent builder constructing a request to `GetResourceData`. -/// -#[derive(::std::clone::Clone, ::std::fmt::Debug)] -pub struct GetResourceDataFluentBuilder { - simple_resource: crate::types::simple_resource::SimpleResourceRef, - pub(crate) inner: crate::operation::get_resource_data::builders::GetResourceDataInputBuilder, -} -impl GetResourceDataFluentBuilder { - /// Creates a new `GetResourceData`. - pub(crate) fn new(simple_resource: crate::types::simple_resource::SimpleResourceRef) -> Self { - Self { - simple_resource, - inner: ::std::default::Default::default(), - } - } - /// Access the GetResourceData as a reference. - pub fn as_input(&self) -> &crate::operation::get_resource_data::builders::GetResourceDataInputBuilder { - &self.inner - } - /// Sends the request and returns the response. - pub async fn send( - self, - ) -> ::std::result::Result< - crate::operation::get_resource_data::GetResourceDataOutput, - crate::types::error::Error, - > { - let input = self - .inner - .build() - // Using Opaque since we don't have a validation-specific error yet. - // Operations' models don't declare their own validation error, - // and smithy-rs seems to not generate a ValidationError case unless there is. - // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError. - .map_err(|mut e| crate::types::error::Error::Opaque { - obj: ::dafny_runtime::Object::from_ref(&mut e as &mut dyn ::std::any::Any) - })?; - crate::operation::get_resource_data::GetResourceData::send(&self.simple_resource, input).await - } - - #[allow(missing_docs)] // documentation missing in model -pub fn blob_value(mut self, input: impl ::std::convert::Into<::aws_smithy_types::Blob>) -> Self { - self.inner = self.inner.blob_value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_blob_value(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self { - self.inner = self.inner.set_blob_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_blob_value(&self) -> &::std::option::Option<::aws_smithy_types::Blob> { - self.inner.get_blob_value() -} -#[allow(missing_docs)] // documentation missing in model -pub fn boolean_value(mut self, input: impl ::std::convert::Into<::std::primitive::bool>) -> Self { - self.inner = self.inner.boolean_value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_boolean_value(mut self, input: ::std::option::Option<::std::primitive::bool>) -> Self { - self.inner = self.inner.set_boolean_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_boolean_value(&self) -> &::std::option::Option<::std::primitive::bool> { - self.inner.get_boolean_value() -} -#[allow(missing_docs)] // documentation missing in model -pub fn integer_value(mut self, input: impl ::std::convert::Into<::std::primitive::i32>) -> Self { - self.inner = self.inner.integer_value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_integer_value(mut self, input: ::std::option::Option<::std::primitive::i32>) -> Self { - self.inner = self.inner.set_integer_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_integer_value(&self) -> &::std::option::Option<::std::primitive::i32> { - self.inner.get_integer_value() -} -#[allow(missing_docs)] // documentation missing in model -pub fn long_value(mut self, input: impl ::std::convert::Into<::std::primitive::i64>) -> Self { - self.inner = self.inner.long_value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_long_value(mut self, input: ::std::option::Option<::std::primitive::i64>) -> Self { - self.inner = self.inner.set_long_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_long_value(&self) -> &::std::option::Option<::std::primitive::i64> { - self.inner.get_long_value() -} -#[allow(missing_docs)] // documentation missing in model -pub fn string_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.inner = self.inner.string_value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_string_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.inner = self.inner.set_string_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_string_value(&self) -> &::std::option::Option<::std::string::String> { - self.inner.get_string_value() -} -} diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs deleted file mode 100644 index 76395bf79..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Orchestration and serialization glue logic for `GetResources`. -#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)] -#[non_exhaustive] -pub struct GetResources; -impl GetResources { - /// Creates a new `GetResources` - pub fn new() -> Self { - Self - } - pub(crate) async fn send( - client: &crate::client::Client, - input: crate::operation::get_resources::GetResourcesInput, - ) -> ::std::result::Result< - crate::operation::get_resources::GetResourcesOutput, - crate::types::error::Error, - > { - let inner_input = crate::conversions::get_resources::_get_resources_input::to_dafny(input); - let inner_result = - ::dafny_runtime::md!(client.dafny_client.clone()).GetResources(&inner_input); - if matches!( - inner_result.as_ref(), - crate::r#_Wrappers_Compile::Result::Success { .. } - ) { - Ok( - crate::conversions::get_resources::_get_resources_output::from_dafny( - inner_result.value().clone(), - ), - ) - } else { - Err(crate::conversions::error::from_dafny( - inner_result.error().clone(), - )) - } - } -} - -pub use crate::operation::get_resources::_get_resources_output::GetResourcesOutput; - -pub use crate::operation::get_resources::_get_resources_input::GetResourcesInput; - -pub(crate) mod _get_resources_output; - -pub(crate) mod _get_resources_input; - -/// Builders -pub mod builders; diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_input.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_input.rs deleted file mode 100644 index dfc1cf86b..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resources/_get_resources_input.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct GetResourcesInput { - #[allow(missing_docs)] // documentation missing in model -pub value: ::std::option::Option<::std::string::String>, -} -impl GetResourcesInput { - #[allow(missing_docs)] // documentation missing in model -pub fn value(&self) -> &::std::option::Option<::std::string::String> { - &self.value -} -} -impl GetResourcesInput { - /// Creates a new builder-style object to manufacture [`GetResourcesInput`](crate::operation::get_resources::builders::GetResourcesInput). - pub fn builder() -> crate::operation::get_resources::builders::GetResourcesInputBuilder { - crate::operation::get_resources::builders::GetResourcesInputBuilder::default() - } -} - -/// A builder for [`GetResourcesInput`](crate::operation::operation::GetResourcesInput). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct GetResourcesInputBuilder { - pub(crate) value: ::std::option::Option<::std::string::String>, -} -impl GetResourcesInputBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.value = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.value = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_value(&self) -> &::std::option::Option<::std::string::String> { - &self.value -} - /// Consumes the builder and constructs a [`GetResourcesInput`](crate::operation::operation::GetResourcesInput). - pub fn build( - self, - ) -> ::std::result::Result< - crate::operation::get_resources::GetResourcesInput, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::operation::get_resources::GetResourcesInput { - value: self.value, - }) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resources/builders.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resources/builders.rs deleted file mode 100644 index c2294e392..000000000 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resources/builders.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub use crate::operation::get_resources::_get_resources_output::GetResourcesOutputBuilder; - -pub use crate::operation::get_resources::_get_resources_input::GetResourcesInputBuilder; - -impl GetResourcesInputBuilder { - /// Sends a request with this input using the given client. - pub async fn send_with( - self, - client: &crate::client::Client, - ) -> ::std::result::Result< - crate::operation::get_resources::GetResourcesOutput, - crate::types::error::Error, - > { - let mut fluent_builder = client.get_resources(); - fluent_builder.inner = self; - fluent_builder.send().await - } -} -/// Fluent builder constructing a request to `GetResources`. -/// -#[derive(::std::clone::Clone, ::std::fmt::Debug)] -pub struct GetResourcesFluentBuilder { - client: crate::client::Client, - pub(crate) inner: crate::operation::get_resources::builders::GetResourcesInputBuilder, -} -impl GetResourcesFluentBuilder { - /// Creates a new `GetResources`. - pub(crate) fn new(client: crate::client::Client) -> Self { - Self { - client, - inner: ::std::default::Default::default(), - } - } - /// Access the GetResources as a reference. - pub fn as_input(&self) -> &crate::operation::get_resources::builders::GetResourcesInputBuilder { - &self.inner - } - /// Sends the request and returns the response. - pub async fn send( - self, - ) -> ::std::result::Result< - crate::operation::get_resources::GetResourcesOutput, - crate::types::error::Error, - > { - let input = self - .inner - .build() - // Using Opaque since we don't have a validation-specific error yet. - // Operations' models don't declare their own validation error, - // and smithy-rs seems to not generate a ValidationError case unless there is. - // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError. - .map_err(|mut e| crate::types::error::Error::Opaque { - obj: ::dafny_runtime::Object::from_ref(&mut e as &mut dyn ::std::any::Any) - })?; - crate::operation::get_resources::GetResources::send(&self.client, input).await - } - - #[allow(missing_docs)] // documentation missing in model -pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.inner = self.inner.value(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.inner = self.inner.set_value(input); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_value(&self) -> &::std::option::Option<::std::string::String> { - self.inner.get_value() -} -} diff --git a/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs deleted file mode 100644 index 6bf8297d8..000000000 --- a/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs +++ /dev/null @@ -1,266 +0,0 @@ -pub fn ostring_to_dafny( - input: &Option, -) -> ::std::rc::Rc< - crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, -> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&b) - }, - None => crate::_Wrappers_Compile::Option::None {}, -}; - ::std::rc::Rc::new(dafny_value) -} - -pub fn ostring_from_dafny( - input: ::std::rc::Rc< - crate::_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some( - dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - &input.Extract(), - ), - ) - } else { - None - } -} - -pub fn obool_to_dafny( - input: &Option, -) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: *b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn obool_from_dafny( - input: ::std::rc::Rc>, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(input.Extract()) - } else { - None - } -} - -pub fn oint_to_dafny(input: Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn oint_from_dafny(input: ::std::rc::Rc>) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(input.Extract()) - } else { - None - } -} - -pub fn olong_to_dafny(input: &Option) -> ::std::rc::Rc> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { value: *b }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn olong_from_dafny( - input: ::std::rc::Rc>, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(input.Extract()) - } else { - None - } -} - -pub fn blob_to_dafny(input: &::aws_smithy_types::Blob) -> ::dafny_runtime::Sequence { - ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&input.clone().into_inner(), |x| *x) -} - -pub fn oblob_to_dafny( - input: &Option<::aws_smithy_types::Blob>, -) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(b) => crate::_Wrappers_Compile::Option::Some { - value: blob_to_dafny(&b), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn blob_from_dafny(input: ::dafny_runtime::Sequence) -> ::aws_smithy_types::Blob { - ::aws_smithy_types::Blob::new( - ::std::rc::Rc::try_unwrap(input.to_array()).unwrap_or_else(|rc| (*rc).clone()), - ) -} - -pub fn oblob_from_dafny( - input: ::std::rc::Rc>>, -) -> Option<::aws_smithy_types::Blob> { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(blob_from_dafny(input.Extract())) - } else { - None - } -} - -pub fn double_to_dafny(input: f64) -> ::dafny_runtime::Sequence { - ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence( - &f64::to_be_bytes(input).to_vec(), - |x| *x, - ) -} - -pub fn odouble_to_dafny( - input: &Option, -) -> ::std::rc::Rc>> { - let dafny_value = match input { - Some(f) => crate::_Wrappers_Compile::Option::Some { - value: double_to_dafny(*f), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn double_from_dafny(input: &::dafny_runtime::Sequence) -> f64 { - let v = ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(input, |x| *x); - f64::from_be_bytes(v.try_into().expect("Error converting Sequence to f64")) -} - -pub fn odouble_from_dafny( - input: ::std::rc::Rc>>, -) -> Option { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(double_from_dafny(&input.Extract())) - } else { - None - } -} - -pub fn timestamp_to_dafny( - input: &::aws_smithy_types::DateTime, -) -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &input.to_string(), - ) -} - -pub fn otimestamp_to_dafny( - input: &Option<::aws_smithy_types::DateTime>, -) -> ::std::rc::Rc< - crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>, -> { - let dafny_value = match input { - Some(f) => crate::_Wrappers_Compile::Option::Some { - value: timestamp_to_dafny(f), - }, - None => crate::_Wrappers_Compile::Option::None {}, - }; - ::std::rc::Rc::new(dafny_value) -} - -pub fn timestamp_from_dafny( - input: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -) -> ::aws_smithy_types::DateTime { - let s = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( - &input, - ); - ::aws_smithy_types::DateTime::from_str(&s, aws_smithy_types::date_time::Format::DateTime) - .unwrap() -} - -pub fn otimestamp_from_dafny( - input: ::std::rc::Rc< - crate::_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, -) -> Option<::aws_smithy_types::DateTime> { - if matches!( - input.as_ref(), - crate::_Wrappers_Compile::Option::Some { .. } - ) { - Some(timestamp_from_dafny(input.Extract())) - } else { - None - } -} - -pub fn option_from_dafny( - input: ::std::rc::Rc>, - converter: fn(&T) -> TR, -) -> Option { - match &*input { - crate::_Wrappers_Compile::Option::Some { value } => Some(converter(value)), - crate::_Wrappers_Compile::Option::None {} => None, - } -} - -pub fn option_to_dafny( - input: &Option, - converter: fn(&TR) -> T, -) -> ::std::rc::Rc> { - match input { - Some(value) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Option::Some { - value: converter(&value), - }), - None => ::std::rc::Rc::new(crate::_Wrappers_Compile::Option::None {}), - } -} - -pub fn result_from_dafny( - input: ::std::rc::Rc>, - converter_t: fn(&T) -> TR, - converter_e: fn(&E) -> ER, -) -> Result { - match &*input { - crate::_Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), - crate::_Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), - } -} - -pub fn result_to_dafny( - input: &Result, - converter_t: fn(&TR) -> T, - converter_e: fn(&ER) -> E, -) -> ::std::rc::Rc> { - match input { - Ok(value) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Success { - value: converter_t(&value), - }), - Err(error) => ::std::rc::Rc::new(crate::_Wrappers_Compile::Result::Failure { - error: converter_e(&error), - }), - } -} diff --git a/TestModels/Resource/runtimes/rust/src/standard_library_externs.rs b/TestModels/Resource/runtimes/rust/src/standard_library_externs.rs deleted file mode 100644 index eca6a2980..000000000 --- a/TestModels/Resource/runtimes/rust/src/standard_library_externs.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Annotation to ignore the case of this module -use crate::r#_Wrappers_Compile; -use crate::UTF8; - -impl crate::UTF8::_default { - pub fn Encode( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - r#_Wrappers_Compile::Result< - UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - let v = s.to_array(); - let mut _accumulator: Vec = vec![]; - // Use of .encode_utf8 method. - let mut surrogate: Option = None; - for c in v.iter() { - let s = if let Some(s) = surrogate { - String::from_utf16(&[s, c.0]) - } else { - String::from_utf16(&[c.0]) - }; - surrogate = None; - match s { - Ok(value) => { - _accumulator.extend(value.as_bytes()); - continue; - } - Err(e) => { - if 0xD800 <= c.0 && c.0 <= 0xDFFF { - surrogate = Some(c.0); - continue; - } - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &e.to_string()) - }); - } - } - } - if let Some(s) = surrogate { - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &format!("Surrogate pair missing: 0x{:04x}", s)) - }); - } - ::std::rc::Rc::new(r#_Wrappers_Compile::Result::< - UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Success { - value: ::dafny_runtime::Sequence::from_array_owned(_accumulator), - }) - } - pub fn Decode( - b: &::dafny_runtime::Sequence, - ) -> ::std::rc::Rc< - r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - let b = String::from_utf8(b.to_array().as_ref().clone()); - match b { - Ok(s) => { - ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success { - value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) - }) - }, - Err(e) => { - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &e.to_string()) - }) - } - } - } -} diff --git a/TestModels/Resource/runtimes/rust/src/types.rs b/TestModels/Resource/runtimes/rust/src/types.rs deleted file mode 100644 index 877860a2f..000000000 --- a/TestModels/Resource/runtimes/rust/src/types.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -/// Types for the `SimpleResourcesConfig` -pub mod simple_resources_config; - -pub mod builders; - -pub mod simple_resource; -pub use simple_resource::SimpleResource; - - - -pub mod error; - - - diff --git a/TestModels/Resource/runtimes/rust/src/types/builders.rs b/TestModels/Resource/runtimes/rust/src/types/builders.rs deleted file mode 100644 index 5fbbbaa0f..000000000 --- a/TestModels/Resource/runtimes/rust/src/types/builders.rs +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. diff --git a/TestModels/Resource/runtimes/rust/src/types/simple_resource.rs b/TestModels/Resource/runtimes/rust/src/types/simple_resource.rs deleted file mode 100644 index 0ec80b2fc..000000000 --- a/TestModels/Resource/runtimes/rust/src/types/simple_resource.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. - -pub trait SimpleResource { - fn get_resource_data( - &mut self, - input: crate::operation::get_resource_data::GetResourceDataInput, - ) -> Result< - crate::operation::get_resource_data::GetResourceDataOutput, - crate::types::error::Error, - >; -} - -#[derive(::std::clone::Clone)] -pub struct SimpleResourceRef { - pub inner: ::std::rc::Rc> -} - -impl ::std::cmp::PartialEq for SimpleResourceRef { - fn eq(&self, other: &SimpleResourceRef) -> bool { - ::std::rc::Rc::ptr_eq(&self.inner, &other.inner) - } -} - -impl ::std::fmt::Debug for SimpleResourceRef { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "") - } -} - -mod get_resource_data; diff --git a/TestModels/Resource/runtimes/rust/src/types/simple_resource/get_resource_data.rs b/TestModels/Resource/runtimes/rust/src/types/simple_resource/get_resource_data.rs deleted file mode 100644 index f141744ae..000000000 --- a/TestModels/Resource/runtimes/rust/src/types/simple_resource/get_resource_data.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -impl crate::types::simple_resource::SimpleResourceRef { - /// Constructs a fluent builder for the [`GetResourceData`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder) operation. - /// - /// - The fluent builder is configurable: - /// - [`blob_value(impl Into>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::blob_value) / [`set_blob_value(Option<::aws_smithy_types::Blob>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::set_blob_value): (undocumented)
- /// - [`boolean_value(impl Into>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::boolean_value) / [`set_boolean_value(Option<::std::primitive::bool>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::set_boolean_value): (undocumented)
- /// - [`integer_value(impl Into>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::integer_value) / [`set_integer_value(Option<::std::primitive::i32>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::set_integer_value): (undocumented)
- /// - [`long_value(impl Into>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::long_value) / [`set_long_value(Option<::std::primitive::i64>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::set_long_value): (undocumented)
- /// - [`string_value(impl Into>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::string_value) / [`set_string_value(Option<::std::string::String>)`](crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::set_string_value): (undocumented)
- /// - On success, responds with [`GetResourceDataOutput`](crate::operation::get_resource_data::GetResourceDataOutput) with field(s): - /// - [`blob_value(Option<::aws_smithy_types::Blob>)`](crate::operation::get_resource_data::GetResourceDataOutput::blob_value): (undocumented) - /// - [`boolean_value(Option<::std::primitive::bool>)`](crate::operation::get_resource_data::GetResourceDataOutput::boolean_value): (undocumented) - /// - [`integer_value(Option<::std::primitive::i32>)`](crate::operation::get_resource_data::GetResourceDataOutput::integer_value): (undocumented) - /// - [`long_value(Option<::std::primitive::i64>)`](crate::operation::get_resource_data::GetResourceDataOutput::long_value): (undocumented) - /// - [`string_value(Option<::std::string::String>)`](crate::operation::get_resource_data::GetResourceDataOutput::string_value): (undocumented) - /// - On failure, responds with [`SdkError`](crate::operation::get_resource_data::GetResourceDataError) - pub fn get_resource_data(&self) -> crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder { - crate::operation::get_resource_data::builders::GetResourceDataFluentBuilder::new(self.clone()) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/types/simple_resources_config.rs b/TestModels/Resource/runtimes/rust/src/types/simple_resources_config.rs deleted file mode 100644 index 5ec179b0e..000000000 --- a/TestModels/Resource/runtimes/rust/src/types/simple_resources_config.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -#[allow(missing_docs)] // documentation missing in model -#[non_exhaustive] -#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] -pub struct SimpleResourcesConfig { - #[allow(missing_docs)] // documentation missing in model -pub name: ::std::option::Option<::std::string::String>, -} -impl SimpleResourcesConfig { - #[allow(missing_docs)] // documentation missing in model -pub fn name(&self) -> &::std::option::Option<::std::string::String> { - &self.name -} -} -impl SimpleResourcesConfig { - /// Creates a new builder-style object to manufacture [`SimpleResourcesConfig`](crate::types::SimpleResourcesConfig). - pub fn builder() -> crate::types::simple_resources_config::SimpleResourcesConfigBuilder { - crate::types::simple_resources_config::SimpleResourcesConfigBuilder::default() - } -} - -/// A builder for [`SimpleResourcesConfig`](crate::types::SimpleResourcesConfig). -#[non_exhaustive] -#[derive( - ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug, -)] -pub struct SimpleResourcesConfigBuilder { - pub(crate) name: ::std::option::Option<::std::string::String>, -} -impl SimpleResourcesConfigBuilder { - #[allow(missing_docs)] // documentation missing in model -pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self { - self.name = ::std::option::Option::Some(input.into()); - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self { - self.name = input; - self -} -#[allow(missing_docs)] // documentation missing in model -pub fn get_name(&self) -> &::std::option::Option<::std::string::String> { - &self.name -} - /// Consumes the builder and constructs a [`SimpleResourcesConfig`](crate::types::SimpleResourcesConfig). - pub fn build( - self, - ) -> ::std::result::Result< - crate::types::simple_resources_config::SimpleResourcesConfig, - ::aws_smithy_types::error::operation::BuildError, - > { - ::std::result::Result::Ok(crate::types::simple_resources_config::SimpleResourcesConfig { - name: self.name, - }) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/wrapped.rs b/TestModels/Resource/runtimes/rust/src/wrapped.rs deleted file mode 100644 index 2d71c843c..000000000 --- a/TestModels/Resource/runtimes/rust/src/wrapped.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -pub mod client; - -impl crate::r#simple::resources::internaldafny::wrapped::_default { - pub fn WrappedSimpleResources(config: &::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, - >) -> ::std::rc::Rc, - ::std::rc::Rc - >>{ - crate::wrapped::client::Client::from_conf(config) - } -} diff --git a/TestModels/Resource/runtimes/rust/src/wrapped/client.rs b/TestModels/Resource/runtimes/rust/src/wrapped/client.rs deleted file mode 100644 index 56d7c7866..000000000 --- a/TestModels/Resource/runtimes/rust/src/wrapped/client.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. -use std::sync::LazyLock; - -pub struct Client { - wrapped: crate::client::Client -} - -/// A runtime for executing operations on the asynchronous client in a blocking manner. -/// Necessary because Dafny only generates synchronous code. -static dafny_tokio_runtime: LazyLock = LazyLock::new(|| { - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap() -}); - -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn crate::r#simple::resources::internaldafny::types::ISimpleResourcesClient); -} - -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} - -impl Client { - pub fn from_conf(config: &::std::rc::Rc< - crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, - >) -> -::std::rc::Rc, - ::std::rc::Rc ->> { - let result = crate::client::Client::from_conf( - crate::conversions::simple_resources_config::_simple_resources_config::from_dafny( - config.clone(), - ), - ); - match result { - Ok(client) => { - let wrap = crate::wrapped::client::Client { - wrapped: client - }; - std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Success { - value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) - } - ) - }, - Err(error) => crate::conversions::error::to_opaque_error_result(error) - } - } -} - -impl crate::r#simple::resources::internaldafny::types::ISimpleResourcesClient for Client { - fn GetResources( - &mut self, - input: &std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourcesInput, - >, - ) -> std::rc::Rc< - crate::r#_Wrappers_Compile::Result< - std::rc::Rc< - crate::r#simple::resources::internaldafny::types::GetResourcesOutput, - >, - std::rc::Rc, - >, - >{ - let inner_input = - crate::conversions::get_resources::_get_resources_input::from_dafny(input.clone()); - let result = tokio::task::block_in_place(|| { - dafny_tokio_runtime.block_on(crate::operation::get_resources::GetResources::send(&self.wrapped, inner_input)) - }); - match result { - Err(error) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Failure { - error: crate::conversions::error::to_dafny(error), - }, - ), - Ok(client) => ::std::rc::Rc::new( - crate::_Wrappers_Compile::Result::Success { - value: crate::conversions::get_resources::_get_resources_output::to_dafny(client), - }, - ), - } - } -} diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/AbstractRustShimGenerator.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/AbstractRustShimGenerator.java index 0a84160b1..2dbfe19f4 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/AbstractRustShimGenerator.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/AbstractRustShimGenerator.java @@ -15,6 +15,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import software.amazon.polymorph.traits.DafnyUtf8BytesTrait; +import software.amazon.polymorph.traits.PositionalTrait; import software.amazon.polymorph.traits.ReferenceTrait; import software.amazon.polymorph.utils.IOUtils; import software.amazon.polymorph.utils.MapUtils; @@ -992,6 +993,60 @@ protected HashMap operationVariables( ); } + final StructureShape inputShape = operationIndex + .getInputShape(operationShape) + .get(); + variables.put( + "operationInputType", + evalTemplate( + "crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationInputName:L", + variables + ) + ); + if (inputShape.hasTrait(PositionalTrait.class)) { + Shape resolvedInputShape = model.expectShape( + ModelUtils.resolveShape(inputShape, model).resolvedId() + ); + variables.put( + "operationDafnyInputType", + rustTypeForShape(resolvedInputShape) + ); + } else { + Map inputShapeVariables = structureVariables(inputShape); + variables.put( + "operationDafnyInputType", + evalTemplate( + "crate::r#$dafnyTypesModuleName:L::$structureName:L", + inputShapeVariables + ) + ); + } + + final StructureShape outputShape = operationIndex + .getOutputShape(operationShape) + .get(); + if (outputShape.hasTrait(PositionalTrait.class)) { + variables.put("operationOutputType", rustTypeForShape(outputShape)); + } else { + variables.put( + "operationOutputType", + evalTemplate( + "crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationOutputName:L", + variables + ) + ); + Map outputShapeVariables = structureVariables( + outputShape + ); + variables.put( + "operationDafnyOutputType", + evalTemplate( + "crate::r#$dafnyTypesModuleName:L::$structureName:L", + outputShapeVariables + ) + ); + } + return variables; } @@ -1160,4 +1215,223 @@ protected String rustResourceTraitName(final ResourceShape resource) { protected String dafnyResourceTraitName(final ResourceShape resource) { return "I" + resourceName(resource); } + + protected String unionName(final UnionShape unionShape) { + return unionShape.getId().getName(service); + } + + protected String rustUnionName(final UnionShape unionShape) { + return toPascalCase(unionName(unionShape)); + } + + protected String qualifiedRustUnionName(final UnionShape unionShape) { + return "%s::types::%s".formatted( + topLevelNameForShape(unionShape), + rustUnionName(unionShape) + ); + } + + /** + * Generates values for variables commonly used in union-specific templates. + */ + protected HashMap unionVariables( + final UnionShape unionShape + ) { + final HashMap variables = new HashMap<>(); + final String unionName = unionName(unionShape); + variables.put("unionName", unionName); + variables.put("snakeCaseUnionName", toSnakeCase(unionName)); + variables.put("dafnyUnionName", unionName); + variables.put("rustUnionName", rustUnionName(unionShape)); + variables.put("qualifiedRustUnionName", qualifiedRustUnionName(unionShape)); + return variables; + } + + protected String unionMemberName(final MemberShape memberShape) { + return memberShape.getMemberName(); + } + + protected String rustUnionMemberName(final MemberShape memberShape) { + return toPascalCase(unionMemberName(memberShape)); + } + + protected String dafnyUnionMemberName(final MemberShape memberShape) { + return unionMemberName(memberShape); + } + + /** + * Generates values for variables commonly used in union-member-specific templates. + */ + protected HashMap unionMemberVariables( + final MemberShape memberShape + ) { + final String memberName = unionMemberName(memberShape); + final Shape targetShape = model.expectShape(memberShape.getTarget()); + + final HashMap variables = new HashMap<>(); + variables.put("unionMemberName", memberName); + variables.put("snakeCaseUnionMemberName", toSnakeCase(memberName)); + variables.put("dafnyUnionMemberName", dafnyUnionMemberName(memberShape)); + variables.put("rustUnionMemberName", rustUnionMemberName(memberShape)); + variables.put("unionMemberType", rustTypeForShape(targetShape)); + return variables; + } + + protected String rustTypeForShape(final Shape originalShape) { + // First handle indirection like @reference + final ModelUtils.ResolvedShapeId resolvedShapeId = ModelUtils.resolveShape( + originalShape, + model + ); + final Shape shape = model.expectShape(resolvedShapeId.resolvedId()); + + return switch (shape.getType()) { + case BOOLEAN -> "::std::primitive::bool"; + // integral + case BYTE -> "::std::primitive::i8"; + case SHORT -> "::std::primitive::i16"; + case INTEGER -> "::std::primitive::i32"; + case LONG -> "::std::primitive::i64"; + // floats + case FLOAT -> "::std::primitive::f32"; + case DOUBLE -> "::std::primitive::f64"; + // special numerics + case BIG_INTEGER -> "::num::bigint::BigInt"; + case BIG_DECIMAL -> "::num::rational::BigRational"; + // special collections + case BLOB -> "::aws_smithy_types::Blob"; + case STRING -> { + //noinspection deprecation + if (shape.hasTrait(EnumTrait.class)) { + yield qualifiedRustEnumType( + ModelUtils.stringToEnumShape(shape.asStringShape().orElseThrow()) + ); + } + yield "::std::string::String"; + } + case ENUM -> qualifiedRustEnumType(shape.asEnumShape().orElseThrow()); + // other simple shapes + case TIMESTAMP -> "::aws_smithy_types::DateTime"; + // aggregates + case STRUCTURE -> { + final StructureShape structureShape = (StructureShape) shape; + yield qualifiedRustStructureType(structureShape); + } + case LIST -> { + final ListShape listShape = (ListShape) shape; + final String memberType = rustTypeForShape( + model.expectShape(listShape.getMember().getTarget()) + ); + yield "::std::vec::Vec<%s>".formatted(memberType); + } + case MAP -> { + final MapShape mapShape = (MapShape) shape; + final String keyType = rustTypeForShape( + model.expectShape(mapShape.getKey().getTarget()) + ); + final String valueType = rustTypeForShape( + model.expectShape(mapShape.getValue().getTarget()) + ); + yield "::std::collections::HashMap<%s, %s>".formatted( + keyType, + valueType + ); + } + case UNION -> qualifiedRustUnionName((UnionShape) shape); + case RESOURCE -> qualifiedRustResourceType((ResourceShape) shape); + case SERVICE -> qualifiedRustServiceType((ServiceShape) shape); + default -> throw new UnsupportedOperationException( + "Unsupported shape type: " + shape.getType() + ); + }; + } + + protected String dafnyTypeForShape(final Shape originalShape) { + // First handle indirection like @reference and @positional + final ModelUtils.ResolvedShapeId resolvedShapeId = ModelUtils.resolveShape( + originalShape, + model + ); + final Shape shape = model.expectShape(resolvedShapeId.resolvedId()); + + return switch (shape.getType()) { + case BOOLEAN -> "::std::primitive::bool"; + // integral + case BYTE -> "::std::primitive::i8"; + case SHORT -> "::std::primitive::i16"; + case INTEGER -> "::std::primitive::i32"; + case LONG -> "::std::primitive::i64"; + // floats + case FLOAT -> "::std::primitive::f32"; + case DOUBLE -> "::std::primitive::f64"; + // special numerics + case BIG_INTEGER -> "::num::bigint::BigInt"; + case BIG_DECIMAL -> "::num::rational::BigRational"; + // special collections + case BLOB -> "::dafny_runtime::dafny_runtime_conversions::DafnySequence"; + case STRING -> { + //noinspection deprecation + if (shape.hasTrait(EnumTrait.class)) { + yield dafnyTypeForShape( + ModelUtils.stringToEnumShape(shape.asStringShape().orElseThrow()) + ); + } + yield "::dafny_runtime::dafny_runtime_conversions::DafnySequence<::dafny_runtime::dafny_runtime_conversions::DafnyCharUTF16>"; + } + case ENUM -> getDafnyTypesModuleName() + + "::" + + enumName((EnumShape) shape); + // other simple shapes + case TIMESTAMP -> "::dafny_runtime::dafny_runtime_conversions::DafnySequence<::dafny_runtime::dafny_runtime_conversions::DafnyCharUTF16>"; + // aggregates + case LIST -> { + final ListShape listShape = (ListShape) shape; + final String memberType = dafnyTypeForShape( + model.expectShape(listShape.getMember().getTarget()) + ); + yield "::dafny_runtime::dafny_runtime_conversions::DafnySequence<%s>".formatted( + memberType + ); + } + case MAP -> { + final MapShape mapShape = (MapShape) shape; + final String keyType = dafnyTypeForShape( + model.expectShape(mapShape.getKey().getTarget()) + ); + final String valueType = dafnyTypeForShape( + model.expectShape(mapShape.getValue().getTarget()) + ); + yield "::dafny_runtime::dafny_runtime_conversions::DafnyMap<%s, %s>".formatted( + keyType, + valueType + ); + } + case STRUCTURE -> "::std::rc::Rc"; + case UNION -> "::std::rc::Rc"; + case RESOURCE -> "::dafny_runtime::Object"; + case SERVICE -> { + ServiceShape service = (ServiceShape) shape; + yield "::dafny_runtime::Object"; + } + default -> throw new UnsupportedOperationException( + "Unsupported shape type: " + shape.getType() + ); + }; + } } diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustLibraryShimGenerator.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustLibraryShimGenerator.java index aba326157..2801f0c60 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustLibraryShimGenerator.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustLibraryShimGenerator.java @@ -10,10 +10,13 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; import software.amazon.polymorph.traits.DafnyUtf8BytesTrait; import software.amazon.polymorph.traits.LocalServiceTrait; +import software.amazon.polymorph.traits.PositionalTrait; import software.amazon.polymorph.traits.ReferenceTrait; import software.amazon.polymorph.utils.IOUtils; import software.amazon.polymorph.utils.MapUtils; @@ -624,6 +627,48 @@ private RustFile operationOuterModule(final OperationShape operationShape) { .getBindingShape(operationShape) .get(); if (bindingShape.isServiceShape()) { + StructureShape inputShape = operationIndex + .getInputShape(operationShape) + .get(); + if (inputShape.hasTrait(PositionalTrait.class)) { + // Need to fetch the single member and then convert, + // since on the Rust side there is still an input structure + // but not on the Dafny side. + final MemberShape onlyMember = PositionalTrait.onlyMember(inputShape); + final String rustValue = + "input." + toSnakeCase(onlyMember.getMemberName()); + variables.put( + "inputToDafny", + toDafny(inputShape, rustValue, true, false).toString() + ); + } else { + variables.put( + "inputToDafny", + evalTemplate( + "crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationInputName:L::to_dafny(input)", + variables + ) + ); + } + + StructureShape outputShape = operationIndex + .getOutputShape(operationShape) + .get(); + if (inputShape.hasTrait(PositionalTrait.class)) { + variables.put( + "outputFromDafny", + fromDafny(outputShape, "inner_result.value()", false, false) + .toString() + ); + } else { + variables.put( + "outputFromDafny", + evalTemplate( + "crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationOutputName:L::from_dafny(inner_result.value().clone())", + variables + ) + ); + } variables.put( "operationSendBody", IOUtils.evalTemplate( @@ -1126,24 +1171,52 @@ protected Set operationConversionModules( final String operationModuleName = toSnakeCase( operationName(operationShape) ); - final String outerContent = IOUtils.evalTemplate( - getClass(), - "runtimes/rust/conversions/operation.rs", - variables - ); - final RustFile outerModule = new RustFile( - Path.of("src", "conversions", operationModuleName + ".rs"), - TokenTree.of(outerContent) - ); - final RustFile requestModule = operationRequestConversionModule( + Optional inputStructure = operationIndex.getOutputShape( operationShape ); - final RustFile responseModule = operationResponseConversionModule( + final boolean hasInputStructure = + inputStructure.isPresent() && + !inputStructure.get().hasTrait(PositionalTrait.class); + Optional outputStructure = operationIndex.getOutputShape( operationShape ); + final boolean hasOutputStructure = + outputStructure.isPresent() && + !outputStructure.get().hasTrait(PositionalTrait.class); - return Set.of(outerModule, requestModule, responseModule); + final Set childModules = new HashSet<>(); + if (hasInputStructure) { + childModules.add( + "_" + variables.get("snakeCaseSyntheticOperationInputName") + ); + } + if (hasOutputStructure) { + childModules.add( + "_" + variables.get("snakeCaseSyntheticOperationOutputName") + ); + } + final RustFile outerModule = new RustFile( + Path.of("src", "conversions", operationModuleName + ".rs"), + declarePubModules(childModules.stream()) + ); + + Set result = new HashSet<>(Set.of(outerModule)); + + if (hasInputStructure) { + final RustFile requestModule = operationRequestConversionModule( + operationShape + ); + result.add(requestModule); + } + if (hasOutputStructure) { + final RustFile responseModule = operationResponseConversionModule( + operationShape + ); + result.add(responseModule); + } + + return result; } @Override @@ -1231,6 +1304,7 @@ private TokenTree operationStructureFromDafnyFunction( structureId, StructureShape.class ); + final boolean isPositional = structureShape.hasTrait(PositionalTrait.class); final Map variables = MapUtils.merge( serviceVariables(), operationVariables(operationShape), @@ -1241,25 +1315,46 @@ private TokenTree operationStructureFromDafnyFunction( fluentMemberSettersForStructure(structureShape).toString() ); - // unwrap() is safe as long as the builder is infallible - return TokenTree.of( - evalTemplate( - """ - #[allow(dead_code)] - pub fn from_dafny( - dafny_value: ::std::rc::Rc< - crate::r#$dafnyTypesModuleName:L::$structureName:L, - >, - ) -> crate::operation::$snakeCaseOperationName:L::$rustStructureName:L { - crate::operation::$snakeCaseOperationName:L::$rustStructureName:L::builder() - $fluentMemberSetters:L - .build() - .unwrap() - } - """, - variables - ) - ); + if (isPositional) { + return TokenTree.of( + evalTemplate( + """ + #[allow(dead_code)] + pub fn from_dafny( + dafny_value: ::std::rc::Rc< + crate::r#$dafnyTypesModuleName:L::$structureName:L, + >, + ) -> crate::operation::$snakeCaseOperationName:L::$rustStructureName:L { + crate::operation::$snakeCaseOperationName:L::$rustStructureName:L::builder() + $fluentMemberSetters:L + .build() + .unwrap() + } + """, + variables + ) + ); + } else { + // unwrap() is safe as long as the builder is infallible + return TokenTree.of( + evalTemplate( + """ + #[allow(dead_code)] + pub fn from_dafny( + dafny_value: ::std::rc::Rc< + crate::r#$dafnyTypesModuleName:L::$structureName:L, + >, + ) -> crate::operation::$snakeCaseOperationName:L::$rustStructureName:L { + crate::operation::$snakeCaseOperationName:L::$rustStructureName:L::builder() + $fluentMemberSetters:L + .build() + .unwrap() + } + """, + variables + ) + ); + } } private RustFile wrappedModule() { @@ -1297,6 +1392,61 @@ private String wrappedClientOperationImpl( serviceVariables(), operationVariables(operationShape) ); + + StructureShape inputShape = operationIndex + .getInputShape(operationShape) + .get(); + if (inputShape.hasTrait(PositionalTrait.class)) { + // Need to wrap the single member after converting, + // since on the Rust side there is still an input structure + // but not on the Dafny side. + final MemberShape onlyMember = PositionalTrait.onlyMember(inputShape); + variables.put("memberName", toSnakeCase(onlyMember.getMemberName())); + variables.put( + "dafnyValue", + fromDafny(inputShape, "input", true, false).toString() + ); + variables.put( + "inputFromDafny", + evalTemplate( + """ + crate::operation::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationInputName:L::$syntheticOperationInputName:L { + $memberName:L: $dafnyValue:L + } + """, + variables + ) + ); + } else { + variables.put( + "inputFromDafny", + evalTemplate( + "crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationInputName:L::from_dafny(input.clone())", + variables + ) + ); + } + variables.put("operationInputDafnyType", dafnyTypeForShape(inputShape)); + + StructureShape outputShape = operationIndex + .getOutputShape(operationShape) + .get(); + if (inputShape.hasTrait(PositionalTrait.class)) { + variables.put( + "outputToDafny", + toDafny(outputShape, "inner_result", false, false).toString() + ); + } else { + variables.put( + "outputToDafny", + evalTemplate( + "crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationOutputName:L::to_dafny(inner_result)", + variables + ) + ); + } + variables.put("operationOutputDafnyType", dafnyTypeForShape(outputShape)); + return IOUtils.evalTemplate( getClass(), "runtimes/rust/wrapped/client_operation_impl.part.rs", @@ -1395,136 +1545,6 @@ protected HashMap errorVariables( return variables; } - protected String unionName(final UnionShape unionShape) { - return unionShape.getId().getName(service); - } - - protected String rustUnionName(final UnionShape unionShape) { - return toPascalCase(unionName(unionShape)); - } - - protected String qualifiedRustUnionName(final UnionShape unionShape) { - return "%s::types::%s".formatted( - topLevelNameForShape(unionShape), - rustUnionName(unionShape) - ); - } - - /** - * Generates values for variables commonly used in union-specific templates. - */ - protected HashMap unionVariables( - final UnionShape unionShape - ) { - final HashMap variables = new HashMap<>(); - final String unionName = unionName(unionShape); - variables.put("unionName", unionName); - variables.put("snakeCaseUnionName", toSnakeCase(unionName)); - variables.put("dafnyUnionName", unionName); - variables.put("rustUnionName", rustUnionName(unionShape)); - variables.put("qualifiedRustUnionName", qualifiedRustUnionName(unionShape)); - return variables; - } - - protected String unionMemberName(final MemberShape memberShape) { - return memberShape.getMemberName(); - } - - protected String rustUnionMemberName(final MemberShape memberShape) { - return toPascalCase(unionMemberName(memberShape)); - } - - protected String dafnyUnionMemberName(final MemberShape memberShape) { - return unionMemberName(memberShape); - } - - /** - * Generates values for variables commonly used in union-member-specific templates. - */ - protected HashMap unionMemberVariables( - final MemberShape memberShape - ) { - final String memberName = unionMemberName(memberShape); - final Shape targetShape = model.expectShape(memberShape.getTarget()); - - final HashMap variables = new HashMap<>(); - variables.put("unionMemberName", memberName); - variables.put("snakeCaseUnionMemberName", toSnakeCase(memberName)); - variables.put("dafnyUnionMemberName", dafnyUnionMemberName(memberShape)); - variables.put("rustUnionMemberName", rustUnionMemberName(memberShape)); - variables.put("unionMemberType", rustTypeForShape(targetShape)); - return variables; - } - - private String rustTypeForShape(final Shape originalShape) { - // First handle indirection like @reference - final ModelUtils.ResolvedShapeId resolvedShapeId = ModelUtils.resolveShape( - originalShape, - model - ); - final Shape shape = model.expectShape(resolvedShapeId.resolvedId()); - - return switch (shape.getType()) { - case BOOLEAN -> "::std::primitive::bool"; - // integral - case BYTE -> "::std::primitive::i8"; - case SHORT -> "::std::primitive::i16"; - case INTEGER -> "::std::primitive::i32"; - case LONG -> "::std::primitive::i64"; - // floats - case FLOAT -> "::std::primitive::f32"; - case DOUBLE -> "::std::primitive::f64"; - // special numerics - case BIG_INTEGER -> "::num::bigint::BigInt"; - case BIG_DECIMAL -> "::num::rational::BigRational"; - // special collections - case BLOB -> "::aws_smithy_types::Blob"; - case STRING -> { - //noinspection deprecation - if (shape.hasTrait(EnumTrait.class)) { - yield qualifiedRustEnumType( - ModelUtils.stringToEnumShape(shape.asStringShape().orElseThrow()) - ); - } - yield "::std::string::String"; - } - case ENUM -> qualifiedRustEnumType(shape.asEnumShape().orElseThrow()); - // other simple shapes - case TIMESTAMP -> "::aws_smithy_types::DateTime"; - // aggregates - case STRUCTURE -> { - final StructureShape structureShape = (StructureShape) shape; - yield qualifiedRustStructureType(structureShape); - } - case LIST -> { - final ListShape listShape = (ListShape) shape; - final String memberType = rustTypeForShape( - model.expectShape(listShape.getMember().getTarget()) - ); - yield "::std::vec::Vec<%s>".formatted(memberType); - } - case MAP -> { - final MapShape mapShape = (MapShape) shape; - final String keyType = rustTypeForShape( - model.expectShape(mapShape.getKey().getTarget()) - ); - final String valueType = rustTypeForShape( - model.expectShape(mapShape.getValue().getTarget()) - ); - yield "::std::collections::HashMap<%s, %s>".formatted( - keyType, - valueType - ); - } - case UNION -> qualifiedRustUnionName((UnionShape) shape); - case RESOURCE -> qualifiedRustResourceType((ResourceShape) shape); - case SERVICE -> qualifiedRustServiceType((ServiceShape) shape); - default -> throw new UnsupportedOperationException( - "Unsupported shape type: " + shape.getType() - ); - }; - } - protected boolean isRustFieldRequired( final StructureShape parent, final MemberShape member diff --git a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/conversions/resource_operation.rs b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/conversions/resource_operation.rs index b40060313..c1eb642d2 100644 --- a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/conversions/resource_operation.rs +++ b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/conversions/resource_operation.rs @@ -2,7 +2,7 @@ impl crate::$dafnyTypesModuleName:L::$dafnyResourceName:L for $rustResourceName:LWrapper { - fn r#_GetResourceData_k( + fn r#_$operationName:L_k( &mut self, input: &::std::rc::Rc< crate::r#$dafnyTypesModuleName:L::$pascalCaseOperationInputName:L, @@ -36,7 +36,7 @@ impl crate::$dafnyTypesModuleName:L::$dafnyResourceName:L } impl crate::types::$snakeCaseResourceName:L::$rustResourceName:L for $dafnyResourceName:LDafnyWrapper { - fn get_resource_data( + fn $snakeCaseOperationName:L( &mut self, input: crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationInputName:L, ) -> Result< diff --git a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/builders.rs b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/builders.rs index 103382956..0ab705fdf 100644 --- a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/builders.rs +++ b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/builders.rs @@ -8,7 +8,7 @@ impl $pascalCaseOperationInputName:LBuilder { self, $operationTargetName:L: &$operationTargetType:L, ) -> ::std::result::Result< - crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationOutputName:L, + $operationOutputType:L, $qualifiedRustServiceErrorType:L, > { let mut fluent_builder = $operationTargetName:L.$snakeCaseOperationName:L(); @@ -39,7 +39,7 @@ impl $pascalCaseOperationName:LFluentBuilder { pub async fn send( self, ) -> ::std::result::Result< - crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationOutputName:L, + $operationOutputType:L, $qualifiedRustServiceErrorType:L, > { let input = self diff --git a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer.rs b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer.rs index e333e3182..cac908666 100644 --- a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer.rs +++ b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer.rs @@ -9,9 +9,9 @@ impl $pascalCaseOperationName:L { } pub(crate) async fn send( $operationTargetName:L: &$operationTargetType:L, - input: crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationInputName:L, + input: $operationInputType:L, ) -> ::std::result::Result< - crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationOutputName:L, + $operationOutputType:L, $qualifiedRustServiceErrorType:L, > { $operationSendBody:L diff --git a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer_send_body.rs b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer_send_body.rs index 1a461e31c..66f9693b0 100644 --- a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer_send_body.rs +++ b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/operation/outer_send_body.rs @@ -1,4 +1,4 @@ - let inner_input = crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationInputName:L::to_dafny(input); + let inner_input = $inputToDafny:L; let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).$operationName:L(&inner_input); if matches!( @@ -6,9 +6,7 @@ crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( - crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationOutputName:L::from_dafny( - inner_result.value().clone(), - ), + $outputFromDafny:L, ) } else { Err(crate::conversions::error::from_dafny( diff --git a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/wrapped/client_operation_impl.part.rs b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/wrapped/client_operation_impl.part.rs index 15b124d3c..2b104d24d 100644 --- a/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/wrapped/client_operation_impl.part.rs +++ b/codegen/smithy-dafny-codegen/src/main/resources/templates/runtimes/rust/wrapped/client_operation_impl.part.rs @@ -1,18 +1,13 @@ fn $operationName:L( &mut self, - input: &std::rc::Rc< - crate::r#$dafnyTypesModuleName:L::$operationInputName:L, - >, + input: &$operationInputDafnyType:L, ) -> std::rc::Rc< crate::r#_Wrappers_Compile::Result< - std::rc::Rc< - crate::r#$dafnyTypesModuleName:L::$operationOutputName:L, - >, + $operationOutputDafnyType:L, std::rc::Rc, >, >{ - let inner_input = - crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationInputName:L::from_dafny(input.clone()); + let inner_input = $inputFromDafny:L; let result = tokio::task::block_in_place(|| { dafny_tokio_runtime.block_on(crate::operation::$snakeCaseOperationName:L::$pascalCaseOperationName:L::send(&self.wrapped, inner_input)) }); @@ -22,9 +17,9 @@ error: crate::conversions::error::to_dafny(error), }, ), - Ok(client) => ::std::rc::Rc::new( + Ok(inner_result) => ::std::rc::Rc::new( crate::_Wrappers_Compile::Result::Success { - value: crate::conversions::$snakeCaseOperationName:L::_$snakeCaseSyntheticOperationOutputName:L::to_dafny(client), + value: $outputToDafny:L, }, ), }