diff --git a/.github/workflows/nightly_dafny.yml b/.github/workflows/nightly_dafny.yml index 38a10bc45..adc56d912 100644 --- a/.github/workflows/nightly_dafny.yml +++ b/.github/workflows/nightly_dafny.yml @@ -27,21 +27,24 @@ jobs: uses: ./.github/workflows/test_models_net_tests.yml with: dafny: "nightly-latest" - # This workflow is pinned to a specific commit from a feature branch - # that's "ahead" of master, so there's no point in testing against nightly prereleases for now. - # dafny-nightly-rust: - # if: github.event_name != 'schedule' || github.repository_owner == 'smithy-lang' - # uses: ./.github/workflows/test_models_rust_tests.yml - # with: - # dafny: "nightly-latest" + # This workflow is normally pinned to a specific commit from the feat-rust feature branch. + # In the spirit of nightly, here we test against the tip of feat-rust + # (built from source instead of downloaded from nuget as a prerelease) + # to catch pending regressions. + dafny-nightly-rust: + if: github.event_name != 'schedule' || github.repository_owner == 'smithy-lang' + uses: ./.github/workflows/test_models_rust_tests.yml + with: + dafny: "feat-rust" cut-issue-on-failure: runs-on: ubuntu-latest - needs: [ + needs: + [ dafny-nightly-verification, dafny-nightly-java, dafny-nightly-net, - # dafny-nightly-rust, + dafny-nightly-rust, ] if: ${{ always() && contains(needs.*.result, 'failure') }} env: diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index d53abfbb7..ad739b83d 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -49,7 +49,7 @@ jobs: # Rust code generation is under development and depends on pending changes to the # Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead. dafny-version: - - f82ce12a800efddb22c987be0adb559752c7b6b9 + - 2412e865d1d04ea70711f4dfaf885fcdc5c338c8 uses: ./.github/workflows/test_models_rust_tests.yml with: dafny: ${{ matrix.dafny-version }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c33fbacea..8e02d6711 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -51,7 +51,7 @@ jobs: # Rust code generation is under development and depends on pending changes to the # Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead. dafny-version: - - f82ce12a800efddb22c987be0adb559752c7b6b9 + - 2412e865d1d04ea70711f4dfaf885fcdc5c338c8 uses: ./.github/workflows/test_models_rust_tests.yml with: dafny: ${{ matrix.dafny-version }} diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index c17cb8735..03176408c 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -516,48 +516,31 @@ test_java: ########################## Rust targets -# Note that transpile_dependencies_test_rust is necessary -# only because we are patching test code in the StandardLibrary, -# so we don't transpile that code then the recursive call to polymorph_rust -# on the StandardLibrary will fail because the patch does not apply. -transpile_rust: | transpile_implementation_rust transpile_test_rust transpile_dependencies_rust transpile_dependencies_test_rust +# TODO: blah blah Rust only supports a single crate for everything +transpile_rust: | transpile_implementation_rust transpile_dependencies_rust transpile_implementation_rust: TARGET=rs transpile_implementation_rust: OUT=implementation_from_dafny transpile_implementation_rust: SRC_INDEX=$(RUST_SRC_INDEX) +transpile_implementation_rust: TEST_INDEX=$(RUST_TEST_INDEX) # The Dafny Rust code generator is not complete yet, # so we want to emit code even if there are unsupported features in the input. transpile_implementation_rust: DAFNY_OPTIONS=-emitUncompilableCode -transpile_implementation_rust: _transpile_implementation_all _mv_implementation_rust - -transpile_test_rust: TARGET=rs -transpile_test_rust: OUT=tests_from_dafny -transpile_test_rust: SRC_INDEX=$(RUST_SRC_INDEX) -transpile_test_rust: TEST_INDEX=$(RUST_TEST_INDEX) -# The Dafny Rust code generator is not complete yet, -# so we want to emit code even if there are unsupported features in the input. -transpile_test_rust: DAFNY_OPTIONS=-emitUncompilableCode -transpile_test_rust: _transpile_test_all _mv_test_rust +# TODO: +transpile_implementation_rust: TRANSPILE_DEPENDENCIES= +transpile_implementation_rust: STD_LIBRARY= +transpile_implementation_rust: SRC_INDEX_TRANSPILE=$(if $(SRC_INDEX),$(SRC_INDEX),src) +transpile_implementation_rust: TEST_INDEX_TRANSPILE=$(if $(TEST_INDEX),$(TEST_INDEX),test) +transpile_implementation_rust: $(if $(TRANSPILE_TESTS_IN_RUST), transpile_test, transpile_implementation) _mv_implementation_rust transpile_dependencies_rust: LANG=rust transpile_dependencies_rust: transpile_dependencies -transpile_dependencies_test_rust: LANG=rust -transpile_dependencies_test_rust: transpile_dependencies_test - _mv_implementation_rust: mkdir -p runtimes/rust/src -# TODO: Currently need to insert an import of the the StandardLibrary. - python -c "import sys; data = sys.stdin.buffer.read(); sys.stdout.buffer.write(data.replace(b'\npub mod', b'\npub use dafny_standard_library::implementation_from_dafny::*;\n\npub mod', 1) if b'\npub mod' in data else data)" \ - < implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/src/implementation_from_dafny.rs + mv implementation_from_dafny-rust/src/implementation_from_dafny.rs runtimes/rust/src/implementation_from_dafny.rs rustfmt runtimes/rust/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust -_mv_test_rust: - rm -f runtimes/rust/tests/tests_from_dafny/mod.rs - mkdir -p runtimes/rust/tests/tests_from_dafny - mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny/mod.rs - rustfmt runtimes/rust/tests/tests_from_dafny/mod.rs - rm -rf tests_from_dafny-rust build_rust: cd runtimes/rust; \ diff --git a/TestModels/.gitignore b/TestModels/.gitignore index 68d851722..a72df25c1 100644 --- a/TestModels/.gitignore +++ b/TestModels/.gitignore @@ -12,7 +12,6 @@ # Dafny Generated Rust # (Rust code generation is incomplete so we're patching and checking in for now) #**/runtimes/rust -**/implementation_from_dafny.rs # Cargo.lock files should only be committed for binaries, not libraries **/Cargo.lock diff --git a/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch index 401362aed..d66e89fb1 100644 --- a/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Aggregate/runtimes/rust/src/client.rs a/TestModels/Aggregate/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..076fca49 +index 00000000..787630d2 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/client.rs @@ -0,0 +1,43 @@ @@ -10,7 +10,7 @@ index 00000000..076fca49 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -22,14 +22,14 @@ index 00000000..076fca49 + // If this service had any configuration properties, + // they would need converting here too. + let inner = -+ crate::implementation_from_dafny::_simple_daggregate_dinternaldafny::_default::SimpleAggregate( ++ crate::simple::aggregate::internaldafny::_default::SimpleAggregate( + &crate::conversions::simple_aggregate_config::_simple_aggregate_config::to_dafny( + conf, + ), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -109,7 +109,7 @@ index 00000000..b5acb2be +pub mod structure_list_element; diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs new file mode 100644 -index 00000000..1f94e9fa +index 00000000..e2b2ff74 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs @@ -0,0 +1,32 @@ @@ -120,21 +120,21 @@ index 00000000..1f94e9fa +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_aggregate::GetAggregateError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_aggregate::GetAggregateError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::aggregate::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::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error, ++ crate::r#simple::aggregate::internaldafny::types::Error, + >, +) -> crate::operation::get_aggregate::GetAggregateError { + // 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::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::aggregate::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_aggregate::GetAggregateError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -147,7 +147,7 @@ index 00000000..1f94e9fa +pub mod _get_aggregate_output; diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs new file mode 100644 -index 00000000..70ea59e7 +index 00000000..3e95555f --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs @@ -0,0 +1,121 @@ @@ -157,21 +157,21 @@ index 00000000..70ea59e7 +pub fn to_dafny( + value: crate::operation::get_aggregate::GetAggregateInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { + simpleStringList: + ::std::rc::Rc::new( + match value.simple_string_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + @@ -179,34 +179,34 @@ index 00000000..70ea59e7 + ::std::rc::Rc::new( + match value.structure_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + crate::conversions::structure_list_element::to_dafny(x.clone())) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + + simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| *v, + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) + }) @@ -217,11 +217,11 @@ index 00000000..70ea59e7 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, + >, +) -> crate::operation::get_aggregate::GetAggregateInput { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, @@ -230,7 +230,7 @@ index 00000000..70ea59e7 + } => + crate::operation::get_aggregate::GetAggregateInput { + simple_string_list : match (&**simpleStringList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -238,7 +238,7 @@ index 00000000..70ea59e7 + _ => None + }, + structure_list : match (&**structureList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -247,7 +247,7 @@ index 00000000..70ea59e7 + }, + + simple_string_map : match (&**simpleStringMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -258,7 +258,7 @@ index 00000000..70ea59e7 + }, + + simple_integer_map : match (&**simpleIntegerMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -274,7 +274,7 @@ index 00000000..70ea59e7 +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs new file mode 100644 -index 00000000..6ac58143 +index 00000000..38af1aed --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs @@ -0,0 +1,121 @@ @@ -284,21 +284,21 @@ index 00000000..6ac58143 +pub fn to_dafny( + value: crate::operation::get_aggregate::GetAggregateOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { + simpleStringList: + ::std::rc::Rc::new( + match value.simple_string_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + @@ -306,34 +306,34 @@ index 00000000..6ac58143 + ::std::rc::Rc::new( + match value.structure_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + crate::conversions::structure_list_element::to_dafny(x.clone())) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + + simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| *v, + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) + }) @@ -344,11 +344,11 @@ index 00000000..6ac58143 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, + >, +) -> crate::operation::get_aggregate::GetAggregateOutput { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, @@ -357,7 +357,7 @@ index 00000000..6ac58143 + } => + crate::operation::get_aggregate::GetAggregateOutput { + simple_string_list : match (&**simpleStringList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -365,7 +365,7 @@ index 00000000..6ac58143 + _ => None + }, + structure_list : match (&**structureList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -374,7 +374,7 @@ index 00000000..6ac58143 + }, + + simple_string_map : match (&**simpleStringMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -385,7 +385,7 @@ index 00000000..6ac58143 + }, + + simple_integer_map : match (&**simpleIntegerMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -401,7 +401,7 @@ index 00000000..6ac58143 +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs new file mode 100644 -index 00000000..8dadbfaf +index 00000000..b57c988a --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs @@ -0,0 +1,39 @@ @@ -412,12 +412,12 @@ index 00000000..8dadbfaf +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError::Unhandled( + unhandled, + ) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::aggregate::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -429,11 +429,11 @@ index 00000000..8dadbfaf +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error, ++ crate::r#simple::aggregate::internaldafny::types::Error, + >, +) -> crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::aggregate::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -446,7 +446,7 @@ index 00000000..8dadbfaf +pub mod _get_aggregate_known_value_test_output; diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs new file mode 100644 -index 00000000..fe7cdfb7 +index 00000000..abb3931c --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs @@ -0,0 +1,121 @@ @@ -456,21 +456,21 @@ index 00000000..fe7cdfb7 +pub fn to_dafny( + value: crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { + simpleStringList: + ::std::rc::Rc::new( + match value.simple_string_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + @@ -478,34 +478,34 @@ index 00000000..fe7cdfb7 + ::std::rc::Rc::new( + match value.structure_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + crate::conversions::structure_list_element::to_dafny(x.clone())) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + + simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| *v, + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) + }) @@ -516,11 +516,11 @@ index 00000000..fe7cdfb7 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, + >, +) -> crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestInput { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, @@ -529,7 +529,7 @@ index 00000000..fe7cdfb7 + } => + crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestInput { + simple_string_list : match (&**simpleStringList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -537,7 +537,7 @@ index 00000000..fe7cdfb7 + _ => None + }, + structure_list : match (&**structureList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -546,7 +546,7 @@ index 00000000..fe7cdfb7 + }, + + simple_string_map : match (&**simpleStringMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -557,7 +557,7 @@ index 00000000..fe7cdfb7 + }, + + simple_integer_map : match (&**simpleIntegerMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -573,7 +573,7 @@ index 00000000..fe7cdfb7 +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs new file mode 100644 -index 00000000..eaac290f +index 00000000..a25bad5f --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs @@ -0,0 +1,121 @@ @@ -583,21 +583,21 @@ index 00000000..eaac290f +pub fn to_dafny( + value: crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { + simpleStringList: + ::std::rc::Rc::new( + match value.simple_string_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + @@ -605,34 +605,34 @@ index 00000000..eaac290f + ::std::rc::Rc::new( + match value.structure_list() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + crate::conversions::structure_list_element::to_dafny(x.clone())) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + + simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), + |v| *v, + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) + }) @@ -643,11 +643,11 @@ index 00000000..eaac290f +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, + >, +) -> crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestOutput { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { ++ crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, @@ -656,7 +656,7 @@ index 00000000..eaac290f + } => + crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestOutput { + simple_string_list : match (&**simpleStringList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -664,7 +664,7 @@ index 00000000..eaac290f + _ => None + }, + structure_list : match (&**structureList).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| + crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -673,7 +673,7 @@ index 00000000..eaac290f + }, + + simple_string_map : match (&**simpleStringMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -684,7 +684,7 @@ index 00000000..eaac290f + }, + + simple_integer_map : match (&**simpleIntegerMap).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -700,7 +700,7 @@ index 00000000..eaac290f +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs new file mode 100644 -index 00000000..6621ed24 +index 00000000..1986a5bf --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs @@ -0,0 +1,81 @@ @@ -709,17 +709,17 @@ index 00000000..6621ed24 +pub fn to_dafny( + value: crate::types::NestedStructure, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, ++ crate::r#simple::aggregate::internaldafny::types::NestedStructure, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { + stringStructure: crate::conversions::string_structure::option_to_dafny(value.string_structure), +}) +} + +pub fn to_dafny_plain( + value: &crate::types::NestedStructure, -+) -> crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { ++) -> crate::r#simple::aggregate::internaldafny::types::NestedStructure { ++ crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { + stringStructure: crate::conversions::string_structure::option_to_dafny(value.string_structure.clone()), +} +} @@ -727,15 +727,15 @@ index 00000000..6621ed24 +pub fn option_to_dafny( + value: Option<&crate::types::NestedStructure>, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_Wrappers_Compile::Option< ++ crate::_Wrappers_Compile::Option< + ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, ++ crate::r#simple::aggregate::internaldafny::types::NestedStructure, + >, + >, +> { + let inner = match value { -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, -+ Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ None => crate::_Wrappers_Compile::Option::None {}, ++ Some(x) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new(to_dafny_plain(x)), + }, + }; @@ -745,11 +745,11 @@ index 00000000..6621ed24 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, ++ crate::r#simple::aggregate::internaldafny::types::NestedStructure, + >, +) -> crate::types::NestedStructure { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { ++ crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { + stringStructure, + } => + crate::types::NestedStructure { @@ -760,10 +760,10 @@ index 00000000..6621ed24 + +#[allow(dead_code)] +pub fn plain_from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, ++ dafny_value: &crate::r#simple::aggregate::internaldafny::types::NestedStructure, +) -> crate::types::NestedStructure { + match dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { ++ crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { + stringStructure, + } => + crate::types::NestedStructure { @@ -774,12 +774,12 @@ index 00000000..6621ed24 + +#[allow(dead_code)] +pub fn option_from_dafny( -+ dafny_value: ::std::rc::Rc>>, +) -> Option { + match &*dafny_value { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::Some { value } => { + Some(plain_from_dafny(value)) + } + _ => None, @@ -796,7 +796,7 @@ index 00000000..177a7b2f +pub mod _simple_aggregate_config; diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs new file mode 100644 -index 00000000..b76d9845 +index 00000000..d8b4fce1 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs @@ -0,0 +1,21 @@ @@ -807,23 +807,23 @@ index 00000000..b76d9845 +pub fn to_dafny( + value: crate::types::simple_aggregate_config::SimpleAggregateConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig, ++ crate::simple::aggregate::internaldafny::types::SimpleAggregateConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig::SimpleAggregateConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::SimpleAggregateConfig::SimpleAggregateConfig {}) +} + +#[allow(unused_variables)] +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig, ++ crate::r#simple::aggregate::internaldafny::types::SimpleAggregateConfig, + >, +) -> crate::types::simple_aggregate_config::SimpleAggregateConfig { + crate::types::simple_aggregate_config::SimpleAggregateConfig {} +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs new file mode 100644 -index 00000000..29f38e55 +index 00000000..5f8502d3 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs @@ -0,0 +1,74 @@ @@ -832,33 +832,33 @@ index 00000000..29f38e55 +pub fn to_dafny( + value: crate::types::StringStructure, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, ++ crate::r#simple::aggregate::internaldafny::types::StringStructure, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { -+ value: dafny_standard_library::conversion::ostring_to_dafny(&value.value), ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::StringStructure::StringStructure { ++ value: crate::standard_library_conversions::ostring_to_dafny(&value.value), +}) +} + +pub fn to_dafny_plain( + value: crate::types::StringStructure, -+) -> crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { -+ value: dafny_standard_library::conversion::ostring_to_dafny(&value.value), ++) -> crate::r#simple::aggregate::internaldafny::types::StringStructure { ++ crate::r#simple::aggregate::internaldafny::types::StringStructure::StringStructure { ++ value: crate::standard_library_conversions::ostring_to_dafny(&value.value), +} +} + +pub fn option_to_dafny( + value: Option, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_Wrappers_Compile::Option< ++ crate::_Wrappers_Compile::Option< + ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, ++ crate::r#simple::aggregate::internaldafny::types::StringStructure, + >, + >, +> { + let inner = match value { -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, -+ Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ None => crate::_Wrappers_Compile::Option::None {}, ++ Some(x) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new(to_dafny_plain(x)), + }, + }; @@ -868,7 +868,7 @@ index 00000000..29f38e55 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, ++ crate::r#simple::aggregate::internaldafny::types::StringStructure, + >, +) -> crate::types::StringStructure { + plain_from_dafny(&*dafny_value) @@ -876,26 +876,26 @@ index 00000000..29f38e55 + +#[allow(dead_code)] +pub fn plain_from_dafny( -+ dafny_value : &crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, ++ dafny_value : &crate::r#simple::aggregate::internaldafny::types::StringStructure, +) -> crate::types::StringStructure { + match dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { ++ crate::r#simple::aggregate::internaldafny::types::StringStructure::StringStructure { + value, + } => + crate::types::StringStructure { -+ value: dafny_standard_library::conversion::ostring_from_dafny(value.clone()), ++ value: crate::standard_library_conversions::ostring_from_dafny(value.clone()), + } +} +} + +#[allow(dead_code)] +pub fn option_from_dafny( -+ dafny_value: ::std::rc::Rc>>, +) -> Option { + match &*dafny_value { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::Some { value } => { + Some(plain_from_dafny(value)) + } + _ => None, @@ -903,7 +903,7 @@ index 00000000..29f38e55 +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs new file mode 100644 -index 00000000..e6603467 +index 00000000..1439b47a --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs @@ -0,0 +1,78 @@ @@ -912,33 +912,33 @@ index 00000000..e6603467 +pub fn to_dafny( + value: crate::types::StructureListElement, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, ++ crate::r#simple::aggregate::internaldafny::types::StructureListElement, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { -+ stringValue: dafny_standard_library::conversion::ostring_to_dafny(&value.string_value), -+ integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value), ++ ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { ++ stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), ++ integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), +}) +} + +#[allow(dead_code)] +pub fn to_dafny_plain( + value: crate::types::StructureListElement, -+) -> crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { -+ stringValue: dafny_standard_library::conversion::ostring_to_dafny(&value.string_value), -+ integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value), ++) -> crate::r#simple::aggregate::internaldafny::types::StructureListElement { ++ crate::r#simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { ++ stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), ++ integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), +} +} + +#[allow(dead_code)] +pub fn option_to_dafny( + value: Option, -+) -> ::std::rc::Rc ::std::rc::Rc>>{ + let inner = match value { -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, -+ Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ None => crate::_Wrappers_Compile::Option::None {}, ++ Some(x) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new(to_dafny_plain(x)), + }, + }; @@ -948,7 +948,7 @@ index 00000000..e6603467 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, ++ crate::r#simple::aggregate::internaldafny::types::StructureListElement, + >, +) -> crate::types::StructureListElement { + plain_from_dafny(&*dafny_value) @@ -956,28 +956,28 @@ index 00000000..e6603467 + +#[allow(dead_code)] +pub fn plain_from_dafny( -+ dafny_value : &crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, ++ dafny_value : &crate::r#simple::aggregate::internaldafny::types::StructureListElement, +) -> crate::types::StructureListElement { + match dafny_value { -+ crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { ++ crate::r#simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { + stringValue, + integerValue, + } => + crate::types::StructureListElement { -+ string_value: dafny_standard_library::conversion::ostring_from_dafny(stringValue.clone()), -+ integer_value: dafny_standard_library::conversion::oint_from_dafny(integerValue.clone()), ++ string_value: crate::standard_library_conversions::ostring_from_dafny(stringValue.clone()), ++ integer_value: crate::standard_library_conversions::oint_from_dafny(integerValue.clone()), + } +} +} + +#[allow(dead_code)] +pub fn option_from_dafny( -+ dafny_value: ::std::rc::Rc>>, +) -> Option { + match &*dafny_value { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::Some { value } => { + Some(plain_from_dafny(value)) + } + _ => None, @@ -1037,6 +1037,33 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs +index e0fd087f..c76afa2b 100644 +--- b/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,22 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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; ++mod standard_library_conversions; ++ ++pub use client::Client; ++pub use types::simple_aggregate_config::SimpleAggregateConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/Aggregate/runtimes/rust/src/lib.rs a/TestModels/Aggregate/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..a2840f69 @@ -1077,7 +1104,7 @@ index 00000000..4806430e +pub mod get_aggregate_known_value_test; diff --git b/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs new file mode 100644 -index 00000000..2d06555c +index 00000000..275313e4 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs @@ -0,0 +1,146 @@ @@ -1104,7 +1131,7 @@ index 00000000..2d06555c + ::dafny_runtime::md!(client.dafny_client.clone()).GetAggregate(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_aggregate::_get_aggregate_output::from_dafny( @@ -1865,7 +1892,7 @@ index 00000000..a146e79b +} diff --git b/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs new file mode 100644 -index 00000000..3d5ab2f0 +index 00000000..bfbc7b95 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs @@ -0,0 +1,149 @@ @@ -1891,7 +1918,7 @@ index 00000000..3d5ab2f0 + .GetAggregateKnownValueTest(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_aggregate_known_value_test::_get_aggregate_known_value_test_output::from_dafny( @@ -2661,6 +2688,259 @@ index 00000000..63afa764 + self.inner.get_nested_structure() + } +} +diff --git b/TestModels/Aggregate/runtimes/rust/src/standard_library_conversions.rs a/TestModels/Aggregate/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/Aggregate/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git b/TestModels/Aggregate/runtimes/rust/src/types.rs a/TestModels/Aggregate/runtimes/rust/src/types.rs new file mode 100644 index 00000000..dd259ffa diff --git a/TestModels/Aggregate/runtimes/rust/Cargo.toml b/TestModels/Aggregate/runtimes/rust/Cargo.toml index 1a73c78c5..a92b8b5b1 100644 --- a/TestModels/Aggregate/runtimes/rust/Cargo.toml +++ b/TestModels/Aggregate/runtimes/rust/Cargo.toml @@ -10,8 +10,11 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../dafny-dependencies/StandardLibrary/runtimes/rust"} +dafny_standard_library = { path = "../../../dafny-dependencies/StandardLibrary/runtimes/rust" } [dev-dependencies.tokio] version = "1.26.0" -features = ["full"] \ No newline at end of file +features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/Aggregate/runtimes/rust/src/client.rs b/TestModels/Aggregate/runtimes/rust/src/client.rs index 076fca49d..787630d2f 100644 --- a/TestModels/Aggregate/runtimes/rust/src/client.rs +++ b/TestModels/Aggregate/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -16,14 +16,14 @@ impl Client { // If this service had any configuration properties, // they would need converting here too. let inner = - crate::implementation_from_dafny::_simple_daggregate_dinternaldafny::_default::SimpleAggregate( + crate::simple::aggregate::internaldafny::_default::SimpleAggregate( &crate::conversions::simple_aggregate_config::_simple_aggregate_config::to_dafny( conf, ), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs index 1f94e9fa2..e2b2ff749 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_aggregate::GetAggregateError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_aggregate::GetAggregateError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::aggregate::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::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error, + crate::r#simple::aggregate::internaldafny::types::Error, >, ) -> crate::operation::get_aggregate::GetAggregateError { // 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::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::aggregate::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_aggregate::GetAggregateError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs index 70ea59e70..3e95555fa 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_input.rs @@ -4,21 +4,21 @@ pub fn to_dafny( value: crate::operation::get_aggregate::GetAggregateInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { simpleStringList: ::std::rc::Rc::new( match value.simple_string_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), @@ -26,34 +26,34 @@ pub fn to_dafny( ::std::rc::Rc::new( match value.structure_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| crate::conversions::structure_list_element::to_dafny(x.clone())) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| *v, ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) }) @@ -64,11 +64,11 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, >, ) -> crate::operation::get_aggregate::GetAggregateInput { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { + crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { simpleStringList, structureList, simpleStringMap, @@ -77,7 +77,7 @@ pub fn from_dafny( } => crate::operation::get_aggregate::GetAggregateInput { simple_string_list : match (&**simpleStringList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -85,7 +85,7 @@ pub fn from_dafny( _ => None }, structure_list : match (&**structureList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -94,7 +94,7 @@ pub fn from_dafny( }, simple_string_map : match (&**simpleStringMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -105,7 +105,7 @@ pub fn from_dafny( }, simple_integer_map : match (&**simpleIntegerMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs index 6ac581435..38af1aed3 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate/_get_aggregate_output.rs @@ -4,21 +4,21 @@ pub fn to_dafny( value: crate::operation::get_aggregate::GetAggregateOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { simpleStringList: ::std::rc::Rc::new( match value.simple_string_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), @@ -26,34 +26,34 @@ pub fn to_dafny( ::std::rc::Rc::new( match value.structure_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| crate::conversions::structure_list_element::to_dafny(x.clone())) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| *v, ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) }) @@ -64,11 +64,11 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, >, ) -> crate::operation::get_aggregate::GetAggregateOutput { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { + crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { simpleStringList, structureList, simpleStringMap, @@ -77,7 +77,7 @@ pub fn from_dafny( } => crate::operation::get_aggregate::GetAggregateOutput { simple_string_list : match (&**simpleStringList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -85,7 +85,7 @@ pub fn from_dafny( _ => None }, structure_list : match (&**structureList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -94,7 +94,7 @@ pub fn from_dafny( }, simple_string_map : match (&**simpleStringMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -105,7 +105,7 @@ pub fn from_dafny( }, simple_integer_map : match (&**simpleIntegerMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs index 8dadbfaf2..b57c988a9 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs @@ -5,12 +5,12 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError::Unhandled( unhandled, ) => ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::aggregate::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -22,11 +22,11 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error, + crate::r#simple::aggregate::internaldafny::types::Error, >, ) -> crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError { // 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::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::aggregate::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs index fe7cdfb71..abb3931cd 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_input.rs @@ -4,21 +4,21 @@ pub fn to_dafny( value: crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { simpleStringList: ::std::rc::Rc::new( match value.simple_string_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), @@ -26,34 +26,34 @@ pub fn to_dafny( ::std::rc::Rc::new( match value.structure_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| crate::conversions::structure_list_element::to_dafny(x.clone())) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| *v, ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) }) @@ -64,11 +64,11 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateInput, >, ) -> crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestInput { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput::GetAggregateInput { + crate::r#simple::aggregate::internaldafny::types::GetAggregateInput::GetAggregateInput { simpleStringList, structureList, simpleStringMap, @@ -77,7 +77,7 @@ pub fn from_dafny( } => crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestInput { simple_string_list : match (&**simpleStringList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -85,7 +85,7 @@ pub fn from_dafny( _ => None }, structure_list : match (&**structureList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -94,7 +94,7 @@ pub fn from_dafny( }, simple_string_map : match (&**simpleStringMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -105,7 +105,7 @@ pub fn from_dafny( }, simple_integer_map : match (&**simpleIntegerMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs index eaac290fd..a25bad5f8 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test/_get_aggregate_known_value_test_output.rs @@ -4,21 +4,21 @@ pub fn to_dafny( value: crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { simpleStringList: ::std::rc::Rc::new( match value.simple_string_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), @@ -26,34 +26,34 @@ pub fn to_dafny( ::std::rc::Rc::new( match value.structure_list() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| crate::conversions::structure_list_element::to_dafny(x.clone())) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), simpleStringMap: ::std::rc::Rc::new(match value.simple_string_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), simpleIntegerMap: ::std::rc::Rc::new(match value.simple_integer_map() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), |v| *v, ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), nestedStructure: crate::conversions::nested_structure::option_to_dafny(value.nested_structure()) }) @@ -64,11 +64,11 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, + crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput, >, ) -> crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestOutput { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { + crate::r#simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { simpleStringList, structureList, simpleStringMap, @@ -77,7 +77,7 @@ pub fn from_dafny( } => crate::operation::get_aggregate_known_value_test::GetAggregateKnownValueTestOutput { simple_string_list : match (&**simpleStringList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&x)) @@ -85,7 +85,7 @@ pub fn from_dafny( _ => None }, structure_list : match (&**structureList).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(&value, |x| crate::conversions::structure_list_element::plain_from_dafny(&x)) @@ -94,7 +94,7 @@ pub fn from_dafny( }, simple_string_map : match (&**simpleStringMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), @@ -105,7 +105,7 @@ pub fn from_dafny( }, simple_integer_map : match (&**simpleIntegerMap).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&value, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&k), diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs index 6621ed244..1986a5bf6 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/nested_structure.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::types::NestedStructure, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, + crate::r#simple::aggregate::internaldafny::types::NestedStructure, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { stringStructure: crate::conversions::string_structure::option_to_dafny(value.string_structure), }) } pub fn to_dafny_plain( value: &crate::types::NestedStructure, -) -> crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { +) -> crate::r#simple::aggregate::internaldafny::types::NestedStructure { + crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { stringStructure: crate::conversions::string_structure::option_to_dafny(value.string_structure.clone()), } } @@ -21,15 +21,15 @@ pub fn to_dafny_plain( pub fn option_to_dafny( value: Option<&crate::types::NestedStructure>, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_Wrappers_Compile::Option< + crate::_Wrappers_Compile::Option< ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, + crate::r#simple::aggregate::internaldafny::types::NestedStructure, >, >, > { let inner = match value { - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, - Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + None => crate::_Wrappers_Compile::Option::None {}, + Some(x) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new(to_dafny_plain(x)), }, }; @@ -39,11 +39,11 @@ pub fn option_to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, + crate::r#simple::aggregate::internaldafny::types::NestedStructure, >, ) -> crate::types::NestedStructure { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { + crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { stringStructure, } => crate::types::NestedStructure { @@ -54,10 +54,10 @@ pub fn from_dafny( #[allow(dead_code)] pub fn plain_from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, + dafny_value: &crate::r#simple::aggregate::internaldafny::types::NestedStructure, ) -> crate::types::NestedStructure { match dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { + crate::r#simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { stringStructure, } => crate::types::NestedStructure { @@ -68,12 +68,12 @@ pub fn plain_from_dafny( #[allow(dead_code)] pub fn option_from_dafny( - dafny_value: ::std::rc::Rc>>, ) -> Option { match &*dafny_value { - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::Some { value } => { Some(plain_from_dafny(value)) } _ => None, diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs index b76d98458..d8b4fce1b 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/simple_aggregate_config/_simple_aggregate_config.rs @@ -5,16 +5,16 @@ pub fn to_dafny( value: crate::types::simple_aggregate_config::SimpleAggregateConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig, + crate::simple::aggregate::internaldafny::types::SimpleAggregateConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig::SimpleAggregateConfig {}) + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::SimpleAggregateConfig::SimpleAggregateConfig {}) } #[allow(unused_variables)] #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig, + crate::r#simple::aggregate::internaldafny::types::SimpleAggregateConfig, >, ) -> crate::types::simple_aggregate_config::SimpleAggregateConfig { crate::types::simple_aggregate_config::SimpleAggregateConfig {} diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs index 29f38e558..5f8502d32 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/string_structure.rs @@ -3,33 +3,33 @@ pub fn to_dafny( value: crate::types::StringStructure, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, + crate::r#simple::aggregate::internaldafny::types::StringStructure, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { - value: dafny_standard_library::conversion::ostring_to_dafny(&value.value), + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::StringStructure::StringStructure { + value: crate::standard_library_conversions::ostring_to_dafny(&value.value), }) } pub fn to_dafny_plain( value: crate::types::StringStructure, -) -> crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { - value: dafny_standard_library::conversion::ostring_to_dafny(&value.value), +) -> crate::r#simple::aggregate::internaldafny::types::StringStructure { + crate::r#simple::aggregate::internaldafny::types::StringStructure::StringStructure { + value: crate::standard_library_conversions::ostring_to_dafny(&value.value), } } pub fn option_to_dafny( value: Option, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_Wrappers_Compile::Option< + crate::_Wrappers_Compile::Option< ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, + crate::r#simple::aggregate::internaldafny::types::StringStructure, >, >, > { let inner = match value { - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, - Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + None => crate::_Wrappers_Compile::Option::None {}, + Some(x) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new(to_dafny_plain(x)), }, }; @@ -39,7 +39,7 @@ pub fn option_to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, + crate::r#simple::aggregate::internaldafny::types::StringStructure, >, ) -> crate::types::StringStructure { plain_from_dafny(&*dafny_value) @@ -47,26 +47,26 @@ pub fn from_dafny( #[allow(dead_code)] pub fn plain_from_dafny( - dafny_value : &crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, + dafny_value : &crate::r#simple::aggregate::internaldafny::types::StringStructure, ) -> crate::types::StringStructure { match dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { + crate::r#simple::aggregate::internaldafny::types::StringStructure::StringStructure { value, } => crate::types::StringStructure { - value: dafny_standard_library::conversion::ostring_from_dafny(value.clone()), + value: crate::standard_library_conversions::ostring_from_dafny(value.clone()), } } } #[allow(dead_code)] pub fn option_from_dafny( - dafny_value: ::std::rc::Rc>>, ) -> Option { match &*dafny_value { - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::Some { value } => { Some(plain_from_dafny(value)) } _ => None, diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs index e66034677..1439b47aa 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/structure_list_element.rs @@ -3,33 +3,33 @@ pub fn to_dafny( value: crate::types::StructureListElement, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, + crate::r#simple::aggregate::internaldafny::types::StructureListElement, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { - stringValue: dafny_standard_library::conversion::ostring_to_dafny(&value.string_value), - integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value), + ::std::rc::Rc::new(crate::r#simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { + stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), + integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), }) } #[allow(dead_code)] pub fn to_dafny_plain( value: crate::types::StructureListElement, -) -> crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { - stringValue: dafny_standard_library::conversion::ostring_to_dafny(&value.string_value), - integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value), +) -> crate::r#simple::aggregate::internaldafny::types::StructureListElement { + crate::r#simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { + stringValue: crate::standard_library_conversions::ostring_to_dafny(&value.string_value), + integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value), } } #[allow(dead_code)] pub fn option_to_dafny( value: Option, -) -> ::std::rc::Rc ::std::rc::Rc>>{ let inner = match value { - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, - Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + None => crate::_Wrappers_Compile::Option::None {}, + Some(x) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new(to_dafny_plain(x)), }, }; @@ -39,7 +39,7 @@ pub fn option_to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, + crate::r#simple::aggregate::internaldafny::types::StructureListElement, >, ) -> crate::types::StructureListElement { plain_from_dafny(&*dafny_value) @@ -47,28 +47,28 @@ pub fn from_dafny( #[allow(dead_code)] pub fn plain_from_dafny( - dafny_value : &crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, + dafny_value : &crate::r#simple::aggregate::internaldafny::types::StructureListElement, ) -> crate::types::StructureListElement { match dafny_value { - crate::implementation_from_dafny::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { + crate::r#simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { stringValue, integerValue, } => crate::types::StructureListElement { - string_value: dafny_standard_library::conversion::ostring_from_dafny(stringValue.clone()), - integer_value: dafny_standard_library::conversion::oint_from_dafny(integerValue.clone()), + string_value: crate::standard_library_conversions::ostring_from_dafny(stringValue.clone()), + integer_value: crate::standard_library_conversions::oint_from_dafny(integerValue.clone()), } } } #[allow(dead_code)] pub fn option_from_dafny( - dafny_value: ::std::rc::Rc>>, ) -> Option { match &*dafny_value { - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::Some { value } => { Some(plain_from_dafny(value)) } _ => None, diff --git a/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..c76afa2b3 --- /dev/null +++ b/TestModels/Aggregate/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2837 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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; +mod standard_library_conversions; + +pub use client::Client; +pub use types::simple_aggregate_config::SimpleAggregateConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod aggregate { + pub mod internaldafny { + pub use crate::simple::aggregate::internaldafny::types::ISimpleAggregateClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleAggregateConfig() -> ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::SimpleAggregateConfig, + > { + ::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::SimpleAggregateConfig::SimpleAggregateConfig {}) + } + pub fn SimpleAggregate( + config: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::SimpleAggregateConfig, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::aggregate::internaldafny::SimpleAggregateClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::aggregate::internaldafny::SimpleAggregateClient, + >, + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::Error, + >, + >, + >, + >::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::aggregate::internaldafny::SimpleAggregateClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::aggregate::internaldafny::SimpleAggregateClient::_allocate_object(); + crate::simple::aggregate::internaldafny::SimpleAggregateClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleAggregateImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + crate::simple::aggregate::internaldafny::SimpleAggregateClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleAggregateClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleAggregateClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::aggregate::internaldafny::SimpleAggregateClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::aggregate::internaldafny::SimpleAggregateClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleAggregateClient for crate::simple::aggregate::internaldafny::SimpleAggregateClient { + fn GetAggregate( + &mut self, + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleAggregateImpl_Compile::_default::GetAggregate( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetAggregateKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleAggregateImpl_Compile::_default::GetAggregateKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::aggregate::internaldafny::SimpleAggregateClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::aggregate::internaldafny::types::ISimpleAggregateClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.aggregate.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetAggregateInput { + GetAggregateInput { + simpleStringList: ::std::rc::Rc>>>, + structureList: ::std::rc::Rc>>>, + simpleStringMap: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + simpleIntegerMap: ::std::rc::Rc, i32>>>, + nestedStructure: ::std::rc::Rc>> + } + } + + impl GetAggregateInput { + pub fn simpleStringList( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + > { + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => simpleStringList, + } + } + pub fn structureList(&self) -> &::std::rc::Rc>>>{ + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => structureList, + } + } + pub fn simpleStringMap( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + > { + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => simpleStringMap, + } + } + pub fn simpleIntegerMap( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + i32, + >, + >, + > { + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => simpleIntegerMap, + } + } + pub fn nestedStructure( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::NestedStructure, + >, + >, + > { + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => nestedStructure, + } + } + } + + impl Debug for GetAggregateInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetAggregateInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => { + write!(_formatter, "simple.aggregate.internaldafny.types.GetAggregateInput.GetAggregateInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + simpleStringList, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + structureList, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + simpleStringMap, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + simpleIntegerMap, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + nestedStructure, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetAggregateInput {} + + impl Hash for GetAggregateInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetAggregateInput::GetAggregateInput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => { + ::std::hash::Hash::hash(simpleStringList, _state); + ::std::hash::Hash::hash(structureList, _state); + ::std::hash::Hash::hash(simpleStringMap, _state); + ::std::hash::Hash::hash(simpleIntegerMap, _state); + ::std::hash::Hash::hash(nestedStructure, _state) + } + } + } + } + + impl Default for GetAggregateInput { + fn default() -> GetAggregateInput { + GetAggregateInput::GetAggregateInput { + simpleStringList: ::std::default::Default::default(), + structureList: ::std::default::Default::default(), + simpleStringMap: ::std::default::Default::default(), + simpleIntegerMap: ::std::default::Default::default(), + nestedStructure: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetAggregateInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetAggregateOutput { + GetAggregateOutput { + simpleStringList: ::std::rc::Rc>>>, + structureList: ::std::rc::Rc>>>, + simpleStringMap: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + simpleIntegerMap: ::std::rc::Rc, i32>>>, + nestedStructure: ::std::rc::Rc>> + } + } + + impl GetAggregateOutput { + pub fn simpleStringList( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + > { + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => simpleStringList, + } + } + pub fn structureList(&self) -> &::std::rc::Rc>>>{ + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => structureList, + } + } + pub fn simpleStringMap( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + > { + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => simpleStringMap, + } + } + pub fn simpleIntegerMap( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + i32, + >, + >, + > { + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => simpleIntegerMap, + } + } + pub fn nestedStructure( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::NestedStructure, + >, + >, + > { + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => nestedStructure, + } + } + } + + impl Debug for GetAggregateOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetAggregateOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => { + write!(_formatter, "simple.aggregate.internaldafny.types.GetAggregateOutput.GetAggregateOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + simpleStringList, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + structureList, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + simpleStringMap, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + simpleIntegerMap, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + nestedStructure, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetAggregateOutput {} + + impl Hash for GetAggregateOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetAggregateOutput::GetAggregateOutput { + simpleStringList, + structureList, + simpleStringMap, + simpleIntegerMap, + nestedStructure, + } => { + ::std::hash::Hash::hash(simpleStringList, _state); + ::std::hash::Hash::hash(structureList, _state); + ::std::hash::Hash::hash(simpleStringMap, _state); + ::std::hash::Hash::hash(simpleIntegerMap, _state); + ::std::hash::Hash::hash(nestedStructure, _state) + } + } + } + } + + impl Default for GetAggregateOutput { + fn default() -> GetAggregateOutput { + GetAggregateOutput::GetAggregateOutput { + simpleStringList: ::std::default::Default::default(), + structureList: ::std::default::Default::default(), + simpleStringMap: ::std::default::Default::default(), + simpleIntegerMap: ::std::default::Default::default(), + nestedStructure: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetAggregateOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum NestedStructure { + NestedStructure { + stringStructure: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::StringStructure, + >, + >, + >, + }, + } + + impl NestedStructure { + pub fn stringStructure( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::StringStructure, + >, + >, + > { + match self { + NestedStructure::NestedStructure { stringStructure } => stringStructure, + } + } + } + + impl Debug for NestedStructure { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for NestedStructure { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + NestedStructure::NestedStructure { stringStructure } => { + write!(_formatter, "simple.aggregate.internaldafny.types.NestedStructure.NestedStructure(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + stringStructure, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for NestedStructure {} + + impl Hash for NestedStructure { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + NestedStructure::NestedStructure { stringStructure } => { + ::std::hash::Hash::hash(stringStructure, _state) + } + } + } + } + + impl Default for NestedStructure { + fn default() -> NestedStructure { + NestedStructure::NestedStructure { + stringStructure: ::std::default::Default::default(), + } + } + } + + impl AsRef for &NestedStructure { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleAggregateClientCallHistory {} + + impl ISimpleAggregateClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::aggregate::internaldafny::types::ISimpleAggregateClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleAggregateClient: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetAggregate( + &mut self, + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >, + >; + fn GetAggregateKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >, + >; + } + + #[derive(PartialEq, Clone)] + pub enum SimpleAggregateConfig { + SimpleAggregateConfig {}, + } + + impl SimpleAggregateConfig {} + + impl Debug for SimpleAggregateConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleAggregateConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleAggregateConfig::SimpleAggregateConfig {} => { + write!(_formatter, "simple.aggregate.internaldafny.types.SimpleAggregateConfig.SimpleAggregateConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleAggregateConfig {} + + impl Hash for SimpleAggregateConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleAggregateConfig::SimpleAggregateConfig {} => {} + } + } + } + + impl Default for SimpleAggregateConfig { + fn default() -> SimpleAggregateConfig { + SimpleAggregateConfig::SimpleAggregateConfig {} + } + } + + impl AsRef for &SimpleAggregateConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum StringStructure { + StringStructure { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl StringStructure { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + StringStructure::StringStructure { value } => value, + } + } + } + + impl Debug for StringStructure { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for StringStructure { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + StringStructure::StringStructure { value } => { + write!(_formatter, "simple.aggregate.internaldafny.types.StringStructure.StringStructure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for StringStructure {} + + impl Hash for StringStructure { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + StringStructure::StringStructure { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for StringStructure { + fn default() -> StringStructure { + StringStructure::StringStructure { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &StringStructure { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum StructureListElement { + StructureListElement { + stringValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + integerValue: ::std::rc::Rc>, + }, + } + + impl StructureListElement { + pub fn stringValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + StructureListElement::StructureListElement { + stringValue, + integerValue, + } => stringValue, + } + } + pub fn integerValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + StructureListElement::StructureListElement { + stringValue, + integerValue, + } => integerValue, + } + } + } + + impl Debug for StructureListElement { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for StructureListElement { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + StructureListElement::StructureListElement { + stringValue, + integerValue, + } => { + write!(_formatter, "simple.aggregate.internaldafny.types.StructureListElement.StructureListElement(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + stringValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + integerValue, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for StructureListElement {} + + impl Hash for StructureListElement { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + StructureListElement::StructureListElement { + stringValue, + integerValue, + } => { + ::std::hash::Hash::hash(stringValue, _state); + ::std::hash::Hash::hash(integerValue, _state) + } + } + } + } + + impl Default for StructureListElement { + fn default() -> StructureListElement { + StructureListElement::StructureListElement { + stringValue: ::std::default::Default::default(), + integerValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &StructureListElement { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.aggregate.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.aggregate.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } +} +pub mod r#_SimpleAggregateImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetAggregate( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { + simpleStringList: input.simpleStringList().clone(), + structureList: input.structureList().clone(), + simpleStringMap: input.simpleStringMap().clone(), + simpleIntegerMap: input.simpleIntegerMap().clone(), + nestedStructure: input.nestedStructure().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetAggregateKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + crate::r#_SimpleAggregateImpl_Compile::_default::ValidateInput(input); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::GetAggregateOutput::GetAggregateOutput { + simpleStringList: input.simpleStringList().clone(), + structureList: input.structureList().clone(), + simpleStringMap: input.simpleStringMap().clone(), + simpleIntegerMap: input.simpleIntegerMap().clone(), + nestedStructure: input.nestedStructure().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn ValidateInput( + input: &::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::GetAggregateInput, + >, + ) -> () { + let mut _e00: ::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + > = input.simpleStringList().UnwrapOr( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >), + ); + let mut _e10: ::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + > = ::dafny_runtime::seq![::dafny_runtime::string_utf16_of("Test")]; + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut _e01: ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + > = input.simpleStringMap().UnwrapOr(&::dafny_runtime::map![]); + let mut _e11: ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + > = ::dafny_runtime::map![(::dafny_runtime::string_utf16_of("Test1")) => (::dafny_runtime::string_utf16_of("Success"))]; + if !(_e01.clone() == _e11.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + let mut _e02: ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + i32, + > = input.simpleIntegerMap().UnwrapOr(&::dafny_runtime::map![]); + let mut _e12: ::dafny_runtime::Map< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + i32, + > = ::dafny_runtime::map![(::dafny_runtime::string_utf16_of("Test3")) => (3)]; + if !(_e02.clone() == _e12.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + let mut _e03: ::dafny_runtime::Sequence< + ::std::rc::Rc, + > = input.structureList().UnwrapOr( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::aggregate::internaldafny::types::StructureListElement, + >, + >), + ); + let mut _e13: ::dafny_runtime::Sequence<::std::rc::Rc> = ::dafny_runtime::seq![::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::StructureListElement::StructureListElement { + stringValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: ::dafny_runtime::string_utf16_of("Test2") + }), + integerValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: 2 + }) + })]; + if !(_e03.clone() == _e13.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e03)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e13)); + panic!("Halt") + }; + let mut _e04: ::std::rc::Rc = input.nestedStructure().UnwrapOr(&::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { + stringStructure: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::Some { + value: ::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::StringStructure::StringStructure { + value: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: ::dafny_runtime::string_utf16_of("") + }) + }) + }) + })); + let mut _e14: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::NestedStructure::NestedStructure { + stringStructure: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::Some { + value: ::std::rc::Rc::new(crate::simple::aggregate::internaldafny::types::StringStructure::StringStructure { + value: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: ::dafny_runtime::string_utf16_of("Nested") + }) + }) + }) + }); + if !(_e04.clone() == _e14.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e04)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e14)); + panic!("Halt") + }; + return (); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleAggregateImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs b/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs index 2d06555ce..275313e4a 100644 --- a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs +++ b/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate.rs @@ -21,7 +21,7 @@ impl GetAggregate { ::dafny_runtime::md!(client.dafny_client.clone()).GetAggregate(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_aggregate::_get_aggregate_output::from_dafny( diff --git a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs b/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs index 3d5ab2f03..bfbc7b95a 100644 --- a/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs +++ b/TestModels/Aggregate/runtimes/rust/src/operation/get_aggregate_known_value_test.rs @@ -20,7 +20,7 @@ impl GetAggregateKnownValueTest { .GetAggregateKnownValueTest(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_aggregate_known_value_test::_get_aggregate_known_value_test_output::from_dafny( diff --git a/TestModels/Aggregate/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Aggregate/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/Aggregate/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/Aggregate/runtimes/rust/tests/aggregate.rs b/TestModels/Aggregate/runtimes/rust/tests/aggregate.rs deleted file mode 100644 index c2a35024c..000000000 --- a/TestModels/Aggregate/runtimes/rust/tests/aggregate.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![allow(non_snake_case)] -use simple_aggregate::types::*; -use simple_aggregate::*; -use std::collections::HashMap; - -#[tokio::test] -async fn test_get_aggregate() { - let stringList = ["Test"]; - let simpleStringMap = HashMap::from([("Test1".to_string(), "Success".to_string())]); - let structureList = vec![StructureListElement::builder() - .string_value("Test2") - .integer_value(2) - .build()]; - let simpleIntegerMap = HashMap::from([("Test3".to_string(), 3)]); - let nestedStructure = NestedStructure::builder() - .string_structure(StringStructure::builder().value("Nested").build()) - .build(); - let result = client() - .get_aggregate() - .simple_integer_map("Test3", 3) - .simple_string_map("Test1", "Success") - .simple_string_list("Test") - .structure_list( - StructureListElement::builder() - .string_value("Test2") - .integer_value(2) - .build(), - ) - .nested_structure(nestedStructure.clone()) - .send() - .await; - - let output = result.unwrap(); - - assert_eq!(output.simple_integer_map.unwrap(), simpleIntegerMap); - assert_eq!(output.simple_string_map.unwrap(), simpleStringMap); - assert_eq!(output.structure_list.unwrap(), structureList); - assert_eq!(output.nested_structure.unwrap(), nestedStructure); - assert_eq!(output.simple_string_list.unwrap(), stringList); -} - -pub fn client() -> Client { - let config = SimpleAggregateConfig::builder().build().unwrap(); - Client::from_conf(config).unwrap() -} diff --git a/TestModels/Constructor/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Constructor/codegen-patches/rust/dafny-4.5.0.patch index 6ce790742..127bdf1db 100644 --- a/TestModels/Constructor/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Constructor/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Constructor/runtimes/rust/src/client.rs a/TestModels/Constructor/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..1b072736 +index 00000000..e209cced --- /dev/null +++ a/TestModels/Constructor/runtimes/rust/src/client.rs @@ -0,0 +1,36 @@ @@ -10,7 +10,7 @@ index 00000000..1b072736 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object, ++ pub(crate) dafny_client: ::dafny_runtime::Object, +} + +impl Client { @@ -18,12 +18,12 @@ index 00000000..1b072736 + #[track_caller] + pub fn from_conf(conf: crate::Config) -> Result { + let inner = -+ crate::implementation_from_dafny::r#_simple_dconstructor_dinternaldafny::_default::SimpleConstructor( ++ crate::r#simple::constructor::internaldafny::_default::SimpleConstructor( + &crate::conversions::simple_constructor_config::_simple_constructor_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -201,7 +201,7 @@ index 00000000..d6c2383c +pub mod simple_constructor_config; diff --git b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs new file mode 100644 -index 00000000..3eacd64d +index 00000000..cb568f9f --- /dev/null +++ a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs @@ -0,0 +1,48 @@ @@ -211,12 +211,12 @@ index 00000000..3eacd64d +pub fn to_dafny_error( + value: crate::operation::get_constructor::GetConstructorError, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error, ++ crate::simple::constructor::internaldafny::types::Error, +> { + match value { + crate::operation::get_constructor::GetConstructorError::Unhandled(unhandled) => { + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error::Opaque { ++ crate::simple::constructor::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)), + }, + ) @@ -227,13 +227,13 @@ index 00000000..3eacd64d +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error, ++ crate::simple::constructor::internaldafny::types::Error, + >, +) -> crate::operation::get_constructor::GetConstructorError { + // 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::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error::CollectionOfErrors { .. } ++ crate::simple::constructor::internaldafny::types::Error::CollectionOfErrors { .. } + ) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_constructor::GetConstructorError::generic( @@ -255,7 +255,7 @@ index 00000000..3eacd64d +pub mod _get_constructor_output; diff --git b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs new file mode 100644 -index 00000000..0be58129 +index 00000000..fdb5c4e3 --- /dev/null +++ a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_input.rs @@ -0,0 +1,41 @@ @@ -264,13 +264,13 @@ index 00000000..0be58129 +pub fn to_dafny( + value: crate::operation::get_constructor::GetConstructorInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput, ++ crate::simple::constructor::internaldafny::types::GetConstructorInput, +>{ + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput::GetConstructorInput { ++ ::std::rc::Rc::new(crate::simple::constructor::internaldafny::types::GetConstructorInput::GetConstructorInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -278,12 +278,12 @@ index 00000000..0be58129 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput, ++ crate::simple::constructor::internaldafny::types::GetConstructorInput, + >, +) -> crate::operation::get_constructor::GetConstructorInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -292,7 +292,7 @@ index 00000000..0be58129 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -302,7 +302,7 @@ index 00000000..0be58129 +} diff --git b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs new file mode 100644 -index 00000000..65a3bb4f +index 00000000..9374bd3e --- /dev/null +++ a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor/_get_constructor_output.rs @@ -0,0 +1,170 @@ @@ -311,7 +311,7 @@ index 00000000..65a3bb4f +pub fn to_dafny( + value: crate::operation::get_constructor::GetConstructorOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput, ++ crate::simple::constructor::internaldafny::types::GetConstructorOutput, +>{ + let crate::operation::get_constructor::GetConstructorOutput { + internal_config_string, @@ -323,38 +323,38 @@ index 00000000..65a3bb4f + } = value; + + let internal_config_string = match internal_config_string { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + + let blob_value = match blob_value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::dafny_runtime::Sequence::from_array(&v), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + + let boolean_value = match boolean_value { -+ Some(value) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(value) => crate::_Wrappers_Compile::Option::Some { value }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + + let string_value = match string_value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + + let integer_value = match integer_value { -+ Some(value) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(value) => crate::_Wrappers_Compile::Option::Some { value }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + + let long_value = match long_value { -+ Some(value) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(value) => crate::_Wrappers_Compile::Option::Some { value }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput::GetConstructorOutput { ++ ::std::rc::Rc::new(crate::simple::constructor::internaldafny::types::GetConstructorOutput::GetConstructorOutput { + internalConfigString: ::std::rc::Rc::new(internal_config_string), + blobValue: ::std::rc::Rc::new(blob_value), + booleanValue: ::std::rc::Rc::new(boolean_value), @@ -367,12 +367,12 @@ index 00000000..65a3bb4f +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput, ++ crate::simple::constructor::internaldafny::types::GetConstructorOutput, + >, +) -> crate::operation::get_constructor::GetConstructorOutput { + let internal_config_string = if matches!( + dafny_value.internalConfigString().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -381,7 +381,7 @@ index 00000000..65a3bb4f + ) + } else if matches!( + dafny_value.internalConfigString().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -390,7 +390,7 @@ index 00000000..65a3bb4f + + let blob_value = if matches!( + dafny_value.blobValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( @@ -400,7 +400,7 @@ index 00000000..65a3bb4f + ) + } else if matches!( + dafny_value.blobValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -409,12 +409,12 @@ index 00000000..65a3bb4f + + let boolean_value = if matches!( + dafny_value.booleanValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.booleanValue().Extract()) + } else if matches!( + dafny_value.booleanValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -423,7 +423,7 @@ index 00000000..65a3bb4f + + let string_value = if matches!( + dafny_value.stringValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -432,7 +432,7 @@ index 00000000..65a3bb4f + ) + } else if matches!( + dafny_value.stringValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -441,12 +441,12 @@ index 00000000..65a3bb4f + + let integer_value = if matches!( + dafny_value.integerValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.integerValue().Extract()) + } else if matches!( + dafny_value.integerValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -455,12 +455,12 @@ index 00000000..65a3bb4f + + let long_value = if matches!( + dafny_value.longValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.longValue().Extract()) + } else if matches!( + dafny_value.longValue().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -487,13 +487,13 @@ index 00000000..e75ae86f +pub mod _simple_constructor_config; diff --git b/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs a/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs new file mode 100644 -index 00000000..1d6c857c +index 00000000..61c4d56f --- /dev/null +++ a/TestModels/Constructor/runtimes/rust/src/conversions/simple_constructor_config/_simple_constructor_config.rs -@@ -0,0 +1,62 @@ +@@ -0,0 +1,59 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. + -+use dafny_standard_library::conversion::{ ++use crate::standard_library_conversions::{ + obool_from_dafny, obool_to_dafny, oint_from_dafny, oint_to_dafny, olong_from_dafny, + olong_to_dafny, ostring_from_dafny, ostring_to_dafny, +}; @@ -502,22 +502,22 @@ index 00000000..1d6c857c +pub fn to_dafny( + config: crate::config::Config, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig, ++ crate::simple::constructor::internaldafny::types::SimpleConstructorConfig, +>{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig::SimpleConstructorConfig { blobValue: blob_to_dafny(config.blob_value), booleanValue: obool_to_dafny(config.boolean_value), stringValue: ostring_to_dafny(&config.string_value), integerValue: oint_to_dafny(config.integer_value), longValue: olong_to_dafny(config.long_value) }) ++ crate::simple::constructor::internaldafny::types::SimpleConstructorConfig::SimpleConstructorConfig { blobValue: blob_to_dafny(config.blob_value), booleanValue: obool_to_dafny(config.boolean_value), stringValue: ostring_to_dafny(&config.string_value), integerValue: oint_to_dafny(config.integer_value), longValue: olong_to_dafny(config.long_value) }) +} + +fn blob_to_dafny( + value: ::std::option::Option<::std::vec::Vec>, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, ++ crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, +> { + let v = match value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::dafny_runtime::Sequence::from_array(&v), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + + ::std::rc::Rc::new(v) @@ -526,7 +526,7 @@ index 00000000..1d6c857c +#[allow(dead_code)] +pub fn from_dafny( + config: ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig, ++ crate::simple::constructor::internaldafny::types::SimpleConstructorConfig, + >, +) -> crate::config::Config { + crate::config::Config { @@ -540,17 +540,14 @@ index 00000000..1d6c857c + +fn blob_from_dafny( + value: ::std::rc::Rc< -+ crate::implementation_from_dafny::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, ++ crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, +) -> ::std::option::Option<::std::vec::Vec> { + match value.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::Some { value } => { + Some(::std::rc::Rc::try_unwrap(value.to_array()).unwrap_or_else(|rc| (*rc).clone())) + } -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => { -+ unreachable!() -+ } ++ crate::_Wrappers_Compile::Option::None {} => None, + } +} diff --git b/TestModels/Constructor/runtimes/rust/src/error.rs a/TestModels/Constructor/runtimes/rust/src/error.rs @@ -605,6 +602,37 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs +index c4ac178d..5aea81e2 100644 +--- b/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,26 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++#[doc(inline)] ++pub use config::Config; ++ ++pub mod client; ++ ++/// Configuration for Constructor Service. ++pub mod config; ++ ++/// Common errors and error handling utilities. ++pub mod error; ++ ++/// All operations that this crate can perform. ++pub mod operation; ++ ++pub mod conversions; ++mod standard_library_conversions; ++ ++pub use client::Client; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/Constructor/runtimes/rust/src/lib.rs a/TestModels/Constructor/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..9986830f @@ -646,7 +674,7 @@ index 00000000..8de453d5 +pub mod get_constructor; diff --git b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs new file mode 100644 -index 00000000..951054d0 +index 00000000..3551482e --- /dev/null +++ a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs @@ -0,0 +1,146 @@ @@ -673,7 +701,7 @@ index 00000000..951054d0 + ::dafny_runtime::md!(client.dafny_client.clone()).GetConstructor(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_constructor::_get_constructor_output::from_dafny( @@ -1132,3 +1160,256 @@ index 00000000..52045c7e + self.inner.get_value() + } +} +diff --git b/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs a/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git a/TestModels/Constructor/runtimes/rust/Cargo.toml b/TestModels/Constructor/runtimes/rust/Cargo.toml index 7bc75f71f..378117767 100644 --- a/TestModels/Constructor/runtimes/rust/Cargo.toml +++ b/TestModels/Constructor/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/Constructor/runtimes/rust/src/client.rs b/TestModels/Constructor/runtimes/rust/src/client.rs index 1b072736e..e209cceda 100644 --- a/TestModels/Constructor/runtimes/rust/src/client.rs +++ b/TestModels/Constructor/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object, + pub(crate) dafny_client: ::dafny_runtime::Object, } impl Client { @@ -12,12 +12,12 @@ impl Client { #[track_caller] pub fn from_conf(conf: crate::Config) -> Result { let inner = - crate::implementation_from_dafny::r#_simple_dconstructor_dinternaldafny::_default::SimpleConstructor( + crate::r#simple::constructor::internaldafny::_default::SimpleConstructor( &crate::conversions::simple_constructor_config::_simple_constructor_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs index 3eacd64d5..cb568f9f6 100644 --- a/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs +++ b/TestModels/Constructor/runtimes/rust/src/conversions/get_constructor.rs @@ -4,12 +4,12 @@ pub fn to_dafny_error( value: crate::operation::get_constructor::GetConstructorError, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error, + crate::simple::constructor::internaldafny::types::Error, > { match value { crate::operation::get_constructor::GetConstructorError::Unhandled(unhandled) => { ::std::rc::Rc::new( - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error::Opaque { + crate::simple::constructor::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)), }, ) @@ -20,13 +20,13 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error, + crate::simple::constructor::internaldafny::types::Error, >, ) -> crate::operation::get_constructor::GetConstructorError { // 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::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::Error::CollectionOfErrors { .. } + crate::simple::constructor::internaldafny::types::Error::CollectionOfErrors { .. } ) { let error_message = "TODO: can't get message yet"; crate::operation::get_constructor::GetConstructorError::generic( 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 index 0be581297..fdb5c4e3f 100644 --- 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 @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_constructor::GetConstructorInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput, + crate::simple::constructor::internaldafny::types::GetConstructorInput, >{ let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput::GetConstructorInput { + ::std::rc::Rc::new(crate::simple::constructor::internaldafny::types::GetConstructorInput::GetConstructorInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,12 +17,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput, + crate::simple::constructor::internaldafny::types::GetConstructorInput, >, ) -> crate::operation::get_constructor::GetConstructorInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -31,7 +31,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { 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 index 65a3bb4f7..9374bd3e1 100644 --- 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 @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_constructor::GetConstructorOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput, + crate::simple::constructor::internaldafny::types::GetConstructorOutput, >{ let crate::operation::get_constructor::GetConstructorOutput { internal_config_string, @@ -15,38 +15,38 @@ pub fn to_dafny( } = value; let internal_config_string = match internal_config_string { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; let blob_value = match blob_value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::Sequence::from_array(&v), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; let boolean_value = match boolean_value { - Some(value) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(value) => crate::_Wrappers_Compile::Option::Some { value }, + None => crate::_Wrappers_Compile::Option::None {}, }; let string_value = match string_value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; let integer_value = match integer_value { - Some(value) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(value) => crate::_Wrappers_Compile::Option::Some { value }, + None => crate::_Wrappers_Compile::Option::None {}, }; let long_value = match long_value { - Some(value) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(value) => crate::_Wrappers_Compile::Option::Some { value }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput::GetConstructorOutput { + ::std::rc::Rc::new(crate::simple::constructor::internaldafny::types::GetConstructorOutput::GetConstructorOutput { internalConfigString: ::std::rc::Rc::new(internal_config_string), blobValue: ::std::rc::Rc::new(blob_value), booleanValue: ::std::rc::Rc::new(boolean_value), @@ -59,12 +59,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput, + crate::simple::constructor::internaldafny::types::GetConstructorOutput, >, ) -> crate::operation::get_constructor::GetConstructorOutput { let internal_config_string = if matches!( dafny_value.internalConfigString().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -73,7 +73,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.internalConfigString().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { @@ -82,7 +82,7 @@ pub fn from_dafny( let blob_value = if matches!( dafny_value.blobValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( @@ -92,7 +92,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.blobValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { @@ -101,12 +101,12 @@ pub fn from_dafny( let boolean_value = if matches!( dafny_value.booleanValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.booleanValue().Extract()) } else if matches!( dafny_value.booleanValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { @@ -115,7 +115,7 @@ pub fn from_dafny( let string_value = if matches!( dafny_value.stringValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -124,7 +124,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.stringValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { @@ -133,12 +133,12 @@ pub fn from_dafny( let integer_value = if matches!( dafny_value.integerValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.integerValue().Extract()) } else if matches!( dafny_value.integerValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { @@ -147,12 +147,12 @@ pub fn from_dafny( let long_value = if matches!( dafny_value.longValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.longValue().Extract()) } else if matches!( dafny_value.longValue().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { 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 index 1d6c857c0..61c4d56fa 100644 --- 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 @@ -1,6 +1,6 @@ // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. -use dafny_standard_library::conversion::{ +use crate::standard_library_conversions::{ obool_from_dafny, obool_to_dafny, oint_from_dafny, oint_to_dafny, olong_from_dafny, olong_to_dafny, ostring_from_dafny, ostring_to_dafny, }; @@ -9,22 +9,22 @@ use dafny_standard_library::conversion::{ pub fn to_dafny( config: crate::config::Config, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig, + crate::simple::constructor::internaldafny::types::SimpleConstructorConfig, >{ ::std::rc::Rc::new( - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig::SimpleConstructorConfig { blobValue: blob_to_dafny(config.blob_value), booleanValue: obool_to_dafny(config.boolean_value), stringValue: ostring_to_dafny(&config.string_value), integerValue: oint_to_dafny(config.integer_value), longValue: olong_to_dafny(config.long_value) }) + crate::simple::constructor::internaldafny::types::SimpleConstructorConfig::SimpleConstructorConfig { blobValue: blob_to_dafny(config.blob_value), booleanValue: obool_to_dafny(config.boolean_value), stringValue: ostring_to_dafny(&config.string_value), integerValue: oint_to_dafny(config.integer_value), longValue: olong_to_dafny(config.long_value) }) } fn blob_to_dafny( value: ::std::option::Option<::std::vec::Vec>, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, > { let v = match value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::Sequence::from_array(&v), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; ::std::rc::Rc::new(v) @@ -33,7 +33,7 @@ fn blob_to_dafny( #[allow(dead_code)] pub fn from_dafny( config: ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig, + crate::simple::constructor::internaldafny::types::SimpleConstructorConfig, >, ) -> crate::config::Config { crate::config::Config { @@ -47,16 +47,13 @@ pub fn from_dafny( fn blob_from_dafny( value: ::std::rc::Rc< - crate::implementation_from_dafny::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + crate::_Wrappers_Compile::Option<::dafny_runtime::Sequence>, >, ) -> ::std::option::Option<::std::vec::Vec> { match value.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::Some { value } => { Some(::std::rc::Rc::try_unwrap(value.to_array()).unwrap_or_else(|rc| (*rc).clone())) } - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => { - unreachable!() - } + crate::_Wrappers_Compile::Option::None {} => None, } } diff --git a/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..5aea81e23 --- /dev/null +++ b/TestModels/Constructor/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2497 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +#[doc(inline)] +pub use config::Config; + +pub mod client; + +/// Configuration for Constructor Service. +pub mod config; + +/// Common errors and error handling utilities. +pub mod error; + +/// All operations that this crate can perform. +pub mod operation; + +pub mod conversions; +mod standard_library_conversions; + +pub use client::Client; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod constructor { + pub mod internaldafny { + pub use crate::simple::constructor::internaldafny::types::ISimpleConstructorClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleConstructorConfig() -> ::std::rc::Rc< + crate::simple::constructor::internaldafny::types::SimpleConstructorConfig, + > { + ::std::rc::Rc::new(crate::simple::constructor::internaldafny::types::SimpleConstructorConfig::SimpleConstructorConfig { + blobValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { + value: ::dafny_runtime::seq![0] + }), + booleanValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: false + }), + stringValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: ::dafny_runtime::string_utf16_of("") + }), + integerValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: 0 + }), + longValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: 0 + }) + }) + } + pub fn SimpleConstructor( + config: &::std::rc::Rc< + crate::simple::constructor::internaldafny::types::SimpleConstructorConfig, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::constructor::internaldafny::SimpleConstructorClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut configToAssign: ::std::rc::Rc< + crate::r#_SimpleConstructorImpl_Compile::Config, + > = ::std::rc::Rc::new( + crate::r#_SimpleConstructorImpl_Compile::Config::Config { + blobValue: config.blobValue().UnwrapOr(&::dafny_runtime::seq![0]), + booleanValue: config.booleanValue().UnwrapOr(&true), + stringValue: config + .stringValue() + .UnwrapOr(&::dafny_runtime::string_utf16_of("")), + integerValue: config.integerValue().UnwrapOr(&0), + longValue: config.longValue().UnwrapOr(&0), + }, + ); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::constructor::internaldafny::SimpleConstructorClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::constructor::internaldafny::SimpleConstructorClient::_allocate_object(); + crate::simple::constructor::internaldafny::SimpleConstructorClient::_ctor( + &_nw1, + &configToAssign, + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + crate::simple::constructor::internaldafny::SimpleConstructorClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleConstructorClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleConstructorClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::constructor::internaldafny::SimpleConstructorClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::constructor::internaldafny::SimpleConstructorClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleConstructorClient + for crate::simple::constructor::internaldafny::SimpleConstructorClient + { + fn GetConstructor( + &mut self, + input: &::std::rc::Rc< + crate::simple::constructor::internaldafny::types::GetConstructorInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::constructor::internaldafny::types::GetConstructorOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleConstructorImpl_Compile::_default::GetConstructor( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::constructor::internaldafny::SimpleConstructorClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::constructor::internaldafny::types::ISimpleConstructorClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.constructor.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetConstructorInput { + GetConstructorInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetConstructorInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetConstructorInput::GetConstructorInput { value } => value, + } + } + } + + impl Debug for GetConstructorInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetConstructorInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetConstructorInput::GetConstructorInput { value } => { + write!(_formatter, "simple.constructor.internaldafny.types.GetConstructorInput.GetConstructorInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetConstructorInput {} + + impl Hash for GetConstructorInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetConstructorInput::GetConstructorInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetConstructorInput { + fn default() -> GetConstructorInput { + GetConstructorInput::GetConstructorInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetConstructorInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetConstructorOutput { + GetConstructorOutput { + internalConfigString: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + blobValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + booleanValue: ::std::rc::Rc>, + stringValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + integerValue: ::std::rc::Rc>, + longValue: ::std::rc::Rc>, + }, + } + + impl GetConstructorOutput { + pub fn internalConfigString( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => internalConfigString, + } + } + pub fn blobValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => blobValue, + } + } + pub fn booleanValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => booleanValue, + } + } + pub fn stringValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => stringValue, + } + } + pub fn integerValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => integerValue, + } + } + pub fn longValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => longValue, + } + } + } + + impl Debug for GetConstructorOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetConstructorOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + write!(_formatter, "simple.constructor.internaldafny.types.GetConstructorOutput.GetConstructorOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + internalConfigString, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + blobValue, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + booleanValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + stringValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + integerValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + longValue, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetConstructorOutput {} + + impl Hash for GetConstructorOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetConstructorOutput::GetConstructorOutput { + internalConfigString, + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + ::std::hash::Hash::hash(internalConfigString, _state); + ::std::hash::Hash::hash(blobValue, _state); + ::std::hash::Hash::hash(booleanValue, _state); + ::std::hash::Hash::hash(stringValue, _state); + ::std::hash::Hash::hash(integerValue, _state); + ::std::hash::Hash::hash(longValue, _state) + } + } + } + } + + impl Default for GetConstructorOutput { + fn default() -> GetConstructorOutput { + GetConstructorOutput::GetConstructorOutput { + internalConfigString: ::std::default::Default::default(), + blobValue: ::std::default::Default::default(), + booleanValue: ::std::default::Default::default(), + stringValue: ::std::default::Default::default(), + integerValue: ::std::default::Default::default(), + longValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetConstructorOutput { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleConstructorClientCallHistory {} + + impl ISimpleConstructorClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::constructor::internaldafny::types::ISimpleConstructorClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleConstructorClient: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetConstructor(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum SimpleConstructorConfig { + SimpleConstructorConfig { + blobValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + booleanValue: ::std::rc::Rc>, + stringValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + integerValue: ::std::rc::Rc>, + longValue: ::std::rc::Rc>, + }, + } + + impl SimpleConstructorConfig { + pub fn blobValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => blobValue, + } + } + pub fn booleanValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => booleanValue, + } + } + pub fn stringValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => stringValue, + } + } + pub fn integerValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => integerValue, + } + } + pub fn longValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => longValue, + } + } + } + + impl Debug for SimpleConstructorConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleConstructorConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + write!(_formatter, "simple.constructor.internaldafny.types.SimpleConstructorConfig.SimpleConstructorConfig(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + blobValue, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + booleanValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + stringValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + integerValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + longValue, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleConstructorConfig {} + + impl Hash for SimpleConstructorConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + ::std::hash::Hash::hash(blobValue, _state); + ::std::hash::Hash::hash(booleanValue, _state); + ::std::hash::Hash::hash(stringValue, _state); + ::std::hash::Hash::hash(integerValue, _state); + ::std::hash::Hash::hash(longValue, _state) + } + } + } + } + + impl Default for SimpleConstructorConfig { + fn default() -> SimpleConstructorConfig { + SimpleConstructorConfig::SimpleConstructorConfig { + blobValue: ::std::default::Default::default(), + booleanValue: ::std::default::Default::default(), + stringValue: ::std::default::Default::default(), + integerValue: ::std::default::Default::default(), + longValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &SimpleConstructorConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.constructor.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.constructor.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } +} +pub mod r#_SimpleConstructorImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetConstructor( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::constructor::internaldafny::types::GetConstructorInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::constructor::internaldafny::types::GetConstructorOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::constructor::internaldafny::types::GetConstructorOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::constructor::internaldafny::types::GetConstructorOutput::GetConstructorOutput { + internalConfigString: input.value().clone(), + blobValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { + value: config.blobValue().clone() + }), + booleanValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: config.booleanValue().clone() + }), + stringValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: config.stringValue().clone() + }), + integerValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: config.integerValue().clone() + }), + longValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: config.longValue().clone() + }) + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::constructor::internaldafny::types::GetConstructorOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config { + blobValue: ::dafny_runtime::Sequence, + booleanValue: bool, + stringValue: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + integerValue: i32, + longValue: i64, + }, + } + + impl Config { + pub fn blobValue(&self) -> &::dafny_runtime::Sequence { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => blobValue, + } + } + pub fn booleanValue(&self) -> &bool { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => booleanValue, + } + } + pub fn stringValue(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => stringValue, + } + } + pub fn integerValue(&self) -> &i32 { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => integerValue, + } + } + pub fn longValue(&self) -> &i64 { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => longValue, + } + } + } + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + write!(_formatter, "SimpleConstructorImpl_Compile.Config.Config(")?; + ::dafny_runtime::DafnyPrint::fmt_print(blobValue, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(booleanValue, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(stringValue, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(integerValue, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(longValue, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + ::std::hash::Hash::hash(blobValue, _state); + ::std::hash::Hash::hash(booleanValue, _state); + ::std::hash::Hash::hash(stringValue, _state); + ::std::hash::Hash::hash(integerValue, _state); + ::std::hash::Hash::hash(longValue, _state) + } + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config { + blobValue: ::std::default::Default::default(), + booleanValue: ::std::default::Default::default(), + stringValue: ::std::default::Default::default(), + integerValue: ::std::default::Default::default(), + longValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs index 951054d0d..3551482e3 100644 --- a/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs +++ b/TestModels/Constructor/runtimes/rust/src/operation/get_constructor.rs @@ -21,7 +21,7 @@ impl GetConstructor { ::dafny_runtime::md!(client.dafny_client.clone()).GetConstructor(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_constructor::_get_constructor_output::from_dafny( diff --git a/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/Constructor/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/Constructor/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/Constructor/runtimes/rust/tests/tests_from_dafny/mod.rs deleted file mode 100644 index 3abf14b61..000000000 --- a/TestModels/Constructor/runtimes/rust/tests/tests_from_dafny/mod.rs +++ /dev/null @@ -1,373 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] - -pub mod r#_simple_dconstructor_dinternaldafny_dwrapped { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn WrappedDefaultSimpleConstructorConfig() -> ::std::rc::Rc< - super::r#_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig, - > { - super::r#_simple_dconstructor_dinternaldafny::_default::DefaultSimpleConstructorConfig() - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dconstructor_dinternaldafny_dwrapped::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_SimpleConstructorImplTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn TestGetConstructorWithDefaultConfig() -> () { - let mut expectedOutput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput::GetConstructorOutput { - internalConfigString: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("inputString") - }), - blobValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { - value: ::dafny_runtime::seq![0] - }), - booleanValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: false - }), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("") - }), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 0 - }), - longValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 0 - }) - }); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dconstructor_dinternaldafny::SimpleConstructorClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dconstructor_dinternaldafny::SimpleConstructorClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dconstructor_dinternaldafny::_default::SimpleConstructor(&super::r#_simple_dconstructor_dinternaldafny::_default::DefaultSimpleConstructorConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dconstructor_dinternaldafny::SimpleConstructorClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleConstructorImplTest_Compile::_default::TestGetConstructor(&::dafny_runtime::upcast_object::()(client.clone()), &expectedOutput); - return (); - } - pub fn TestGetConstructorWithParamConfig() -> () { - let mut paramConfig: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig::SimpleConstructorConfig { - blobValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { - value: ::dafny_runtime::seq![0, 0, 7] - }), - booleanValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: true - }), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("ParamString") - }), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 7 - }), - longValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 7 - }) - }); - let mut expectedOutput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput::GetConstructorOutput { - internalConfigString: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("inputString") - }), - blobValue: paramConfig.blobValue().clone(), - booleanValue: paramConfig.booleanValue().clone(), - stringValue: paramConfig.stringValue().clone(), - integerValue: paramConfig.integerValue().clone(), - longValue: paramConfig.longValue().clone() - }); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dconstructor_dinternaldafny::SimpleConstructorClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dconstructor_dinternaldafny::SimpleConstructorClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_simple_dconstructor_dinternaldafny::_default::SimpleConstructor( - ¶mConfig, - ), - ); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dconstructor_dinternaldafny::SimpleConstructorClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleConstructorImplTest_Compile::_default::TestGetConstructor(&::dafny_runtime::upcast_object::()(client.clone()), &expectedOutput); - return (); - } - pub fn TestGetConstructor( - client: &::dafny_runtime::Object< - dyn super::r#_simple_dconstructor_dinternaldafny_dtypes::ISimpleConstructorClient, - >, - expectedOutput: &::std::rc::Rc< - super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput, - >, - ) -> () { - let mut input: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorInput::GetConstructorInput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("inputString") - }) - }); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dconstructor_dinternaldafny_dtypes::ISimpleConstructorClient::GetConstructor(::dafny_runtime::md!(client.clone()), &input)); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut ret: ::std::rc::Rc< - super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput, - > = valueOrError0.read().Extract(); - if !(ret.internalConfigString().clone() - == expectedOutput.internalConfigString().clone()) - { - panic!("Halt") - }; - if !(ret.blobValue().clone() == expectedOutput.blobValue().clone()) { - panic!("Halt") - }; - if !(ret.booleanValue().clone() == expectedOutput.booleanValue().clone()) { - panic!("Halt") - }; - if !(ret.stringValue().clone() == expectedOutput.stringValue().clone()) { - panic!("Halt") - }; - if !(ret.integerValue().clone() == expectedOutput.integerValue().clone()) { - panic!("Halt") - }; - if !(ret.longValue().clone() == expectedOutput.longValue().clone()) { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_SimpleConstructorImplTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_WrappedSimpleConstructorTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn TestGetConstructorWithParamConfig() -> () { - let mut paramConfig: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::SimpleConstructorConfig::SimpleConstructorConfig { - blobValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { - value: ::dafny_runtime::seq![0, 0, 7] - }), - booleanValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: true - }), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("ParamString") - }), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 7 - }), - longValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 7 - }) - }); - let mut expectedOutput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput::GetConstructorOutput { - internalConfigString: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("inputString") - }), - blobValue: paramConfig.blobValue().clone(), - booleanValue: paramConfig.booleanValue().clone(), - stringValue: paramConfig.stringValue().clone(), - integerValue: paramConfig.integerValue().clone(), - longValue: paramConfig.longValue().clone() - }); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dconstructor_dinternaldafny_dwrapped::_default::WrappedSimpleConstructor(¶mConfig)); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - dyn super::r#_simple_dconstructor_dinternaldafny_dtypes::ISimpleConstructorClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleConstructorImplTest_Compile::_default::TestGetConstructor( - &client, - &expectedOutput, - ); - return (); - } - pub fn TestGetConstructorWithDefaultConfig() -> () { - let mut expectedOutput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dconstructor_dinternaldafny_dtypes::GetConstructorOutput::GetConstructorOutput { - internalConfigString: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("inputString") - }), - blobValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { - value: ::dafny_runtime::seq![0] - }), - booleanValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: false - }), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("") - }), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 0 - }), - longValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 0 - }) - }); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dconstructor_dinternaldafny_dwrapped::_default::WrappedSimpleConstructor(&super::r#_simple_dconstructor_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleConstructorConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - dyn super::r#_simple_dconstructor_dinternaldafny_dtypes::ISimpleConstructorClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleConstructorImplTest_Compile::_default::TestGetConstructor( - &client, - &expectedOutput, - ); - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_WrappedSimpleConstructorTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod _module { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _Test__Main_() -> () { - let mut success: bool = true; - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleConstructorImplTest.TestGetConstructorWithDefaultConfig: "# - )) - ); - super::r#_SimpleConstructorImplTest_Compile::_default::TestGetConstructorWithDefaultConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleConstructorImplTest.TestGetConstructorWithParamConfig: "# - )) - ); - super::r#_SimpleConstructorImplTest_Compile::_default::TestGetConstructorWithParamConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedSimpleConstructorTest.TestGetConstructorWithParamConfig: "# - )) - ); - super::r#_WrappedSimpleConstructorTest_Compile::_default::TestGetConstructorWithParamConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedSimpleConstructorTest.TestGetConstructorWithDefaultConfig: "# - )) - ); - super::r#_WrappedSimpleConstructorTest_Compile::_default::TestGetConstructorWithDefaultConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - if !success { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::_module::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -fn main() { - _module::_default::_Test__Main_(); -} diff --git a/TestModels/LanguageSpecificLogic/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/LanguageSpecificLogic/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..147b1f3c8 --- /dev/null +++ b/TestModels/LanguageSpecificLogic/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,582 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +pub use dafny_standard_library::implementation_from_dafny::*; + +pub mod r#_language_dspecific_dlogic_dinternaldafny_dtypes { + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent { + DafnyCallEvent { input: I, output: O }, + _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for DafnyCallEvent + { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "language.specific.logic.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::hash::Hash, + O: ::dafny_runtime::DafnyType + ::std::hash::Hash, + > ::std::hash::Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::default::Default, + O: ::dafny_runtime::DafnyType + ::std::default::Default, + > ::std::default::Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + ::std::convert::AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetRuntimeInformationOutput { + GetRuntimeInformationOutput { + language: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + runtime: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + } + + impl GetRuntimeInformationOutput { + pub fn language(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + GetRuntimeInformationOutput::GetRuntimeInformationOutput { language, runtime } => { + language + } + } + } + pub fn runtime(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + GetRuntimeInformationOutput::GetRuntimeInformationOutput { language, runtime } => { + runtime + } + } + } + } + + impl ::std::fmt::Debug for GetRuntimeInformationOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for GetRuntimeInformationOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetRuntimeInformationOutput::GetRuntimeInformationOutput { language, runtime } => { + write!(_formatter, "language.specific.logic.internaldafny.types.GetRuntimeInformationOutput.GetRuntimeInformationOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(language, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(runtime, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetRuntimeInformationOutput {} + + impl ::std::hash::Hash for GetRuntimeInformationOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetRuntimeInformationOutput::GetRuntimeInformationOutput { language, runtime } => { + ::std::hash::Hash::hash(language, _state); + ::std::hash::Hash::hash(runtime, _state) + } + } + } + } + + impl ::std::default::Default for GetRuntimeInformationOutput { + fn default() -> GetRuntimeInformationOutput { + GetRuntimeInformationOutput::GetRuntimeInformationOutput { + language: ::std::default::Default::default(), + runtime: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &GetRuntimeInformationOutput { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ILanguageSpecificLogicClientCallHistory {} + + impl ILanguageSpecificLogicClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::ILanguageSpecificLogicClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ILanguageSpecificLogicClient: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetRuntimeInformation(&mut self) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum LanguageSpecificLogicConfig { + LanguageSpecificLogicConfig {}, + } + + impl LanguageSpecificLogicConfig {} + + impl ::std::fmt::Debug for LanguageSpecificLogicConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for LanguageSpecificLogicConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + LanguageSpecificLogicConfig::LanguageSpecificLogicConfig {} => { + write!(_formatter, "language.specific.logic.internaldafny.types.LanguageSpecificLogicConfig.LanguageSpecificLogicConfig")?; + Ok(()) + } + } + } + } + + impl Eq for LanguageSpecificLogicConfig {} + + impl ::std::hash::Hash for LanguageSpecificLogicConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + LanguageSpecificLogicConfig::LanguageSpecificLogicConfig {} => {} + } + } + } + + impl ::std::default::Default for LanguageSpecificLogicConfig { + fn default() -> LanguageSpecificLogicConfig { + LanguageSpecificLogicConfig::LanguageSpecificLogicConfig {} + } + } + + impl ::std::convert::AsRef for &LanguageSpecificLogicConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!( + _formatter, + "language.specific.logic.internaldafny.types.Error.CollectionOfErrors(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "language.specific.logic.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl ::std::hash::Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl ::std::default::Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; +} +pub mod r#_LanguageSpecificLogicImpl_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn GetRuntimeInformation(config: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::std::rc::Rc< + super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::std::rc::Rc< + super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + super::r#_LanguageSpecificLogicImpl_Compile::_default::GetRustRuntimeVersion( + config, + ), + ); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut runtimeInfo: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError0.read().Extract(); + let mut getRuntimeInformationOutput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::GetRuntimeInformationOutput::GetRuntimeInformationOutput { + language: ::dafny_runtime::string_utf16_of("Rust"), + runtime: runtimeInfo.clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { + value: getRuntimeInformationOutput.clone() + })); + return output.read(); + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_LanguageSpecificLogicImpl_Compile::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl ::std::fmt::Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!( + _formatter, + "LanguageSpecificLogicImpl_Compile.Config.Config" + )?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl ::std::hash::Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl ::std::default::Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl ::std::convert::AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_language_dspecific_dlogic_dinternaldafny { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn DefaultLanguageSpecificLogicConfig() -> ::std::rc::Rc< + super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::LanguageSpecificLogicConfig, + > { + ::std::rc::Rc::new(super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::LanguageSpecificLogicConfig::LanguageSpecificLogicConfig {}) + } + pub fn LanguageSpecificLogic( + config: &::std::rc::Rc, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient, + >, + >::new(); + let mut _nw0: ::dafny_runtime::Object = super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient::_allocate_object(); + super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient::_ctor( + &_nw0, + &::std::rc::Rc::new(super::r#_LanguageSpecificLogicImpl_Compile::Config::Config {}), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_language_dspecific_dlogic_dinternaldafny::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + pub struct LanguageSpecificLogicClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl LanguageSpecificLogicClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config(&self) -> ::std::rc::Rc { + self.r#__i_config.clone() + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::ILanguageSpecificLogicClient + for super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient + { + fn GetRuntimeInformation(&mut self) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + super::r#_LanguageSpecificLogicImpl_Compile::_default::GetRuntimeInformation( + &self.config().clone(), + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_language_dspecific_dlogic_dinternaldafny::LanguageSpecificLogicClient { + ::dafny_runtime::UpcastObjectFn!(dyn super::r#_language_dspecific_dlogic_dinternaldafny_dtypes::ILanguageSpecificLogicClient); + } +} +pub mod _module {} diff --git a/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch index 1a4185309..2c973a895 100644 --- a/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Refinement/runtimes/rust/src/client.rs a/TestModels/Refinement/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..feeb912e +index 00000000..b9d63c1f --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/client.rs @@ -0,0 +1,40 @@ @@ -10,7 +10,7 @@ index 00000000..feeb912e + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..feeb912e + conf: crate::types::simple_refinement_config::SimpleRefinementConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_drefinement_dinternaldafny::_default::SimpleRefinement( ++ crate::simple::refinement::internaldafny::_default::SimpleRefinement( + &crate::conversions::simple_refinement_config::_simple_refinement_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -143,7 +143,7 @@ index 00000000..54b3f0f2 +pub mod simple_refinement_config; diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs new file mode 100644 -index 00000000..6a3ea7ea +index 00000000..6586e95d --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs @@ -0,0 +1,32 @@ @@ -154,21 +154,21 @@ index 00000000..6a3ea7ea +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_refinement::GetRefinementError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_refinement::GetRefinementError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::refinement::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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, ++ crate::r#simple::refinement::internaldafny::types::Error, + >, +) -> crate::operation::get_refinement::GetRefinementError { + // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_refinement::GetRefinementError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -181,16 +181,16 @@ index 00000000..6a3ea7ea +pub mod _get_refinement_output; diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs new file mode 100644 -index 00000000..654df8a8 +index 00000000..1d5b2459 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs -@@ -0,0 +1,52 @@ +@@ -0,0 +1,51 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_refinement::GetRefinementInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, ++ crate::r#simple::refinement::internaldafny::types::GetRefinementInput, +> { + let crate::operation::get_refinement::GetRefinementInput { + required_string, @@ -203,11 +203,11 @@ index 00000000..654df8a8 + ); + + let optional_string = match optional_string { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput::GetRefinementInput { ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::GetRefinementInput::GetRefinementInput { + requiredString: required_string, + optionalString: ::std::rc::Rc::new(optional_string), + }) @@ -216,10 +216,10 @@ index 00000000..654df8a8 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, ++ crate::r#simple::refinement::internaldafny::types::GetRefinementInput, + >, +) -> crate::operation::get_refinement::GetRefinementInput { -+ let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput::GetRefinementInput { requiredString, optionalString } = dafny_value.as_ref(); ++ let crate::r#simple::refinement::internaldafny::types::GetRefinementInput::GetRefinementInput { requiredString, optionalString } = dafny_value.as_ref(); + + let required_string = + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -227,9 +227,8 @@ index 00000000..654df8a8 + ); + + let optional_string = match optionalString.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(value)), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), ++ crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, ++ crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(value)), + }; + + crate::operation::get_refinement::GetRefinementInput { @@ -239,16 +238,16 @@ index 00000000..654df8a8 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs new file mode 100644 -index 00000000..42278a8f +index 00000000..6ffa4044 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs -@@ -0,0 +1,52 @@ +@@ -0,0 +1,51 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_refinement::GetRefinementOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, ++ crate::r#simple::refinement::internaldafny::types::GetRefinementOutput, +> { + let crate::operation::get_refinement::GetRefinementOutput { + required_string, @@ -261,11 +260,11 @@ index 00000000..42278a8f + ); + + let optional_string = match optional_string { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput::GetRefinementOutput { ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::GetRefinementOutput::GetRefinementOutput { + requiredString: required_string, + optionalString: ::std::rc::Rc::new(optional_string), + }) @@ -274,10 +273,10 @@ index 00000000..42278a8f +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, ++ crate::r#simple::refinement::internaldafny::types::GetRefinementOutput, + >, +) -> crate::operation::get_refinement::GetRefinementOutput { -+ let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput::GetRefinementOutput { requiredString, optionalString } = dafny_value.as_ref(); ++ let crate::r#simple::refinement::internaldafny::types::GetRefinementOutput::GetRefinementOutput { requiredString, optionalString } = dafny_value.as_ref(); + + let required_string = + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -285,9 +284,8 @@ index 00000000..42278a8f + ); + + let optional_string = match optionalString.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), ++ crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, ++ crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), + }; + + crate::operation::get_refinement::GetRefinementOutput { @@ -297,7 +295,7 @@ index 00000000..42278a8f +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs new file mode 100644 -index 00000000..ae52f851 +index 00000000..460f0edf --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs @@ -0,0 +1,37 @@ @@ -308,10 +306,10 @@ index 00000000..ae52f851 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::only_input::OnlyInputError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::only_input::OnlyInputError::Unhandled(unhandled) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::refinement::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -323,11 +321,11 @@ index 00000000..ae52f851 +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, ++ crate::r#simple::refinement::internaldafny::types::Error, + >, +) -> crate::operation::only_input::OnlyInputError { + // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::only_input::OnlyInputError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -340,25 +338,25 @@ index 00000000..ae52f851 +pub mod _only_input_output; diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs a/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs new file mode 100644 -index 00000000..f472165b +index 00000000..fbd63d3f --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs -@@ -0,0 +1,37 @@ +@@ -0,0 +1,36 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::only_input::OnlyInputInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, ++ crate::r#simple::refinement::internaldafny::types::OnlyInputInput, +> { + let crate::operation::only_input::OnlyInputInput { value } = value; + + let optional_string = match value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput::OnlyInputInput { ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::OnlyInputInput::OnlyInputInput { + value: ::std::rc::Rc::new(optional_string) + }) +} @@ -366,15 +364,14 @@ index 00000000..f472165b +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, ++ crate::r#simple::refinement::internaldafny::types::OnlyInputInput, + >, +) -> crate::operation::only_input::OnlyInputInput { -+ let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput::OnlyInputInput { value } = dafny_value.as_ref(); ++ let crate::r#simple::refinement::internaldafny::types::OnlyInputInput::OnlyInputInput { value } = dafny_value.as_ref(); + + let optional_string = match value.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), ++ crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, ++ crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), + }; + + crate::operation::only_input::OnlyInputInput { @@ -397,7 +394,7 @@ index 00000000..24a58661 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs new file mode 100644 -index 00000000..fa99f1e9 +index 00000000..c9a8d250 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs @@ -0,0 +1,37 @@ @@ -408,10 +405,10 @@ index 00000000..fa99f1e9 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::only_output::OnlyOutputError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::only_output::OnlyOutputError::Unhandled(unhandled) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::refinement::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -423,11 +420,11 @@ index 00000000..fa99f1e9 +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, ++ crate::r#simple::refinement::internaldafny::types::Error, + >, +) -> crate::operation::only_output::OnlyOutputError { + // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::only_output::OnlyOutputError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -454,25 +451,25 @@ index 00000000..58e99a74 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs a/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs new file mode 100644 -index 00000000..f71262a2 +index 00000000..106f9d8c --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs -@@ -0,0 +1,37 @@ +@@ -0,0 +1,36 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::only_output::OnlyOutputOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, ++ crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput, +> { + let crate::operation::only_output::OnlyOutputOutput { value } = value; + + let optional_string = match value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput::OnlyOutputOutput { ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput::OnlyOutputOutput { + value: ::std::rc::Rc::new(optional_string) + }) +} @@ -480,15 +477,14 @@ index 00000000..f71262a2 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, ++ crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput, + >, +) -> crate::operation::only_output::OnlyOutputOutput { -+ let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput::OnlyOutputOutput { value } = dafny_value.as_ref(); ++ let crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput::OnlyOutputOutput { value } = dafny_value.as_ref(); + + let optional_string = match value.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), ++ crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, ++ crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), + }; + + crate::operation::only_output::OnlyOutputOutput { @@ -497,7 +493,7 @@ index 00000000..f71262a2 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs new file mode 100644 -index 00000000..39ef340e +index 00000000..cd6ab475 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs @@ -0,0 +1,32 @@ @@ -508,21 +504,21 @@ index 00000000..39ef340e +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::readonly_operation::ReadonlyOperationError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::readonly_operation::ReadonlyOperationError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::refinement::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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, ++ crate::r#simple::refinement::internaldafny::types::Error, + >, +) -> crate::operation::readonly_operation::ReadonlyOperationError { + // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::readonly_operation::ReadonlyOperationError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -535,16 +531,16 @@ index 00000000..39ef340e +pub mod _readonly_operation_output; diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs new file mode 100644 -index 00000000..f5d78c82 +index 00000000..c6398a37 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs -@@ -0,0 +1,52 @@ +@@ -0,0 +1,51 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::readonly_operation::ReadonlyOperationInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, ++ crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput, +> { + let crate::operation::readonly_operation::ReadonlyOperationInput { + required_string, @@ -557,11 +553,11 @@ index 00000000..f5d78c82 + ); + + let optional_string = match optional_string { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput::ReadonlyOperationInput { ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput::ReadonlyOperationInput { + requiredString: required_string, + optionalString: ::std::rc::Rc::new(optional_string), + }) @@ -570,10 +566,10 @@ index 00000000..f5d78c82 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, ++ crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput, + >, +) -> crate::operation::readonly_operation::ReadonlyOperationInput { -+ let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput::ReadonlyOperationInput { requiredString, optionalString } = dafny_value.as_ref(); ++ let crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput::ReadonlyOperationInput { requiredString, optionalString } = dafny_value.as_ref(); + + let required_string = + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -581,9 +577,8 @@ index 00000000..f5d78c82 + ); + + let optional_string = match optionalString.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), ++ crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, ++ crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), + }; + + crate::operation::readonly_operation::ReadonlyOperationInput { @@ -593,16 +588,16 @@ index 00000000..f5d78c82 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs new file mode 100644 -index 00000000..f666f156 +index 00000000..a00fe9a0 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs -@@ -0,0 +1,52 @@ +@@ -0,0 +1,51 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::readonly_operation::ReadonlyOperationOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, ++ crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput, +> { + let crate::operation::readonly_operation::ReadonlyOperationOutput { + required_string, @@ -615,11 +610,11 @@ index 00000000..f666f156 + ); + + let optional_string = match optional_string { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput::ReadonlyOperationOutput { ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString: required_string, + optionalString: ::std::rc::Rc::new(optional_string), + }) @@ -628,10 +623,10 @@ index 00000000..f666f156 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, ++ crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput, + >, +) -> crate::operation::readonly_operation::ReadonlyOperationOutput { -+ let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput::ReadonlyOperationOutput { requiredString, optionalString } = dafny_value.as_ref(); ++ let crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput::ReadonlyOperationOutput { requiredString, optionalString } = dafny_value.as_ref(); + + let required_string = + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -639,9 +634,8 @@ index 00000000..f666f156 + ); + + let optional_string = match optionalString.as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), ++ crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, ++ crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), + }; + + crate::operation::readonly_operation::ReadonlyOperationOutput { @@ -660,7 +654,7 @@ index 00000000..9d22fe48 +pub mod _simple_refinement_config; diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs a/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs new file mode 100644 -index 00000000..fc750ac0 +index 00000000..41e00dbe --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs @@ -0,0 +1,19 @@ @@ -670,15 +664,15 @@ index 00000000..fc750ac0 +pub fn to_dafny( + value: crate::types::simple_refinement_config::SimpleRefinementConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig, ++ crate::simple::refinement::internaldafny::types::SimpleRefinementConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig::SimpleRefinementConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::SimpleRefinementConfig::SimpleRefinementConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig, ++ crate::r#simple::refinement::internaldafny::types::SimpleRefinementConfig, + >, +) -> crate::types::simple_refinement_config::SimpleRefinementConfig { + crate::types::simple_refinement_config::SimpleRefinementConfig {} @@ -735,6 +729,34 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs +index d9cc0581..6bcd1e00 100644 +--- b/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,23 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++ ++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; ++mod standard_library_conversions; ++ ++pub use client::Client; ++pub use types::simple_refinement_config::SimpleRefinementConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/Refinement/runtimes/rust/src/lib.rs a/TestModels/Refinement/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..33ef356e @@ -781,7 +803,7 @@ index 00000000..015f55f3 +pub mod readonly_operation; diff --git b/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs a/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs new file mode 100644 -index 00000000..4787b47b +index 00000000..6fe26ebe --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs @@ -0,0 +1,147 @@ @@ -809,7 +831,7 @@ index 00000000..4787b47b + ::dafny_runtime::md!(client.dafny_client.clone()).GetRefinement(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_refinement::_get_refinement_output::from_dafny( @@ -1233,7 +1255,7 @@ index 00000000..8be68872 +} diff --git b/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs a/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs new file mode 100644 -index 00000000..efc8308f +index 00000000..03ee1548 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs @@ -0,0 +1,146 @@ @@ -1260,7 +1282,7 @@ index 00000000..efc8308f + ::dafny_runtime::md!(client.dafny_client.clone()).OnlyInput(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::only_input::_only_input_output::from_dafny( @@ -1544,7 +1566,7 @@ index 00000000..9148352c +} diff --git b/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs a/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs new file mode 100644 -index 00000000..c0e947f7 +index 00000000..0a815e21 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs @@ -0,0 +1,143 @@ @@ -1568,7 +1590,7 @@ index 00000000..c0e947f7 + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).OnlyOutput(); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::only_output::_only_output_output::from_dafny( @@ -1845,7 +1867,7 @@ index 00000000..890d49af +} diff --git b/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs a/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs new file mode 100644 -index 00000000..5c941e61 +index 00000000..8940d4a3 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs @@ -0,0 +1,147 @@ @@ -1873,7 +1895,7 @@ index 00000000..5c941e61 + ::dafny_runtime::md!(client.dafny_client.clone()).ReadonlyOperation(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::readonly_operation::_readonly_operation_output::from_dafny( @@ -2287,6 +2309,259 @@ index 00000000..153306c8 + self.inner.get_optional_string() + } +} +diff --git b/TestModels/Refinement/runtimes/rust/src/standard_library_conversions.rs a/TestModels/Refinement/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/Refinement/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git b/TestModels/Refinement/runtimes/rust/src/types.rs a/TestModels/Refinement/runtimes/rust/src/types.rs new file mode 100644 index 00000000..2612ec35 diff --git a/TestModels/Refinement/runtimes/rust/Cargo.toml b/TestModels/Refinement/runtimes/rust/Cargo.toml index 705504af9..6ca1da232 100644 --- a/TestModels/Refinement/runtimes/rust/Cargo.toml +++ b/TestModels/Refinement/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/Refinement/runtimes/rust/src/client.rs b/TestModels/Refinement/runtimes/rust/src/client.rs index feeb912e2..b9d63c1fc 100644 --- a/TestModels/Refinement/runtimes/rust/src/client.rs +++ b/TestModels/Refinement/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_refinement_config::SimpleRefinementConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_drefinement_dinternaldafny::_default::SimpleRefinement( + crate::simple::refinement::internaldafny::_default::SimpleRefinement( &crate::conversions::simple_refinement_config::_simple_refinement_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs index 6a3ea7ea7..6586e95d9 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_refinement::GetRefinementError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_refinement::GetRefinementError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::refinement::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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, + crate::r#simple::refinement::internaldafny::types::Error, >, ) -> crate::operation::get_refinement::GetRefinementError { // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_refinement::GetRefinementError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs index 654df8a86..1d5b24591 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_input.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_refinement::GetRefinementInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, + crate::r#simple::refinement::internaldafny::types::GetRefinementInput, > { let crate::operation::get_refinement::GetRefinementInput { required_string, @@ -16,11 +16,11 @@ pub fn to_dafny( ); let optional_string = match optional_string { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput::GetRefinementInput { + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::GetRefinementInput::GetRefinementInput { requiredString: required_string, optionalString: ::std::rc::Rc::new(optional_string), }) @@ -29,10 +29,10 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, + crate::r#simple::refinement::internaldafny::types::GetRefinementInput, >, ) -> crate::operation::get_refinement::GetRefinementInput { - let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput::GetRefinementInput { requiredString, optionalString } = dafny_value.as_ref(); + let crate::r#simple::refinement::internaldafny::types::GetRefinementInput::GetRefinementInput { requiredString, optionalString } = dafny_value.as_ref(); let required_string = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -40,9 +40,8 @@ pub fn from_dafny( ); let optional_string = match optionalString.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(value)), - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, + crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(value)), }; crate::operation::get_refinement::GetRefinementInput { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs index 42278a8f2..6ffa40441 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement/_get_refinement_output.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_refinement::GetRefinementOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, + crate::r#simple::refinement::internaldafny::types::GetRefinementOutput, > { let crate::operation::get_refinement::GetRefinementOutput { required_string, @@ -16,11 +16,11 @@ pub fn to_dafny( ); let optional_string = match optional_string { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput::GetRefinementOutput { + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::GetRefinementOutput::GetRefinementOutput { requiredString: required_string, optionalString: ::std::rc::Rc::new(optional_string), }) @@ -29,10 +29,10 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, + crate::r#simple::refinement::internaldafny::types::GetRefinementOutput, >, ) -> crate::operation::get_refinement::GetRefinementOutput { - let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput::GetRefinementOutput { requiredString, optionalString } = dafny_value.as_ref(); + let crate::r#simple::refinement::internaldafny::types::GetRefinementOutput::GetRefinementOutput { requiredString, optionalString } = dafny_value.as_ref(); let required_string = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -40,9 +40,8 @@ pub fn from_dafny( ); let optional_string = match optionalString.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, + crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), }; crate::operation::get_refinement::GetRefinementOutput { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs b/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs index ae52f8510..460f0edfa 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs @@ -5,10 +5,10 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::only_input::OnlyInputError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::only_input::OnlyInputError::Unhandled(unhandled) => ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::refinement::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -20,11 +20,11 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, + crate::r#simple::refinement::internaldafny::types::Error, >, ) -> crate::operation::only_input::OnlyInputError { // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::only_input::OnlyInputError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs b/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs index f472165bc..fbd63d3f6 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/only_input/_only_input_input.rs @@ -3,16 +3,16 @@ pub fn to_dafny( value: crate::operation::only_input::OnlyInputInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, + crate::r#simple::refinement::internaldafny::types::OnlyInputInput, > { let crate::operation::only_input::OnlyInputInput { value } = value; let optional_string = match value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput::OnlyInputInput { + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::OnlyInputInput::OnlyInputInput { value: ::std::rc::Rc::new(optional_string) }) } @@ -20,15 +20,14 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, + crate::r#simple::refinement::internaldafny::types::OnlyInputInput, >, ) -> crate::operation::only_input::OnlyInputInput { - let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput::OnlyInputInput { value } = dafny_value.as_ref(); + let crate::r#simple::refinement::internaldafny::types::OnlyInputInput::OnlyInputInput { value } = dafny_value.as_ref(); let optional_string = match value.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, + crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), }; crate::operation::only_input::OnlyInputInput { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs b/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs index fa99f1e9d..c9a8d2504 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs @@ -5,10 +5,10 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::only_output::OnlyOutputError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::only_output::OnlyOutputError::Unhandled(unhandled) => ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::refinement::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -20,11 +20,11 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, + crate::r#simple::refinement::internaldafny::types::Error, >, ) -> crate::operation::only_output::OnlyOutputError { // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::only_output::OnlyOutputError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs b/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs index f71262a2d..106f9d8c9 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/only_output/_only_output_output.rs @@ -3,16 +3,16 @@ pub fn to_dafny( value: crate::operation::only_output::OnlyOutputOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, + crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput, > { let crate::operation::only_output::OnlyOutputOutput { value } = value; let optional_string = match value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput::OnlyOutputOutput { + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput::OnlyOutputOutput { value: ::std::rc::Rc::new(optional_string) }) } @@ -20,15 +20,14 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, + crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput, >, ) -> crate::operation::only_output::OnlyOutputOutput { - let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput::OnlyOutputOutput { value } = dafny_value.as_ref(); + let crate::r#simple::refinement::internaldafny::types::OnlyOutputOutput::OnlyOutputOutput { value } = dafny_value.as_ref(); let optional_string = match value.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, + crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), }; crate::operation::only_output::OnlyOutputOutput { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs index 39ef340ee..cd6ab4756 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::readonly_operation::ReadonlyOperationError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::readonly_operation::ReadonlyOperationError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::refinement::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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error, + crate::r#simple::refinement::internaldafny::types::Error, >, ) -> crate::operation::readonly_operation::ReadonlyOperationError { // 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::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::refinement::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::readonly_operation::ReadonlyOperationError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs index f5d78c823..c6398a37e 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_input.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::readonly_operation::ReadonlyOperationInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, + crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput, > { let crate::operation::readonly_operation::ReadonlyOperationInput { required_string, @@ -16,11 +16,11 @@ pub fn to_dafny( ); let optional_string = match optional_string { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput::ReadonlyOperationInput { + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput::ReadonlyOperationInput { requiredString: required_string, optionalString: ::std::rc::Rc::new(optional_string), }) @@ -29,10 +29,10 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, + crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput, >, ) -> crate::operation::readonly_operation::ReadonlyOperationInput { - let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput::ReadonlyOperationInput { requiredString, optionalString } = dafny_value.as_ref(); + let crate::r#simple::refinement::internaldafny::types::ReadonlyOperationInput::ReadonlyOperationInput { requiredString, optionalString } = dafny_value.as_ref(); let required_string = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -40,9 +40,8 @@ pub fn from_dafny( ); let optional_string = match optionalString.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, + crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), }; crate::operation::readonly_operation::ReadonlyOperationInput { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs index f666f1561..a00fe9a0e 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation/_readonly_operation_output.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::readonly_operation::ReadonlyOperationOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, + crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput, > { let crate::operation::readonly_operation::ReadonlyOperationOutput { required_string, @@ -16,11 +16,11 @@ pub fn to_dafny( ); let optional_string = match optional_string { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput::ReadonlyOperationOutput { + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput::ReadonlyOperationOutput { requiredString: required_string, optionalString: ::std::rc::Rc::new(optional_string), }) @@ -29,10 +29,10 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, + crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput, >, ) -> crate::operation::readonly_operation::ReadonlyOperationOutput { - let crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput::ReadonlyOperationOutput { requiredString, optionalString } = dafny_value.as_ref(); + let crate::r#simple::refinement::internaldafny::types::ReadonlyOperationOutput::ReadonlyOperationOutput { requiredString, optionalString } = dafny_value.as_ref(); let required_string = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -40,9 +40,8 @@ pub fn from_dafny( ); let optional_string = match optionalString.as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + crate::_Wrappers_Compile::Option::None {} => ::std::option::Option::None, + crate::_Wrappers_Compile::Option::Some { value } => ::std::option::Option::Some(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value)), }; crate::operation::readonly_operation::ReadonlyOperationOutput { diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs b/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs index fc750ac07..41e00dbe3 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/simple_refinement_config/_simple_refinement_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_refinement_config::SimpleRefinementConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig, + crate::simple::refinement::internaldafny::types::SimpleRefinementConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig::SimpleRefinementConfig {}) + ::std::rc::Rc::new(crate::r#simple::refinement::internaldafny::types::SimpleRefinementConfig::SimpleRefinementConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig, + crate::r#simple::refinement::internaldafny::types::SimpleRefinementConfig, >, ) -> crate::types::simple_refinement_config::SimpleRefinementConfig { crate::types::simple_refinement_config::SimpleRefinementConfig {} diff --git a/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..6bcd1e002 --- /dev/null +++ b/TestModels/Refinement/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2663 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + + +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; +mod standard_library_conversions; + +pub use client::Client; +pub use types::simple_refinement_config::SimpleRefinementConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod refinement { + pub mod internaldafny { + pub use crate::simple::refinement::internaldafny::types::ISimpleRefinementClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleRefinementConfig() -> ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::SimpleRefinementConfig, + > { + ::std::rc::Rc::new(crate::simple::refinement::internaldafny::types::SimpleRefinementConfig::SimpleRefinementConfig {}) + } + pub fn SimpleRefinement( + config: &::std::rc::Rc< + crate::simple::refinement::internaldafny::types::SimpleRefinementConfig, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::refinement::internaldafny::SimpleRefinementClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::refinement::internaldafny::SimpleRefinementClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::refinement::internaldafny::SimpleRefinementClient::_allocate_object(); + crate::simple::refinement::internaldafny::SimpleRefinementClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleRefinementImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + crate::simple::refinement::internaldafny::SimpleRefinementClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleRefinementClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleRefinementClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::refinement::internaldafny::SimpleRefinementClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::refinement::internaldafny::SimpleRefinementClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleRefinementClient for crate::simple::refinement::internaldafny::SimpleRefinementClient { + fn GetRefinement( + &mut self, + input: &::std::rc::Rc< + crate::simple::refinement::internaldafny::types::GetRefinementInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::GetRefinementOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleRefinementImpl_Compile::_default::GetRefinement( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn OnlyInput( + &mut self, + input: &::std::rc::Rc< + crate::simple::refinement::internaldafny::types::OnlyInputInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + (), + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + (), + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::Error, + >, + >, + >, + >::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + (), + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::Error, + >, + >, + >, + >::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleRefinementImpl_Compile::_default::OnlyInput( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + fn OnlyOutput( + &mut self, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::OnlyOutputOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleRefinementImpl_Compile::_default::OnlyOutput( + &self.config().clone(), + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + return output.read(); + } + fn ReadonlyOperation(&self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + crate::r#_SimpleRefinementImpl_Compile::_default::ReadonlyOperation( + &self.config().clone(), + input, + ) + } + } + + impl UpcastObject + for crate::simple::refinement::internaldafny::SimpleRefinementClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::refinement::internaldafny::types::ISimpleRefinementClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.refinement.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetRefinementInput { + GetRefinementInput { + requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + optionalString: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetRefinementInput { + pub fn requiredString( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + GetRefinementInput::GetRefinementInput { + requiredString, + optionalString, + } => requiredString, + } + } + pub fn optionalString( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetRefinementInput::GetRefinementInput { + requiredString, + optionalString, + } => optionalString, + } + } + } + + impl Debug for GetRefinementInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetRefinementInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetRefinementInput::GetRefinementInput { + requiredString, + optionalString, + } => { + write!(_formatter, "simple.refinement.internaldafny.types.GetRefinementInput.GetRefinementInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + requiredString, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + optionalString, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetRefinementInput {} + + impl Hash for GetRefinementInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetRefinementInput::GetRefinementInput { + requiredString, + optionalString, + } => { + ::std::hash::Hash::hash(requiredString, _state); + ::std::hash::Hash::hash(optionalString, _state) + } + } + } + } + + impl Default for GetRefinementInput { + fn default() -> GetRefinementInput { + GetRefinementInput::GetRefinementInput { + requiredString: ::std::default::Default::default(), + optionalString: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetRefinementInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetRefinementOutput { + GetRefinementOutput { + requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + optionalString: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetRefinementOutput { + pub fn requiredString( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + GetRefinementOutput::GetRefinementOutput { + requiredString, + optionalString, + } => requiredString, + } + } + pub fn optionalString( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetRefinementOutput::GetRefinementOutput { + requiredString, + optionalString, + } => optionalString, + } + } + } + + impl Debug for GetRefinementOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetRefinementOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetRefinementOutput::GetRefinementOutput { + requiredString, + optionalString, + } => { + write!(_formatter, "simple.refinement.internaldafny.types.GetRefinementOutput.GetRefinementOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + requiredString, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + optionalString, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetRefinementOutput {} + + impl Hash for GetRefinementOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetRefinementOutput::GetRefinementOutput { + requiredString, + optionalString, + } => { + ::std::hash::Hash::hash(requiredString, _state); + ::std::hash::Hash::hash(optionalString, _state) + } + } + } + } + + impl Default for GetRefinementOutput { + fn default() -> GetRefinementOutput { + GetRefinementOutput::GetRefinementOutput { + requiredString: ::std::default::Default::default(), + optionalString: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetRefinementOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum OnlyInputInput { + OnlyInputInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl OnlyInputInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + OnlyInputInput::OnlyInputInput { value } => value, + } + } + } + + impl Debug for OnlyInputInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for OnlyInputInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + OnlyInputInput::OnlyInputInput { value } => { + write!(_formatter, "simple.refinement.internaldafny.types.OnlyInputInput.OnlyInputInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for OnlyInputInput {} + + impl Hash for OnlyInputInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + OnlyInputInput::OnlyInputInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for OnlyInputInput { + fn default() -> OnlyInputInput { + OnlyInputInput::OnlyInputInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &OnlyInputInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum OnlyOutputOutput { + OnlyOutputOutput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl OnlyOutputOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + OnlyOutputOutput::OnlyOutputOutput { value } => value, + } + } + } + + impl Debug for OnlyOutputOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for OnlyOutputOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + OnlyOutputOutput::OnlyOutputOutput { value } => { + write!(_formatter, "simple.refinement.internaldafny.types.OnlyOutputOutput.OnlyOutputOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for OnlyOutputOutput {} + + impl Hash for OnlyOutputOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + OnlyOutputOutput::OnlyOutputOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for OnlyOutputOutput { + fn default() -> OnlyOutputOutput { + OnlyOutputOutput::OnlyOutputOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &OnlyOutputOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum ReadonlyOperationInput { + ReadonlyOperationInput { + requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + optionalString: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl ReadonlyOperationInput { + pub fn requiredString( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + ReadonlyOperationInput::ReadonlyOperationInput { + requiredString, + optionalString, + } => requiredString, + } + } + pub fn optionalString( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + ReadonlyOperationInput::ReadonlyOperationInput { + requiredString, + optionalString, + } => optionalString, + } + } + } + + impl Debug for ReadonlyOperationInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for ReadonlyOperationInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + ReadonlyOperationInput::ReadonlyOperationInput { + requiredString, + optionalString, + } => { + write!(_formatter, "simple.refinement.internaldafny.types.ReadonlyOperationInput.ReadonlyOperationInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + requiredString, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + optionalString, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for ReadonlyOperationInput {} + + impl Hash for ReadonlyOperationInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + ReadonlyOperationInput::ReadonlyOperationInput { + requiredString, + optionalString, + } => { + ::std::hash::Hash::hash(requiredString, _state); + ::std::hash::Hash::hash(optionalString, _state) + } + } + } + } + + impl Default for ReadonlyOperationInput { + fn default() -> ReadonlyOperationInput { + ReadonlyOperationInput::ReadonlyOperationInput { + requiredString: ::std::default::Default::default(), + optionalString: ::std::default::Default::default(), + } + } + } + + impl AsRef for &ReadonlyOperationInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum ReadonlyOperationOutput { + ReadonlyOperationOutput { + requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + optionalString: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl ReadonlyOperationOutput { + pub fn requiredString( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString, + optionalString, + } => requiredString, + } + } + pub fn optionalString( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString, + optionalString, + } => optionalString, + } + } + } + + impl Debug for ReadonlyOperationOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for ReadonlyOperationOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString, + optionalString, + } => { + write!(_formatter, "simple.refinement.internaldafny.types.ReadonlyOperationOutput.ReadonlyOperationOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + requiredString, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + optionalString, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for ReadonlyOperationOutput {} + + impl Hash for ReadonlyOperationOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString, + optionalString, + } => { + ::std::hash::Hash::hash(requiredString, _state); + ::std::hash::Hash::hash(optionalString, _state) + } + } + } + } + + impl Default for ReadonlyOperationOutput { + fn default() -> ReadonlyOperationOutput { + ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString: ::std::default::Default::default(), + optionalString: ::std::default::Default::default(), + } + } + } + + impl AsRef for &ReadonlyOperationOutput { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleRefinementClientCallHistory {} + + impl ISimpleRefinementClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::refinement::internaldafny::types::ISimpleRefinementClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleRefinementClient: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetRefinement(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn OnlyInput( + &mut self, + input: &::std::rc::Rc< + crate::simple::refinement::internaldafny::types::OnlyInputInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + (), + ::std::rc::Rc, + >, + >; + fn OnlyOutput( + &mut self, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::OnlyOutputOutput, + >, + ::std::rc::Rc, + >, + >; + fn ReadonlyOperation(&self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum SimpleRefinementConfig { + SimpleRefinementConfig {}, + } + + impl SimpleRefinementConfig {} + + impl Debug for SimpleRefinementConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleRefinementConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleRefinementConfig::SimpleRefinementConfig {} => { + write!(_formatter, "simple.refinement.internaldafny.types.SimpleRefinementConfig.SimpleRefinementConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleRefinementConfig {} + + impl Hash for SimpleRefinementConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleRefinementConfig::SimpleRefinementConfig {} => {} + } + } + } + + impl Default for SimpleRefinementConfig { + fn default() -> SimpleRefinementConfig { + SimpleRefinementConfig::SimpleRefinementConfig {} + } + } + + impl AsRef for &SimpleRefinementConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.refinement.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.refinement.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } +} +pub mod r#_SimpleRefinementImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetRefinement( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::refinement::internaldafny::types::GetRefinementInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::GetRefinementOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::refinement::internaldafny::types::GetRefinementOutput::GetRefinementOutput { + requiredString: input.requiredString().clone(), + optionalString: input.optionalString().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::GetRefinementOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn OnlyInput( + config: &::std::rc::Rc, + input: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + (), + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + (), + ::std::rc::Rc, + >, + >, + >::new(); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(input)); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + (), + ::std::rc::Rc, + >::Success { + value: (), + }, + )); + return output.read(); + } + pub fn OnlyOutput( + config: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::OnlyOutputOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::refinement::internaldafny::types::OnlyOutputOutput::OnlyOutputOutput { + value: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: ::dafny_runtime::string_utf16_of("Hello World") + }) + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::OnlyOutputOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn ReadonlyOperation( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::refinement::internaldafny::types::ReadonlyOperationInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::refinement::internaldafny::types::ReadonlyOperationOutput, + >, + ::std::rc::Rc, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { + value: ::std::rc::Rc::new(crate::simple::refinement::internaldafny::types::ReadonlyOperationOutput::ReadonlyOperationOutput { + requiredString: input.requiredString().clone(), + optionalString: input.optionalString().clone() + }) + }) + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleRefinementImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs b/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs index 4787b47ba..6fe26ebee 100644 --- a/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs +++ b/TestModels/Refinement/runtimes/rust/src/operation/get_refinement.rs @@ -22,7 +22,7 @@ impl GetRefinement { ::dafny_runtime::md!(client.dafny_client.clone()).GetRefinement(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_refinement::_get_refinement_output::from_dafny( diff --git a/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs b/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs index efc8308fb..03ee15483 100644 --- a/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs +++ b/TestModels/Refinement/runtimes/rust/src/operation/only_input.rs @@ -21,7 +21,7 @@ impl OnlyInput { ::dafny_runtime::md!(client.dafny_client.clone()).OnlyInput(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::only_input::_only_input_output::from_dafny( diff --git a/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs b/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs index c0e947f74..0a815e211 100644 --- a/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs +++ b/TestModels/Refinement/runtimes/rust/src/operation/only_output.rs @@ -18,7 +18,7 @@ impl OnlyOutput { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).OnlyOutput(); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::only_output::_only_output_output::from_dafny( diff --git a/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs b/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs index 5c941e611..8940d4a38 100644 --- a/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs +++ b/TestModels/Refinement/runtimes/rust/src/operation/readonly_operation.rs @@ -22,7 +22,7 @@ impl ReadonlyOperation { ::dafny_runtime::md!(client.dafny_client.clone()).ReadonlyOperation(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::readonly_operation::_readonly_operation_output::from_dafny( diff --git a/TestModels/Refinement/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Refinement/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/Refinement/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch index 3d05c3e4c..023a075ac 100644 --- a/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Resource/runtimes/rust/src/client.rs a/TestModels/Resource/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..ce55ba69 +index 00000000..593b1051 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/client.rs @@ -0,0 +1,39 @@ @@ -10,7 +10,7 @@ index 00000000..ce55ba69 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,14 +20,14 @@ index 00000000..ce55ba69 + conf: crate::types::simple_resources_config::SimpleResourcesConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dresources_dinternaldafny::_default::SimpleResources( ++ crate::simple::resources::internaldafny::_default::SimpleResources( + &crate::conversions::simple_resources_config::_simple_resources_config::to_dafny( + conf, + ), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -78,7 +78,7 @@ index 00000000..6db43c2c +pub mod simple_resources_config; diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs new file mode 100644 -index 00000000..f329aa4b +index 00000000..ec6cd5b2 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs @@ -0,0 +1,32 @@ @@ -89,21 +89,21 @@ index 00000000..f329aa4b +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_resource_data::GetResourceDataError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_resource_data::GetResourceDataError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::resources::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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error, ++ crate::r#simple::resources::internaldafny::types::Error, + >, +) -> crate::operation::get_resource_data::GetResourceDataError { + // 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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::resources::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_resource_data::GetResourceDataError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -116,7 +116,7 @@ index 00000000..f329aa4b +pub mod _get_resource_data_output; diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs new file mode 100644 -index 00000000..5c0d40ef +index 00000000..3c8f9f69 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_input.rs @@ -0,0 +1,39 @@ @@ -125,25 +125,25 @@ index 00000000..5c0d40ef +pub fn to_dafny( + value: crate::operation::get_resource_data::GetResourceDataInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, ++ crate::r#simple::resources::internaldafny::types::GetResourceDataInput, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput::GetResourceDataInput { -+ stringValue: dafny_standard_library::conversion::ostring_to_dafny(value.string_value()), -+ booleanValue: dafny_standard_library::conversion::obool_to_dafny(value.boolean_value()), -+ integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value()), -+ longValue: dafny_standard_library::conversion::olong_to_dafny(value.long_value()), -+ blobValue: dafny_standard_library::conversion::oblob_to_dafny(value.blob_value()) ++ ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourceDataInput::GetResourceDataInput { ++ stringValue: crate::standard_library_conversions::ostring_to_dafny(value.string_value()), ++ booleanValue: crate::standard_library_conversions::obool_to_dafny(value.boolean_value()), ++ integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value()), ++ longValue: crate::standard_library_conversions::olong_to_dafny(value.long_value()), ++ blobValue: crate::standard_library_conversions::oblob_to_dafny(value.blob_value()) + }) +} +// _get_resource_data_Input +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, ++ crate::r#simple::resources::internaldafny::types::GetResourceDataInput, + >, +) -> crate::operation::get_resource_data::GetResourceDataInput { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput::GetResourceDataInput { ++ crate::r#simple::resources::internaldafny::types::GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + integerValue, @@ -151,17 +151,17 @@ index 00000000..5c0d40ef + stringValue, + } => + crate::operation::get_resource_data::GetResourceDataInput { -+ string_value: dafny_standard_library::conversion::ostring_from_dafny(stringValue.clone()), -+ boolean_value: dafny_standard_library::conversion::obool_from_dafny(booleanValue.clone()), -+ integer_value: dafny_standard_library::conversion::oint_from_dafny(integerValue.clone()), -+ long_value: dafny_standard_library::conversion::olong_from_dafny(longValue.clone()), -+ blob_value: dafny_standard_library::conversion::oblob_from_dafny(blobValue.clone()) ++ string_value: crate::standard_library_conversions::ostring_from_dafny(stringValue.clone()), ++ boolean_value: crate::standard_library_conversions::obool_from_dafny(booleanValue.clone()), ++ integer_value: crate::standard_library_conversions::oint_from_dafny(integerValue.clone()), ++ long_value: crate::standard_library_conversions::olong_from_dafny(longValue.clone()), ++ blob_value: crate::standard_library_conversions::oblob_from_dafny(blobValue.clone()) + } + } +} diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs new file mode 100644 -index 00000000..33ffc699 +index 00000000..514edbdb --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data/_get_resource_data_output.rs @@ -0,0 +1,39 @@ @@ -170,25 +170,25 @@ index 00000000..33ffc699 +pub fn to_dafny( + value: crate::operation::get_resource_data::GetResourceDataOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, ++ crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput::GetResourceDataOutput { -+ stringValue: dafny_standard_library::conversion::ostring_to_dafny(value.string_value()), -+ booleanValue: dafny_standard_library::conversion::obool_to_dafny(value.boolean_value()), -+ integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value()), -+ longValue: dafny_standard_library::conversion::olong_to_dafny(value.long_value()), -+ blobValue: dafny_standard_library::conversion::oblob_to_dafny(value.blob_value()) ++ ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourceDataOutput::GetResourceDataOutput { ++ stringValue: crate::standard_library_conversions::ostring_to_dafny(value.string_value()), ++ booleanValue: crate::standard_library_conversions::obool_to_dafny(value.boolean_value()), ++ integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value()), ++ longValue: crate::standard_library_conversions::olong_to_dafny(value.long_value()), ++ blobValue: crate::standard_library_conversions::oblob_to_dafny(value.blob_value()) + }) +} +// _get_resource_data_output +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, ++ crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, + >, +) -> crate::operation::get_resource_data::GetResourceDataOutput { + match &*dafny_value { -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput::GetResourceDataOutput { ++ crate::r#simple::resources::internaldafny::types::GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + integerValue, @@ -196,17 +196,17 @@ index 00000000..33ffc699 + stringValue, + } => + crate::operation::get_resource_data::GetResourceDataOutput { -+ string_value: dafny_standard_library::conversion::ostring_from_dafny(stringValue.clone()), -+ boolean_value: dafny_standard_library::conversion::obool_from_dafny(booleanValue.clone()), -+ integer_value: dafny_standard_library::conversion::oint_from_dafny(integerValue.clone()), -+ long_value: dafny_standard_library::conversion::olong_from_dafny(longValue.clone()), -+ blob_value: dafny_standard_library::conversion::oblob_from_dafny(blobValue.clone()) ++ string_value: crate::standard_library_conversions::ostring_from_dafny(stringValue.clone()), ++ boolean_value: crate::standard_library_conversions::obool_from_dafny(booleanValue.clone()), ++ integer_value: crate::standard_library_conversions::oint_from_dafny(integerValue.clone()), ++ long_value: crate::standard_library_conversions::olong_from_dafny(longValue.clone()), ++ blob_value: crate::standard_library_conversions::oblob_from_dafny(blobValue.clone()) + } + } +} diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs new file mode 100644 -index 00000000..eb244cbd +index 00000000..1cffc46a --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs @@ -0,0 +1,32 @@ @@ -217,21 +217,21 @@ index 00000000..eb244cbd +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_resources::GetResourcesError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_resources::GetResourcesError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::resources::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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error, ++ crate::r#simple::resources::internaldafny::types::Error, + >, +) -> crate::operation::get_resources::GetResourcesError { + // 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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::resources::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_resources::GetResourcesError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -244,7 +244,7 @@ index 00000000..eb244cbd +pub mod _get_resources_output; diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs new file mode 100644 -index 00000000..544cb9f8 +index 00000000..95e17091 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_input.rs @@ -0,0 +1,43 @@ @@ -253,15 +253,15 @@ index 00000000..544cb9f8 +pub fn to_dafny( + value: crate::operation::get_resources::GetResourcesInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, ++ crate::r#simple::resources::internaldafny::types::GetResourcesInput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&b) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput::GetResourcesInput { ++ ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourcesInput::GetResourcesInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -269,12 +269,12 @@ index 00000000..544cb9f8 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, ++ crate::r#simple::resources::internaldafny::types::GetResourcesInput, + >, +) -> crate::operation::get_resources::GetResourcesInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -283,7 +283,7 @@ index 00000000..544cb9f8 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -293,7 +293,7 @@ index 00000000..544cb9f8 +} diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs new file mode 100644 -index 00000000..11651495 +index 00000000..294b93b5 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs @@ -0,0 +1,111 @@ @@ -303,15 +303,15 @@ index 00000000..11651495 +pub fn to_dafny( + value: crate::operation::get_resources::GetResourcesOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, ++ crate::r#simple::resources::internaldafny::types::GetResourcesOutput, +> { + let wrap = SimpleResourceWrapper { + obj: value.output.clone(), + }; -+ let inner : ::std::rc::Rc<::std::cell::UnsafeCell> ++ let inner : ::std::rc::Rc<::std::cell::UnsafeCell> + = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); + -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput::GetResourcesOutput { ++ ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourcesOutput::GetResourcesOutput { + output: ::dafny_runtime::Object (Some(inner) ) + }) +} @@ -319,7 +319,7 @@ index 00000000..11651495 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, ++ crate::r#simple::resources::internaldafny::types::GetResourcesOutput, + >, +) -> crate::operation::get_resources::GetResourcesOutput { + let wrap = SimpleResourceDafnyWrapper { @@ -338,20 +338,20 @@ index 00000000..11651495 + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} + -+impl crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource ++impl crate::r#simple::resources::internaldafny::types::ISimpleResource + for SimpleResourceWrapper +{ + fn r#_GetResourceData_k( + &mut self, + input: &::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, ++ crate::r#simple::resources::internaldafny::types::GetResourceDataInput, + >, + ) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result< ++ crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, ++ crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, + >, -+ ::std::rc::Rc, ++ ::std::rc::Rc, + >, + > + { @@ -361,12 +361,12 @@ index 00000000..11651495 + ); + let inner_result = self.obj.borrow_mut().get_resource_data(inner_input); + let result = match inner_result { -+ Ok(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { ++ Ok(x) => crate::r#_Wrappers_Compile::Result::Success { + value: crate::conversions::get_resource_data::_get_resource_data_output::to_dafny( + x, + ), + }, -+ Err(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Failure { ++ Err(x) => crate::r#_Wrappers_Compile::Result::Failure { + error: crate::conversions::get_resource_data::to_dafny_error(x), + }, + }; @@ -377,7 +377,7 @@ index 00000000..11651495 +#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] +pub struct SimpleResourceDafnyWrapper { + pub(crate) obj: ::dafny_runtime::Object< -+ dyn crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, ++ dyn crate::r#simple::resources::internaldafny::types::ISimpleResource, + >, +} + @@ -394,7 +394,7 @@ index 00000000..11651495 + let inner_result = ::dafny_runtime::md!(self.obj.clone()).GetResourceData(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_resource_data::_get_resource_data_output::from_dafny( @@ -419,7 +419,7 @@ index 00000000..5121f1c0 +pub mod _simple_resources_config; diff --git b/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs a/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs new file mode 100644 -index 00000000..2d0c9438 +index 00000000..33886d22 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/simple_resources_config/_simple_resources_config.rs @@ -0,0 +1,26 @@ @@ -429,9 +429,9 @@ index 00000000..2d0c9438 +pub fn to_dafny( + value: crate::types::simple_resources_config::SimpleResourcesConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, ++ crate::simple::resources::internaldafny::types::SimpleResourcesConfig, +> { -+ let inner = crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig::SimpleResourcesConfig { ++ let inner = crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig::SimpleResourcesConfig { + name : dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&value.name) + }; + ::std::rc::Rc::new(inner) @@ -440,7 +440,7 @@ index 00000000..2d0c9438 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, ++ crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, + >, +) -> crate::types::simple_resources_config::SimpleResourcesConfig { + crate::types::simple_resources_config::SimpleResourcesConfig { @@ -501,6 +501,153 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs +index 8b7375ca..d698ebfd 100644 +--- b/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,22 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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; ++mod standard_library_conversions; ++ ++pub use client::Client; ++pub use types::simple_resources_config::SimpleResourcesConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; +@@ -1380,13 +1396,13 @@ pub mod simple { + >, + >::new(); + let mut internalConfig: ::std::rc::Rc< +- crate::r#_SimpleResourcesOperations_Compile::Config, ++ crate::r#simpleResourcesOperations_Compile::Config, + > = ::std::rc::Rc::new( +- crate::r#_SimpleResourcesOperations_Compile::Config::Config { ++ crate::r#simpleResourcesOperations_Compile::Config::Config { + name: config.name().clone(), + }, + ); +- if crate::r#_SimpleResourcesOperations_Compile::_default::r#_ValidInternalConfig_q(&internalConfig) { ++ if crate::r#simpleResourcesOperations_Compile::_default::r#_ValidInternalConfig_q(&internalConfig) { + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut _nw2: ::dafny_runtime::Object = crate::simple::resources::internaldafny::SimpleResourcesClient::_allocate_object(); + crate::simple::resources::internaldafny::SimpleResourcesClient::_ctor(&_nw2, &internalConfig); +@@ -1419,7 +1435,7 @@ pub mod simple { + + pub struct SimpleResourcesClient { + pub r#__i_config: +- ::std::rc::Rc, ++ ::std::rc::Rc, + } + + impl SimpleResourcesClient { +@@ -1430,7 +1446,7 @@ pub mod simple { + this: &::dafny_runtime::Object< + crate::simple::resources::internaldafny::SimpleResourcesClient, + >, +- config: &::std::rc::Rc, ++ config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( +@@ -1443,7 +1459,7 @@ pub mod simple { + } + pub fn config( + &self, +- ) -> ::std::rc::Rc ++ ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } +@@ -1470,7 +1486,7 @@ pub mod simple { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( +- crate::r#_SimpleResourcesOperations_Compile::_default::GetResources( ++ crate::r#simpleResourcesOperations_Compile::_default::GetResources( + &self.config().clone(), + input, + ), +@@ -2358,7 +2374,7 @@ pub mod simple { + } + } + } +-pub mod r#_SimpleResource_Compile { ++pub mod r#simpleResource_Compile { + pub use crate::simple::resources::internaldafny::types::ISimpleResource; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; +@@ -2377,7 +2393,7 @@ pub mod r#_SimpleResource_Compile { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( +- this: &::dafny_runtime::Object, ++ this: &::dafny_runtime::Object, + value: &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, +@@ -2481,7 +2497,7 @@ pub mod r#_SimpleResource_Compile { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::resources::internaldafny::types::ISimpleResource); + } + } +-pub mod r#_SimpleResourcesOperations_Compile { ++pub mod r#simpleResourcesOperations_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; +@@ -2493,12 +2509,12 @@ pub mod r#_SimpleResourcesOperations_Compile { + + impl _default { + pub fn r#_ValidInternalConfig_q( +- config: &::std::rc::Rc, ++ config: &::std::rc::Rc, + ) -> bool { + true && ::dafny_runtime::int!(0) < config.name().cardinality() + } + pub fn GetResources( +- config: &::std::rc::Rc, ++ config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesInput, + >, +@@ -2519,19 +2535,19 @@ pub mod r#_SimpleResourcesOperations_Compile { + >, + >::new(); + let mut resource = ::dafny_runtime::MaybePlacebo::< +- ::dafny_runtime::Object, ++ ::dafny_runtime::Object, + >::new(); + let mut _nw1: ::dafny_runtime::Object< +- crate::r#_SimpleResource_Compile::SimpleResource, +- > = crate::r#_SimpleResource_Compile::SimpleResource::_allocate_object(); +- crate::r#_SimpleResource_Compile::SimpleResource::_ctor( ++ crate::r#simpleResource_Compile::SimpleResource, ++ > = crate::r#simpleResource_Compile::SimpleResource::_allocate_object(); ++ crate::r#simpleResource_Compile::SimpleResource::_ctor( + &_nw1, + input.value(), + config.name(), + ); + resource = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + let mut result: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::resources::internaldafny::types::GetResourcesOutput::GetResourcesOutput { +- output: ::dafny_runtime::upcast_object::()(resource.read()) ++ output: ::dafny_runtime::upcast_object::()(resource.read()) + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< diff --git b/TestModels/Resource/runtimes/rust/src/lib.rs a/TestModels/Resource/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..7d3dac61 @@ -1156,7 +1303,7 @@ index 00000000..9c1c4890 +} diff --git b/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs a/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs new file mode 100644 -index 00000000..ea7c05ea +index 00000000..56fc89a4 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs @@ -0,0 +1,145 @@ @@ -1182,7 +1329,7 @@ index 00000000..ea7c05ea + ::dafny_runtime::md!(client.dafny_client.clone()).GetResources(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_resources::_get_resources_output::from_dafny( @@ -1514,6 +1661,259 @@ index 00000000..56453a6b + self.inner.get_value() + } +} +diff --git b/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs a/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git b/TestModels/Resource/runtimes/rust/src/types.rs a/TestModels/Resource/runtimes/rust/src/types.rs new file mode 100644 index 00000000..3ce75ec7 diff --git a/TestModels/Resource/runtimes/rust/Cargo.toml b/TestModels/Resource/runtimes/rust/Cargo.toml index d068dbc19..ebff554f1 100644 --- a/TestModels/Resource/runtimes/rust/Cargo.toml +++ b/TestModels/Resource/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/Resource/runtimes/rust/src/client.rs b/TestModels/Resource/runtimes/rust/src/client.rs index ce55ba698..593b1051d 100644 --- a/TestModels/Resource/runtimes/rust/src/client.rs +++ b/TestModels/Resource/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,14 +14,14 @@ impl Client { conf: crate::types::simple_resources_config::SimpleResourcesConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dresources_dinternaldafny::_default::SimpleResources( + crate::simple::resources::internaldafny::_default::SimpleResources( &crate::conversions::simple_resources_config::_simple_resources_config::to_dafny( conf, ), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs index f329aa4b5..ec6cd5b2f 100644 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs +++ b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_resource_data::GetResourceDataError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_resource_data::GetResourceDataError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::resources::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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error, + crate::r#simple::resources::internaldafny::types::Error, >, ) -> crate::operation::get_resource_data::GetResourceDataError { // 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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::resources::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_resource_data::GetResourceDataError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { 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 index 5c0d40ef4..3c8f9f69e 100644 --- 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 @@ -3,25 +3,25 @@ pub fn to_dafny( value: crate::operation::get_resource_data::GetResourceDataInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, + crate::r#simple::resources::internaldafny::types::GetResourceDataInput, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput::GetResourceDataInput { - stringValue: dafny_standard_library::conversion::ostring_to_dafny(value.string_value()), - booleanValue: dafny_standard_library::conversion::obool_to_dafny(value.boolean_value()), - integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value()), - longValue: dafny_standard_library::conversion::olong_to_dafny(value.long_value()), - blobValue: dafny_standard_library::conversion::oblob_to_dafny(value.blob_value()) + ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourceDataInput::GetResourceDataInput { + stringValue: crate::standard_library_conversions::ostring_to_dafny(value.string_value()), + booleanValue: crate::standard_library_conversions::obool_to_dafny(value.boolean_value()), + integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value()), + longValue: crate::standard_library_conversions::olong_to_dafny(value.long_value()), + blobValue: crate::standard_library_conversions::oblob_to_dafny(value.blob_value()) }) } // _get_resource_data_Input #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, + crate::r#simple::resources::internaldafny::types::GetResourceDataInput, >, ) -> crate::operation::get_resource_data::GetResourceDataInput { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput::GetResourceDataInput { + crate::r#simple::resources::internaldafny::types::GetResourceDataInput::GetResourceDataInput { blobValue, booleanValue, integerValue, @@ -29,11 +29,11 @@ pub fn from_dafny( stringValue, } => crate::operation::get_resource_data::GetResourceDataInput { - string_value: dafny_standard_library::conversion::ostring_from_dafny(stringValue.clone()), - boolean_value: dafny_standard_library::conversion::obool_from_dafny(booleanValue.clone()), - integer_value: dafny_standard_library::conversion::oint_from_dafny(integerValue.clone()), - long_value: dafny_standard_library::conversion::olong_from_dafny(longValue.clone()), - blob_value: dafny_standard_library::conversion::oblob_from_dafny(blobValue.clone()) + string_value: crate::standard_library_conversions::ostring_from_dafny(stringValue.clone()), + boolean_value: crate::standard_library_conversions::obool_from_dafny(booleanValue.clone()), + integer_value: crate::standard_library_conversions::oint_from_dafny(integerValue.clone()), + long_value: crate::standard_library_conversions::olong_from_dafny(longValue.clone()), + blob_value: crate::standard_library_conversions::oblob_from_dafny(blobValue.clone()) } } } 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 index 33ffc6993..514edbdb4 100644 --- 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 @@ -3,25 +3,25 @@ pub fn to_dafny( value: crate::operation::get_resource_data::GetResourceDataOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, + crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput::GetResourceDataOutput { - stringValue: dafny_standard_library::conversion::ostring_to_dafny(value.string_value()), - booleanValue: dafny_standard_library::conversion::obool_to_dafny(value.boolean_value()), - integerValue: dafny_standard_library::conversion::oint_to_dafny(value.integer_value()), - longValue: dafny_standard_library::conversion::olong_to_dafny(value.long_value()), - blobValue: dafny_standard_library::conversion::oblob_to_dafny(value.blob_value()) + ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourceDataOutput::GetResourceDataOutput { + stringValue: crate::standard_library_conversions::ostring_to_dafny(value.string_value()), + booleanValue: crate::standard_library_conversions::obool_to_dafny(value.boolean_value()), + integerValue: crate::standard_library_conversions::oint_to_dafny(value.integer_value()), + longValue: crate::standard_library_conversions::olong_to_dafny(value.long_value()), + blobValue: crate::standard_library_conversions::oblob_to_dafny(value.blob_value()) }) } // _get_resource_data_output #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, + crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, >, ) -> crate::operation::get_resource_data::GetResourceDataOutput { match &*dafny_value { - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput::GetResourceDataOutput { + crate::r#simple::resources::internaldafny::types::GetResourceDataOutput::GetResourceDataOutput { blobValue, booleanValue, integerValue, @@ -29,11 +29,11 @@ pub fn from_dafny( stringValue, } => crate::operation::get_resource_data::GetResourceDataOutput { - string_value: dafny_standard_library::conversion::ostring_from_dafny(stringValue.clone()), - boolean_value: dafny_standard_library::conversion::obool_from_dafny(booleanValue.clone()), - integer_value: dafny_standard_library::conversion::oint_from_dafny(integerValue.clone()), - long_value: dafny_standard_library::conversion::olong_from_dafny(longValue.clone()), - blob_value: dafny_standard_library::conversion::oblob_from_dafny(blobValue.clone()) + string_value: crate::standard_library_conversions::ostring_from_dafny(stringValue.clone()), + boolean_value: crate::standard_library_conversions::obool_from_dafny(booleanValue.clone()), + integer_value: crate::standard_library_conversions::oint_from_dafny(integerValue.clone()), + long_value: crate::standard_library_conversions::olong_from_dafny(longValue.clone()), + blob_value: crate::standard_library_conversions::oblob_from_dafny(blobValue.clone()) } } } diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs index eb244cbdb..1cffc46a9 100644 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs +++ b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_resources::GetResourcesError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_resources::GetResourcesError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::resources::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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error, + crate::r#simple::resources::internaldafny::types::Error, >, ) -> crate::operation::get_resources::GetResourcesError { // 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::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::resources::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_resources::GetResourcesError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { 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 index 544cb9f8b..95e17091e 100644 --- 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 @@ -3,15 +3,15 @@ pub fn to_dafny( value: crate::operation::get_resources::GetResourcesInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, + crate::r#simple::resources::internaldafny::types::GetResourcesInput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: + Some(b) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&b) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput::GetResourcesInput { + ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourcesInput::GetResourcesInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,12 +19,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, + crate::r#simple::resources::internaldafny::types::GetResourcesInput, >, ) -> crate::operation::get_resources::GetResourcesInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -33,7 +33,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { 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 index 116514952..294b93b5c 100644 --- 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 @@ -4,15 +4,15 @@ use crate::types::simple_resource::SimpleResource; pub fn to_dafny( value: crate::operation::get_resources::GetResourcesOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, + crate::r#simple::resources::internaldafny::types::GetResourcesOutput, > { let wrap = SimpleResourceWrapper { obj: value.output.clone(), }; - let inner : ::std::rc::Rc<::std::cell::UnsafeCell> + let inner : ::std::rc::Rc<::std::cell::UnsafeCell> = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput::GetResourcesOutput { + ::std::rc::Rc::new(crate::r#simple::resources::internaldafny::types::GetResourcesOutput::GetResourcesOutput { output: ::dafny_runtime::Object (Some(inner) ) }) } @@ -20,7 +20,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, + crate::r#simple::resources::internaldafny::types::GetResourcesOutput, >, ) -> crate::operation::get_resources::GetResourcesOutput { let wrap = SimpleResourceDafnyWrapper { @@ -39,20 +39,20 @@ impl ::dafny_runtime::UpcastObject for SimpleResourceWrappe ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); } -impl crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource +impl crate::r#simple::resources::internaldafny::types::ISimpleResource for SimpleResourceWrapper { fn r#_GetResourceData_k( &mut self, input: &::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, + crate::r#simple::resources::internaldafny::types::GetResourceDataInput, >, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_Wrappers_Compile::Result< + crate::r#_Wrappers_Compile::Result< ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, + crate::r#simple::resources::internaldafny::types::GetResourceDataOutput, >, - ::std::rc::Rc, + ::std::rc::Rc, >, > { @@ -62,12 +62,12 @@ impl crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtype ); let inner_result = self.obj.borrow_mut().get_resource_data(inner_input); let result = match inner_result { - Ok(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { + Ok(x) => crate::r#_Wrappers_Compile::Result::Success { value: crate::conversions::get_resource_data::_get_resource_data_output::to_dafny( x, ), }, - Err(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Failure { + Err(x) => crate::r#_Wrappers_Compile::Result::Failure { error: crate::conversions::get_resource_data::to_dafny_error(x), }, }; @@ -78,7 +78,7 @@ impl crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtype #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)] pub struct SimpleResourceDafnyWrapper { pub(crate) obj: ::dafny_runtime::Object< - dyn crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, + dyn crate::r#simple::resources::internaldafny::types::ISimpleResource, >, } @@ -95,7 +95,7 @@ impl SimpleResource for SimpleResourceDafnyWrapper { let inner_result = ::dafny_runtime::md!(self.obj.clone()).GetResourceData(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_resource_data::_get_resource_data_output::from_dafny( 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 index 2d0c94388..33886d220 100644 --- 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 @@ -4,9 +4,9 @@ pub fn to_dafny( value: crate::types::simple_resources_config::SimpleResourcesConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, + crate::simple::resources::internaldafny::types::SimpleResourcesConfig, > { - let inner = crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig::SimpleResourcesConfig { + let inner = crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig::SimpleResourcesConfig { name : dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&value.name) }; ::std::rc::Rc::new(inner) @@ -15,7 +15,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, + crate::r#simple::resources::internaldafny::types::SimpleResourcesConfig, >, ) -> crate::types::simple_resources_config::SimpleResourcesConfig { crate::types::simple_resources_config::SimpleResourcesConfig { diff --git a/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..d698ebfd5 --- /dev/null +++ b/TestModels/Resource/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2677 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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; +mod standard_library_conversions; + +pub use client::Client; +pub use types::simple_resources_config::SimpleResourcesConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod resources { + pub mod internaldafny { + pub use crate::simple::resources::internaldafny::types::ISimpleResourcesClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleResourcesConfig() -> ::std::rc::Rc< + crate::simple::resources::internaldafny::types::SimpleResourcesConfig, + > { + ::std::rc::Rc::new(crate::simple::resources::internaldafny::types::SimpleResourcesConfig::SimpleResourcesConfig { + name: ::dafny_runtime::string_utf16_of("default") + }) + } + pub fn SimpleResources( + config: &::std::rc::Rc< + crate::simple::resources::internaldafny::types::SimpleResourcesConfig, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::resources::internaldafny::SimpleResourcesClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::resources::internaldafny::SimpleResourcesClient, + >, + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::Error, + >, + >, + >, + >::new(); + let mut internalConfig: ::std::rc::Rc< + crate::r#simpleResourcesOperations_Compile::Config, + > = ::std::rc::Rc::new( + crate::r#simpleResourcesOperations_Compile::Config::Config { + name: config.name().clone(), + }, + ); + if crate::r#simpleResourcesOperations_Compile::_default::r#_ValidInternalConfig_q(&internalConfig) { + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut _nw2: ::dafny_runtime::Object = crate::simple::resources::internaldafny::SimpleResourcesClient::_allocate_object(); + crate::simple::resources::internaldafny::SimpleResourcesClient::_ctor(&_nw2, &internalConfig); + client = ::dafny_runtime::MaybePlacebo::from(_nw2.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } else { + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: ::std::rc::Rc::new(crate::simple::resources::internaldafny::types::Error::SimpleResourcesException { + message: ::dafny_runtime::string_utf16_of("Length of name must be greater than 0") + }) + })); + return res.read(); + }; + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleResourcesClient { + pub r#__i_config: + ::std::rc::Rc, + } + + impl SimpleResourcesClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::resources::internaldafny::SimpleResourcesClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::resources::internaldafny::SimpleResourcesClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleResourcesClient for crate::simple::resources::internaldafny::SimpleResourcesClient { + fn GetResources( + &mut self, + input: &::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#simpleResourcesOperations_Compile::_default::GetResources( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::resources::internaldafny::SimpleResourcesClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::resources::internaldafny::types::ISimpleResourcesClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.resources.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetResourceDataInput { + GetResourceDataInput { + blobValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + booleanValue: ::std::rc::Rc>, + stringValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + integerValue: ::std::rc::Rc>, + longValue: ::std::rc::Rc>, + }, + } + + impl GetResourceDataInput { + pub fn blobValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => blobValue, + } + } + pub fn booleanValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => booleanValue, + } + } + pub fn stringValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => stringValue, + } + } + pub fn integerValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => integerValue, + } + } + pub fn longValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => longValue, + } + } + } + + impl Debug for GetResourceDataInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetResourceDataInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + write!(_formatter, "simple.resources.internaldafny.types.GetResourceDataInput.GetResourceDataInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + blobValue, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + booleanValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + stringValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + integerValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + longValue, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetResourceDataInput {} + + impl Hash for GetResourceDataInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetResourceDataInput::GetResourceDataInput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + ::std::hash::Hash::hash(blobValue, _state); + ::std::hash::Hash::hash(booleanValue, _state); + ::std::hash::Hash::hash(stringValue, _state); + ::std::hash::Hash::hash(integerValue, _state); + ::std::hash::Hash::hash(longValue, _state) + } + } + } + } + + impl Default for GetResourceDataInput { + fn default() -> GetResourceDataInput { + GetResourceDataInput::GetResourceDataInput { + blobValue: ::std::default::Default::default(), + booleanValue: ::std::default::Default::default(), + stringValue: ::std::default::Default::default(), + integerValue: ::std::default::Default::default(), + longValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetResourceDataInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetResourceDataOutput { + GetResourceDataOutput { + blobValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + booleanValue: ::std::rc::Rc>, + stringValue: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + integerValue: ::std::rc::Rc>, + longValue: ::std::rc::Rc>, + }, + } + + impl GetResourceDataOutput { + pub fn blobValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => blobValue, + } + } + pub fn booleanValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => booleanValue, + } + } + pub fn stringValue( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => stringValue, + } + } + pub fn integerValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => integerValue, + } + } + pub fn longValue( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => longValue, + } + } + } + + impl Debug for GetResourceDataOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetResourceDataOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + write!(_formatter, "simple.resources.internaldafny.types.GetResourceDataOutput.GetResourceDataOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + blobValue, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + booleanValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + stringValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + integerValue, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + longValue, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetResourceDataOutput {} + + impl Hash for GetResourceDataOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetResourceDataOutput::GetResourceDataOutput { + blobValue, + booleanValue, + stringValue, + integerValue, + longValue, + } => { + ::std::hash::Hash::hash(blobValue, _state); + ::std::hash::Hash::hash(booleanValue, _state); + ::std::hash::Hash::hash(stringValue, _state); + ::std::hash::Hash::hash(integerValue, _state); + ::std::hash::Hash::hash(longValue, _state) + } + } + } + } + + impl Default for GetResourceDataOutput { + fn default() -> GetResourceDataOutput { + GetResourceDataOutput::GetResourceDataOutput { + blobValue: ::std::default::Default::default(), + booleanValue: ::std::default::Default::default(), + stringValue: ::std::default::Default::default(), + integerValue: ::std::default::Default::default(), + longValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetResourceDataOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetResourcesInput { + GetResourcesInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetResourcesInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetResourcesInput::GetResourcesInput { value } => value, + } + } + } + + impl Debug for GetResourcesInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetResourcesInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetResourcesInput::GetResourcesInput { value } => { + write!(_formatter, "simple.resources.internaldafny.types.GetResourcesInput.GetResourcesInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetResourcesInput {} + + impl Hash for GetResourcesInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetResourcesInput::GetResourcesInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetResourcesInput { + fn default() -> GetResourcesInput { + GetResourcesInput::GetResourcesInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetResourcesInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetResourcesOutput { + GetResourcesOutput { + output: ::dafny_runtime::Object< + dyn crate::simple::resources::internaldafny::types::ISimpleResource, + >, + }, + } + + impl GetResourcesOutput { + pub fn output( + &self, + ) -> &::dafny_runtime::Object< + dyn crate::simple::resources::internaldafny::types::ISimpleResource, + > { + match self { + GetResourcesOutput::GetResourcesOutput { output } => output, + } + } + } + + impl Debug for GetResourcesOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetResourcesOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetResourcesOutput::GetResourcesOutput { output } => { + write!(_formatter, "simple.resources.internaldafny.types.GetResourcesOutput.GetResourcesOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetResourcesOutput {} + + impl Hash for GetResourcesOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetResourcesOutput::GetResourcesOutput { output } => { + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl Default for GetResourcesOutput { + fn default() -> GetResourcesOutput { + GetResourcesOutput::GetResourcesOutput { + output: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetResourcesOutput { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleResourceCallHistory {} + + impl ISimpleResourceCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::resources::internaldafny::types::ISimpleResourceCallHistory + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + pub trait ISimpleResource: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetResourceData(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from(crate::simple::resources::internaldafny::types::ISimpleResource::r#_GetResourceData_k(::dafny_runtime::md!(::dafny_runtime::Object::<_>::from_ref(self)), input)); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn r#_GetResourceData_k(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + pub struct ISimpleResourcesClientCallHistory {} + + impl ISimpleResourcesClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::resources::internaldafny::types::ISimpleResourcesClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleResourcesClient: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetResources( + &mut self, + input: &::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesOutput, + >, + ::std::rc::Rc, + >, + >; + } + + #[derive(PartialEq, Clone)] + pub enum SimpleResourcesConfig { + SimpleResourcesConfig { + name: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + } + + impl SimpleResourcesConfig { + pub fn name( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + SimpleResourcesConfig::SimpleResourcesConfig { name } => name, + } + } + } + + impl Debug for SimpleResourcesConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleResourcesConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleResourcesConfig::SimpleResourcesConfig { name } => { + write!(_formatter, "simple.resources.internaldafny.types.SimpleResourcesConfig.SimpleResourcesConfig(")?; + ::dafny_runtime::DafnyPrint::fmt_print(name, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleResourcesConfig {} + + impl Hash for SimpleResourcesConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleResourcesConfig::SimpleResourcesConfig { name } => { + ::std::hash::Hash::hash(name, _state) + } + } + } + } + + impl Default for SimpleResourcesConfig { + fn default() -> SimpleResourcesConfig { + SimpleResourcesConfig::SimpleResourcesConfig { + name: ::std::default::Default::default(), + } + } + } + + impl AsRef for &SimpleResourcesConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Error { + SimpleResourcesException { + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::SimpleResourcesException { message } => message, + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::SimpleResourcesException { message } => { + panic!("field does not exist on this variant") + } + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::SimpleResourcesException { message } => { + panic!("field does not exist on this variant") + } + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::SimpleResourcesException { message } => { + write!(_formatter, "simple.resources.internaldafny.types.Error.SimpleResourcesException(")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.resources.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.resources.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::SimpleResourcesException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::SimpleResourcesException { + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } +} +pub mod r#simpleResource_Compile { + pub use crate::simple::resources::internaldafny::types::ISimpleResource; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct SimpleResource { + pub r#__i_value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + pub r#__i_name: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + } + + impl SimpleResource { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object, + value: &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + name: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> () { + let mut _set__i_value: bool = false; + let mut _set__i_name: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_value, + _set__i_value, + value.clone() + ); + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_name, + _set__i_name, + name.clone() + ); + return (); + } + pub fn value( + &self, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + self.r#__i_value.clone() + } + pub fn name(&self) -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + self.r#__i_name.clone() + } + } + + impl UpcastObject for SimpleResource { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleResource for SimpleResource { + fn r#_GetResourceData_k( + &mut self, + input: &::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourceDataInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourceDataOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourceDataOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut rtnString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = if matches!( + input.stringValue().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + self.name() + .clone() + .concat(&::dafny_runtime::string_utf16_of(" ")) + .concat(input.stringValue().value()) + } else { + self.name().clone() + }; + let mut rtn: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::resources::internaldafny::types::GetResourceDataOutput::GetResourceDataOutput { + blobValue: input.blobValue().clone(), + booleanValue: input.booleanValue().clone(), + stringValue: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: rtnString.clone() + }), + integerValue: input.integerValue().clone(), + longValue: input.longValue().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourceDataOutput, + >, + ::std::rc::Rc, + >::Success { + value: rtn.clone(), + }, + )); + return output.read(); + } + } + + impl UpcastObject for SimpleResource { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::resources::internaldafny::types::ISimpleResource); + } +} +pub mod r#simpleResourcesOperations_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn r#_ValidInternalConfig_q( + config: &::std::rc::Rc, + ) -> bool { + true && ::dafny_runtime::int!(0) < config.name().cardinality() + } + pub fn GetResources( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut resource = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object, + >::new(); + let mut _nw1: ::dafny_runtime::Object< + crate::r#simpleResource_Compile::SimpleResource, + > = crate::r#simpleResource_Compile::SimpleResource::_allocate_object(); + crate::r#simpleResource_Compile::SimpleResource::_ctor( + &_nw1, + input.value(), + config.name(), + ); + resource = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + let mut result: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::resources::internaldafny::types::GetResourcesOutput::GetResourcesOutput { + output: ::dafny_runtime::upcast_object::()(resource.read()) + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::resources::internaldafny::types::GetResourcesOutput, + >, + ::std::rc::Rc, + >::Success { + value: result.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config { + name: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + } + + impl Config { + pub fn name(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Config::Config { name } => name, + } + } + } + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config { name } => { + write!( + _formatter, + "SimpleResourcesOperations_Compile.Config.Config(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(name, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config { name } => ::std::hash::Hash::hash(name, _state), + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config { + name: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs b/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs index ea7c05ea9..56fc89a46 100644 --- a/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs +++ b/TestModels/Resource/runtimes/rust/src/operation/get_resources.rs @@ -20,7 +20,7 @@ impl GetResources { ::dafny_runtime::md!(client.dafny_client.clone()).GetResources(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_resources::_get_resources_output::from_dafny( diff --git a/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs b/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/Resource/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/Resource/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/Resource/runtimes/rust/tests/tests_from_dafny/mod.rs deleted file mode 100644 index cb6c8117b..000000000 --- a/TestModels/Resource/runtimes/rust/tests/tests_from_dafny/mod.rs +++ /dev/null @@ -1,481 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] - -pub mod r#_Helpers_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn allNone( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput::GetResourceDataInput { - blobValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::None {}), - booleanValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::None {}), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}), - longValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - }) - } - pub fn checkMostNone( - name: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - output: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ) -> () { - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Some { - value: name.clone(), - }) == output.stringValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence, - >::None {}) - == output.blobValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - == output.booleanValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - == output.integerValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - == output.longValue().clone()) - { - panic!("Halt") - }; - return (); - } - pub fn allSome( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput::GetResourceDataInput { - blobValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence>::Some { - value: ::dafny_runtime::seq![1] - }), - booleanValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: true - }), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("Some") - }), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 1 - }), - longValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 1 - }) - }) - } - pub fn checkSome( - name: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - output: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ) -> () { - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Some { - value: name.concat(&::dafny_runtime::string_utf16_of(" Some")), - }) == output.stringValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence, - >::Some { - value: ::dafny_runtime::seq![1], - }) == output.blobValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: true, - }) == output.booleanValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: 1 }) - == output.integerValue().clone()) - { - panic!("Halt") - }; - if !(::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: 1 }) - == output.longValue().clone()) - { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::r#_Helpers_Compile::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_SimpleResourcesTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn TestNoneGetData( - config: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, - >, - resource: &::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - ) -> () { - let mut input: ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, - > = super::r#_Helpers_Compile::_default::allNone(); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource::GetResourceData( - ::dafny_runtime::md!(resource.clone()), - &input, - ), - ); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut result: ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - > = valueOrError0.read().Extract(); - super::r#_Helpers_Compile::_default::checkMostNone(config.name(), &result); - return (); - } - pub fn TestSomeGetData( - config: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, - >, - resource: &::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - ) -> () { - let mut input: ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, - > = super::r#_Helpers_Compile::_default::allSome(); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource::GetResourceData( - ::dafny_runtime::md!(resource.clone()), - &input, - ), - ); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut output: ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - > = valueOrError0.read().Extract(); - super::r#_Helpers_Compile::_default::checkSome(config.name(), &output); - return (); - } - pub fn TestGetResources( - config: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, - >, - client: &::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - >, - ) -> ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - > { - let mut resource = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - >::new(); - let mut input: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput::GetResourcesInput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("Test") - }) - }); - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient::GetResources(::dafny_runtime::md!(client.clone()), &input)); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut output: ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - > = valueOrError0.read().Extract(); - resource = ::dafny_runtime::MaybePlacebo::from(output.output().clone()); - return resource.read(); - } - pub fn TestClient( - config: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, - >, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from( - super::r#_simple_dresources_dinternaldafny::_default::SimpleResources(config), - ); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - > = valueOrError0.read().Extract(); - let mut resource = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - >::new(); - let mut _out4 = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - >::new(); - _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_SimpleResourcesTest_Compile::_default::TestGetResources(config, &::dafny_runtime::upcast_object::()(client.clone()))); - resource = ::dafny_runtime::MaybePlacebo::from(_out4.read()); - super::r#_SimpleResourcesTest_Compile::_default::TestNoneGetData( - config, - &resource.read(), - ); - super::r#_SimpleResourcesTest_Compile::_default::TestSomeGetData( - config, - &resource.read(), - ); - return (); - } - pub fn TestDefaultConfig() -> () { - super::r#_SimpleResourcesTest_Compile::_default::TestClient( - &super::r#_simple_dresources_dinternaldafny::_default::DefaultSimpleResourcesConfig( - ), - ); - return (); - } - pub fn TestCustomConfig() -> () { - super::r#_SimpleResourcesTest_Compile::_default::TestClient(&::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig::SimpleResourcesConfig { - name: ::dafny_runtime::string_utf16_of("Dafny") - })); - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_SimpleResourcesTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_simple_dresources_dinternaldafny_dwrapped { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn WrappedDefaultSimpleResourcesConfig( - ) -> ::std::rc::Rc - { - super::r#_simple_dresources_dinternaldafny::_default::DefaultSimpleResourcesConfig() - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dresources_dinternaldafny_dwrapped::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_WrappedTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn TestWrappedClient( - config: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, - >, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dresources_dinternaldafny_dwrapped::_default::WrappedSimpleResources(config)); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out5.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - > = valueOrError0.read().Extract(); - let mut resource = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - >::new(); - let mut _out6 = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - >::new(); - _out6 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleResourcesTest_Compile::_default::TestGetResources(config, &client), - ); - resource = ::dafny_runtime::MaybePlacebo::from(_out6.read()); - super::r#_SimpleResourcesTest_Compile::_default::TestNoneGetData( - config, - &resource.read(), - ); - super::r#_SimpleResourcesTest_Compile::_default::TestSomeGetData( - config, - &resource.read(), - ); - return (); - } - pub fn WrappedTestDefaultConfig() -> () { - super::r#_WrappedTest_Compile::_default::TestWrappedClient(&super::r#_simple_dresources_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleResourcesConfig()); - return (); - } - pub fn WrappedTestCustomConfig() -> () { - super::r#_WrappedTest_Compile::_default::TestWrappedClient(&::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig::SimpleResourcesConfig { - name: ::dafny_runtime::string_utf16_of("Dafny") - })); - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::r#_WrappedTest_Compile::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod _module { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _Test__Main_() -> () { - let mut success: bool = true; - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleResourcesTest.TestDefaultConfig: "# - )) - ); - super::r#_SimpleResourcesTest_Compile::_default::TestDefaultConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleResourcesTest.TestCustomConfig: "# - )) - ); - super::r#_SimpleResourcesTest_Compile::_default::TestCustomConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedTest.WrappedTestDefaultConfig: "# - )) - ); - super::r#_WrappedTest_Compile::_default::WrappedTestDefaultConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedTest.WrappedTestCustomConfig: "# - )) - ); - super::r#_WrappedTest_Compile::_default::WrappedTestCustomConfig(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - if !success { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::_module::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -fn main() { - _module::_default::_Test__Main_(); -} diff --git a/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch index cdeca741e..fef50d1f5 100644 --- a/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..93d1e50b +index 00000000..0e7fbefe --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs @@ -0,0 +1,38 @@ @@ -10,7 +10,7 @@ index 00000000..93d1e50b + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -19,12 +19,12 @@ index 00000000..93d1e50b + pub fn from_conf( + conf: crate::types::simple_blob_config::SimpleBlobConfig, + ) -> Result { -+ let inner = crate::implementation_from_dafny::_simple_dtypes_dblob_dinternaldafny::_default::SimpleBlob( ++ let inner = crate::simple::types::blob::internaldafny::_default::SimpleBlob( + &crate::conversions::simple_blob_config::_simple_blob_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -98,7 +98,7 @@ index 00000000..1cd4ad22 +pub mod simple_blob_config; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs new file mode 100644 -index 00000000..7c8aa91f +index 00000000..43479fd3 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs @@ -0,0 +1,37 @@ @@ -109,10 +109,10 @@ index 00000000..7c8aa91f +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_blob::GetBlobError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_blob::GetBlobError::Unhandled(unhandled) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::types::blob::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -124,11 +124,11 @@ index 00000000..7c8aa91f +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::blob::internaldafny::types::Error, + >, +) -> crate::operation::get_blob::GetBlobError { + // 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::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::blob::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_blob::GetBlobError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -141,7 +141,7 @@ index 00000000..7c8aa91f +pub mod _get_blob_output; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs new file mode 100644 -index 00000000..ce65274f +index 00000000..5c7d9c2b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs @@ -0,0 +1,42 @@ @@ -149,15 +149,15 @@ index 00000000..ce65274f +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_blob::GetBlobInput, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::dafny_runtime::Sequence::from_array(&v), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { ++ ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobInput::GetBlobInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -165,12 +165,12 @@ index 00000000..ce65274f +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, ++ crate::r#simple::types::blob::internaldafny::types::GetBlobInput, + >, +) -> crate::operation::get_blob::GetBlobInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + ::std::rc::Rc::try_unwrap(dafny_value.value().Extract().to_array()) @@ -178,7 +178,7 @@ index 00000000..ce65274f + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -189,7 +189,7 @@ index 00000000..ce65274f +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs new file mode 100644 -index 00000000..1dc91e40 +index 00000000..e9770da2 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs @@ -0,0 +1,43 @@ @@ -197,15 +197,15 @@ index 00000000..1dc91e40 +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_blob::GetBlobOutput, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&b, |e| *e), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobOutput::GetBlobOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -213,12 +213,12 @@ index 00000000..1dc91e40 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, ++ crate::r#simple::types::blob::internaldafny::types::GetBlobOutput, + >, +) -> crate::operation::get_blob::GetBlobOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( @@ -228,7 +228,7 @@ index 00000000..1dc91e40 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -238,7 +238,7 @@ index 00000000..1dc91e40 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs new file mode 100644 -index 00000000..fb107c56 +index 00000000..50a67357 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs @@ -0,0 +1,39 @@ @@ -249,11 +249,11 @@ index 00000000..fb107c56 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_blob_known_value::GetBlobKnownValueError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_blob_known_value::GetBlobKnownValueError::Unhandled(unhandled) => { + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::types::blob::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -266,11 +266,11 @@ index 00000000..fb107c56 +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::blob::internaldafny::types::Error, + >, +) -> crate::operation::get_blob_known_value::GetBlobKnownValueError { + // 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::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::blob::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_blob_known_value::GetBlobKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -283,7 +283,7 @@ index 00000000..fb107c56 +pub mod _get_blob_known_value_output; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs new file mode 100644 -index 00000000..22d94d79 +index 00000000..581adeb7 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs @@ -0,0 +1,41 @@ @@ -291,15 +291,15 @@ index 00000000..22d94d79 +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_blob_known_value::GetBlobKnownValueInput, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::dafny_runtime::Sequence::from_array(&v), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { ++ ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobInput::GetBlobInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -307,12 +307,12 @@ index 00000000..22d94d79 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, ++ crate::r#simple::types::blob::internaldafny::types::GetBlobInput, + >, +) -> crate::operation::get_blob_known_value::GetBlobKnownValueInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + ::std::rc::Rc::try_unwrap(dafny_value.value().Extract().to_array()) @@ -320,7 +320,7 @@ index 00000000..22d94d79 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -330,7 +330,7 @@ index 00000000..22d94d79 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs new file mode 100644 -index 00000000..b9de8844 +index 00000000..19cf6355 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs @@ -0,0 +1,43 @@ @@ -338,15 +338,15 @@ index 00000000..b9de8844 +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_blob_known_value::GetBlobKnownValueOutput, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&v, |e| *e), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobOutput::GetBlobOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -354,12 +354,12 @@ index 00000000..b9de8844 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, ++ crate::r#simple::types::blob::internaldafny::types::GetBlobOutput, + >, +) -> crate::operation::get_blob_known_value::GetBlobKnownValueOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( @@ -369,7 +369,7 @@ index 00000000..b9de8844 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -388,7 +388,7 @@ index 00000000..89599c3f +pub mod _simple_blob_config; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs new file mode 100644 -index 00000000..7081c632 +index 00000000..d0a4cd5c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs @@ -0,0 +1,18 @@ @@ -397,15 +397,15 @@ index 00000000..7081c632 + +pub fn to_dafny( + value: crate::types::simple_blob_config::SimpleBlobConfig, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig::SimpleBlobConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::SimpleBlobConfig::SimpleBlobConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig, ++ crate::r#simple::types::blob::internaldafny::types::SimpleBlobConfig, + >, +) -> crate::types::simple_blob_config::SimpleBlobConfig { + crate::types::simple_blob_config::SimpleBlobConfig {} @@ -462,6 +462,33 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs +index ef528d59..1c1963a2 100644 +--- b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,22 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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; ++mod standard_library_conversions; ++ ++pub use client::Client; ++pub use types::simple_blob_config::SimpleBlobConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..3938142e @@ -502,7 +529,7 @@ index 00000000..a72267ed +pub mod get_blob_known_value; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs new file mode 100644 -index 00000000..fb2a00c2 +index 00000000..2c923f1a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs @@ -0,0 +1,142 @@ @@ -527,7 +554,7 @@ index 00000000..fb2a00c2 + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetBlob(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok(crate::conversions::get_blob::_get_blob_output::from_dafny( + inner_result.value().clone(), @@ -872,7 +899,7 @@ index 00000000..bedb57b1 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs new file mode 100644 -index 00000000..3d74474a +index 00000000..ee1819d4 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs @@ -0,0 +1,145 @@ @@ -898,7 +925,7 @@ index 00000000..3d74474a + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetBlob(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_blob_known_value::_get_blob_known_value_output::from_dafny( @@ -1245,6 +1272,259 @@ index 00000000..274bb3f3 + self.inner.get_value() + } +} +diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/standard_library_conversions.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/types.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/types.rs new file mode 100644 index 00000000..1dca219a diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/Cargo.toml index 27d4c835e..7db289b45 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs index 93d1e50bf..0e7fbefea 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -13,12 +13,12 @@ impl Client { pub fn from_conf( conf: crate::types::simple_blob_config::SimpleBlobConfig, ) -> Result { - let inner = crate::implementation_from_dafny::_simple_dtypes_dblob_dinternaldafny::_default::SimpleBlob( + let inner = crate::simple::types::blob::internaldafny::_default::SimpleBlob( &crate::conversions::simple_blob_config::_simple_blob_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs index 7c8aa91f6..43479fd3c 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs @@ -5,10 +5,10 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_blob::GetBlobError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_blob::GetBlobError::Unhandled(unhandled) => ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::types::blob::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -20,11 +20,11 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, + crate::r#simple::types::blob::internaldafny::types::Error, >, ) -> crate::operation::get_blob::GetBlobError { // 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::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::blob::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_blob::GetBlobError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs index ce65274f7..5c7d9c2be 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs @@ -2,15 +2,15 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_blob::GetBlobInput, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::Sequence::from_array(&v), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { + ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobInput::GetBlobInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -18,12 +18,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, + crate::r#simple::types::blob::internaldafny::types::GetBlobInput, >, ) -> crate::operation::get_blob::GetBlobInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( ::std::rc::Rc::try_unwrap(dafny_value.value().Extract().to_array()) @@ -31,7 +31,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs index 1dc91e407..e9770da2c 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs @@ -2,15 +2,15 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_blob::GetBlobOutput, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&b, |e| *e), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobOutput::GetBlobOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -18,12 +18,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + crate::r#simple::types::blob::internaldafny::types::GetBlobOutput, >, ) -> crate::operation::get_blob::GetBlobOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( @@ -33,7 +33,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs index fb107c56e..50a67357d 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs @@ -5,11 +5,11 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_blob_known_value::GetBlobKnownValueError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_blob_known_value::GetBlobKnownValueError::Unhandled(unhandled) => { ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::types::blob::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -22,11 +22,11 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, + crate::r#simple::types::blob::internaldafny::types::Error, >, ) -> crate::operation::get_blob_known_value::GetBlobKnownValueError { // 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::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::blob::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_blob_known_value::GetBlobKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs index 22d94d79b..581adeb75 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs @@ -2,15 +2,15 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_blob_known_value::GetBlobKnownValueInput, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::Sequence::from_array(&v), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { + ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobInput::GetBlobInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -18,12 +18,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, + crate::r#simple::types::blob::internaldafny::types::GetBlobInput, >, ) -> crate::operation::get_blob_known_value::GetBlobKnownValueInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( ::std::rc::Rc::try_unwrap(dafny_value.value().Extract().to_array()) @@ -31,7 +31,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs index b9de88447..19cf63550 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs @@ -2,15 +2,15 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_blob_known_value::GetBlobKnownValueOutput, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&v, |e| *e), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::GetBlobOutput::GetBlobOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -18,12 +18,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + crate::r#simple::types::blob::internaldafny::types::GetBlobOutput, >, ) -> crate::operation::get_blob_known_value::GetBlobKnownValueOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( @@ -33,7 +33,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs index 7081c6326..d0a4cd5c4 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/simple_blob_config/_simple_blob_config.rs @@ -3,15 +3,15 @@ pub fn to_dafny( value: crate::types::simple_blob_config::SimpleBlobConfig, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig::SimpleBlobConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::blob::internaldafny::types::SimpleBlobConfig::SimpleBlobConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig, + crate::r#simple::types::blob::internaldafny::types::SimpleBlobConfig, >, ) -> crate::types::simple_blob_config::SimpleBlobConfig { crate::types::simple_blob_config::SimpleBlobConfig {} diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..1c1963a20 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2278 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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; +mod standard_library_conversions; + +pub use client::Client; +pub use types::simple_blob_config::SimpleBlobConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod blob { + pub mod internaldafny { + pub use crate::simple::types::blob::internaldafny::types::ISimpleTypesBlobClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleBlobConfig() -> ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::SimpleBlobConfig, + > { + ::std::rc::Rc::new(crate::simple::types::blob::internaldafny::types::SimpleBlobConfig::SimpleBlobConfig {}) + } + pub fn SimpleBlob( + config: &::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::SimpleBlobConfig, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::blob::internaldafny::SimpleBlobClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::blob::internaldafny::SimpleBlobClient, + >, + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::Error, + >, + >, + >, + >::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::types::blob::internaldafny::SimpleBlobClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::blob::internaldafny::SimpleBlobClient::_allocate_object(); + crate::simple::types::blob::internaldafny::SimpleBlobClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleBlobImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + crate::simple::types::blob::internaldafny::SimpleBlobClient, + >, + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::Error, + >, + >::Success { + value: client.read(), + }, + )); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleBlobClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleBlobClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::blob::internaldafny::SimpleBlobClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::types::blob::internaldafny::SimpleBlobClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesBlobClient for crate::simple::types::blob::internaldafny::SimpleBlobClient { + fn GetBlob( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleBlobImpl_Compile::_default::GetBlob( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetBlobKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleBlobImpl_Compile::_default::GetBlobKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::blob::internaldafny::SimpleBlobClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::blob::internaldafny::types::ISimpleTypesBlobClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.blob.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetBlobInput { + GetBlobInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + }, + } + + impl GetBlobInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetBlobInput::GetBlobInput { value } => value, + } + } + } + + impl Debug for GetBlobInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetBlobInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBlobInput::GetBlobInput { value } => { + write!(_formatter, "simple.types.blob.internaldafny.types.GetBlobInput.GetBlobInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetBlobInput {} + + impl Hash for GetBlobInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBlobInput::GetBlobInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetBlobInput { + fn default() -> GetBlobInput { + GetBlobInput::GetBlobInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetBlobInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetBlobOutput { + GetBlobOutput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + }, + } + + impl GetBlobOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetBlobOutput::GetBlobOutput { value } => value, + } + } + } + + impl Debug for GetBlobOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetBlobOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBlobOutput::GetBlobOutput { value } => { + write!(_formatter, "simple.types.blob.internaldafny.types.GetBlobOutput.GetBlobOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetBlobOutput {} + + impl Hash for GetBlobOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBlobOutput::GetBlobOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetBlobOutput { + fn default() -> GetBlobOutput { + GetBlobOutput::GetBlobOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetBlobOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleBlobConfig { + SimpleBlobConfig {}, + } + + impl SimpleBlobConfig {} + + impl Debug for SimpleBlobConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleBlobConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleBlobConfig::SimpleBlobConfig {} => { + write!(_formatter, "simple.types.blob.internaldafny.types.SimpleBlobConfig.SimpleBlobConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleBlobConfig {} + + impl Hash for SimpleBlobConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleBlobConfig::SimpleBlobConfig {} => {} + } + } + } + + impl Default for SimpleBlobConfig { + fn default() -> SimpleBlobConfig { + SimpleBlobConfig::SimpleBlobConfig {} + } + } + + impl AsRef for &SimpleBlobConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesBlobClientCallHistory {} + + impl ISimpleTypesBlobClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::blob::internaldafny::types::ISimpleTypesBlobClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesBlobClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetBlob( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + >, + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::Error, + >, + >, + >; + fn GetBlobKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + >, + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::Error, + >, + >, + >; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.blob.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.blob.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } + } +} +pub mod r#_SimpleBlobImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetBlob( + config: &::std::rc::Rc, + input: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(input.value().value()); + let mut res: ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + > = ::std::rc::Rc::new( + crate::simple::types::blob::internaldafny::types::GetBlobOutput::GetBlobOutput { + value: input.value().clone(), + }, + ); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(res.value().value()); + let mut _e00: ::dafny_runtime::Sequence = res.value().value().clone(); + let mut _e10: ::dafny_runtime::Sequence = input.value().value().clone(); + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetBlobKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(input.value().value()); + let mut _e01: ::dafny_runtime::Sequence = input.value().value().clone(); + let mut _e11: ::dafny_runtime::Sequence = ::dafny_runtime::seq![0, 2, 4]; + if !(_e01.clone() == _e11.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc< + crate::simple::types::blob::internaldafny::types::GetBlobOutput, + > = ::std::rc::Rc::new( + crate::simple::types::blob::internaldafny::types::GetBlobOutput::GetBlobOutput { + value: input.value().clone(), + }, + ); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(res.value().value()); + let mut _e02: ::dafny_runtime::Sequence = res.value().value().clone(); + let mut _e12: ::dafny_runtime::Sequence = input.value().value().clone(); + if !(_e02.clone() == _e12.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn ValidateBlobType(input: &::dafny_runtime::Sequence) -> () { + if !(input.cardinality() >= ::dafny_runtime::int!(0)) { + panic!("Halt") + }; + let mut _hi1: ::dafny_runtime::DafnyInt = input.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi1.clone()) { + let mut inputElement: u8 = input.get(&i); + if !(inputElement >= 0) { + panic!("Halt") + } + } + return (); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleBlobImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs index fb2a00c2b..2c923f1aa 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs @@ -19,7 +19,7 @@ impl GetBlob { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetBlob(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok(crate::conversions::get_blob::_get_blob_output::from_dafny( inner_result.value().clone(), diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs index 3d74474ae..ee1819d4f 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs @@ -20,7 +20,7 @@ impl GetBlobKnownValue { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetBlob(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_blob_known_value::_get_blob_known_value_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/standard_library_conversions.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/Makefile b/TestModels/SimpleTypes/SimpleBoolean/Makefile index 7fe35f6fa..a0007469f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/Makefile +++ b/TestModels/SimpleTypes/SimpleBoolean/Makefile @@ -6,6 +6,8 @@ CORES=2 +TRANSPILE_TESTS_IN_RUST=1 + include ../../SharedMakefile.mk NAMESPACE=simple.types.boolean diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index e61513620..63c8138c7 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..7a4f6c04 +index 00000000..7c61a140 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -10,7 +10,7 @@ index 00000000..7a4f6c04 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..7a4f6c04 + conf: crate::types::simple_boolean_config::SimpleBooleanConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( ++ crate::simple::types::boolean::internaldafny::_default::SimpleBoolean( + &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -75,20 +75,20 @@ index 00000000..86f87891 \ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs new file mode 100644 -index 00000000..e48128a5 +index 00000000..6e7334d5 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs @@ -0,0 +1,30 @@ +/// Wraps up an arbitrary Rust Error value as a Dafny Error +pub fn to_opaque_error(value: E) -> -+ ::std::rc::Rc ++ ::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::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::types::boolean::internaldafny::types::Error::Opaque { + obj: error_obj, + }, + ) @@ -97,14 +97,14 @@ index 00000000..e48128a5 +/// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure +pub fn to_opaque_error_result(value: E) -> + ::std::rc::Rc< -+ dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result< ++ crate::_Wrappers_Compile::Result< + T, -+ ::std::rc::Rc ++ ::std::rc::Rc + > + > +{ + ::std::rc::Rc::new( -+ dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result::Failure { ++ crate::_Wrappers_Compile::Result::Failure { + error: to_opaque_error(value) + } + ) @@ -112,7 +112,7 @@ index 00000000..e48128a5 \ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..22f78d17 +index 00000000..55d5124b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,32 @@ @@ -123,21 +123,21 @@ index 00000000..22f78d17 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_boolean::GetBooleanError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::boolean::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::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::boolean::internaldafny::types::Error, + >, +) -> crate::operation::get_boolean::GetBooleanError { + // 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::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::boolean::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -150,7 +150,7 @@ index 00000000..22f78d17 +pub mod _get_boolean_output; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs new file mode 100644 -index 00000000..27e4ef74 +index 00000000..c00eb911 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -0,0 +1,37 @@ @@ -159,13 +159,13 @@ index 00000000..27e4ef74 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ ::std::rc::Rc::new(crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -173,17 +173,17 @@ index 00000000..27e4ef74 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput, + >, +) -> crate::operation::get_boolean::GetBooleanInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -193,7 +193,7 @@ index 00000000..27e4ef74 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs new file mode 100644 -index 00000000..719f9692 +index 00000000..4014e019 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -0,0 +1,37 @@ @@ -202,13 +202,13 @@ index 00000000..719f9692 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput::GetBooleanOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -216,17 +216,17 @@ index 00000000..719f9692 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, +) -> crate::operation::get_boolean::GetBooleanOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -245,7 +245,7 @@ index 00000000..371a47e5 +pub mod _simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs new file mode 100644 -index 00000000..94c39f03 +index 00000000..9c55fca9 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs @@ -0,0 +1,19 @@ @@ -255,15 +255,15 @@ index 00000000..94c39f03 +pub fn to_dafny( + value: crate::types::simple_boolean_config::SimpleBooleanConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::simple::types::boolean::internaldafny::types::SimpleBooleanConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig::SimpleBooleanConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig, + >, +) -> crate::types::simple_boolean_config::SimpleBooleanConfig { + crate::types::simple_boolean_config::SimpleBooleanConfig {} @@ -325,12 +325,146 @@ index 00000000..4d66eb2e + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} \ No newline at end of file +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs +index 0237283a..162bb766 100644 +--- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,23 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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; ++ ++#[cfg(feature = "wrapped-client")] ++pub mod wrapped; ++ ++pub use client::Client; ++pub use types::simple_boolean_config::SimpleBooleanConfig; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; +@@ -2035,6 +2052,52 @@ pub mod r#_SimpleBooleanImpl_Compile { + } + } + } ++pub mod r#_StandardLibraryInterop_Compile { ++ pub use dafny_runtime::UpcastObject; ++ pub use std::any::Any; ++ ++ pub struct WrappersInterop {} ++ ++ impl WrappersInterop { ++ pub fn _allocate_object() -> ::dafny_runtime::Object { ++ ::dafny_runtime::allocate_object::() ++ } ++ pub fn CreateStringSome( ++ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> ::std::rc::Rc< ++ crate::r#_Wrappers_Compile::Option< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Some { ++ value: s.clone(), ++ }) ++ } ++ pub fn CreateStringNone() -> ::std::rc::Rc< ++ crate::r#_Wrappers_Compile::Option< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::None {}) ++ } ++ pub fn CreateBooleanSome( ++ b: bool, ++ ) -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) ++ } ++ pub fn CreateBooleanNone() -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) ++ } ++ } ++ ++ impl UpcastObject for WrappersInterop { ++ ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); ++ } ++} + pub mod r#_SimpleBooleanImplTest_Compile { + pub struct _default {} + +@@ -2277,52 +2340,6 @@ pub mod r#_WrappedSimpleTypesBooleanTest_Compile { + _default::GetBooleanFalse() + } + } +-pub mod r#_StandardLibraryInterop_Compile { +- pub use dafny_runtime::UpcastObject; +- pub use std::any::Any; +- +- pub struct WrappersInterop {} +- +- impl WrappersInterop { +- pub fn _allocate_object() -> ::dafny_runtime::Object { +- ::dafny_runtime::allocate_object::() +- } +- pub fn CreateStringSome( +- s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, +- ) -> ::std::rc::Rc< +- crate::r#_Wrappers_Compile::Option< +- ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, +- >, +- > { +- ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< +- ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, +- >::Some { +- value: s.clone(), +- }) +- } +- pub fn CreateStringNone() -> ::std::rc::Rc< +- crate::r#_Wrappers_Compile::Option< +- ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, +- >, +- > { +- ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< +- ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, +- >::None {}) +- } +- pub fn CreateBooleanSome( +- b: bool, +- ) -> ::std::rc::Rc> { +- ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) +- } +- pub fn CreateBooleanNone() -> ::std::rc::Rc> { +- ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) +- } +- } +- +- impl UpcastObject for WrappersInterop { +- ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); +- } +-} + pub mod _module { + pub struct _default {} + diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..b8e65a55 +index 00000000..53977d7d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,20 @@ +#![allow(deprecated)] + +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. @@ -346,8 +480,6 @@ index 00000000..b8e65a55 + +mod conversions; + -+pub mod implementation_from_dafny; -+ +#[cfg(feature = "wrapped-client")] +pub mod wrapped; + @@ -365,7 +497,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..5b1fec21 +index 00000000..362a3cde --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -391,7 +523,7 @@ index 00000000..5b1fec21 + ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_boolean::_get_boolean_output::from_dafny( @@ -766,15 +898,25 @@ index 00000000..6bf027f6 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs new file mode 100644 -index 00000000..39355176 +index 00000000..10349e12 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs -@@ -0,0 +1 @@ +@@ -0,0 +1,12 @@ +pub mod client; -\ No newline at end of file ++ ++impl crate::r#simple::types::boolean::internaldafny::wrapped::_default { ++ pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< ++ crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig, ++ >) -> ::std::rc::Rc, ++ ::std::rc::Rc ++ >>{ ++ crate::wrapped::client::Client::from_conf(config) ++ } ++} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs new file mode 100644 -index 00000000..71509248 +index 00000000..3703ce67 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs @@ -0,0 +1,88 @@ @@ -788,8 +930,8 @@ index 00000000..71509248 + rt: Runtime +} + -+impl dafny_runtime::UpcastObject for Client { -+ ::dafny_runtime::UpcastObjectFn!(dyn crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient); ++impl dafny_runtime::UpcastObject for Client { ++ ::dafny_runtime::UpcastObjectFn!(dyn crate::r#simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient); +} + +impl dafny_runtime::UpcastObject for Client { @@ -798,11 +940,11 @@ index 00000000..71509248 + +impl Client { + pub fn from_conf(config: &::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig, + >) -> -+::std::rc::Rc, -+ ::std::rc::Rc ++::std::rc::Rc, ++ ::std::rc::Rc +>> { + let rt_result = tokio::runtime::Builder::new_current_thread() + .enable_all() @@ -823,7 +965,7 @@ index 00000000..71509248 + rt + }; + std::rc::Rc::new( -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { ++ crate::_Wrappers_Compile::Result::Success { + value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) + } + ) @@ -833,20 +975,20 @@ index 00000000..71509248 + } +} + -+impl crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient ++impl crate::r#simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient + for Client +{ + fn GetBoolean( + &mut self, + input: &std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput, + >, + ) -> std::rc::Rc< -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result< ++ crate::r#_Wrappers_Compile::Result< + std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, -+ std::rc::Rc, ++ std::rc::Rc, + >, + >{ + let inner_input = @@ -854,28 +996,15 @@ index 00000000..71509248 + let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); + match result { + Err(error) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { ++ crate::_Wrappers_Compile::Result::Failure { + error: crate::conversions::get_boolean::to_dafny_error(error), + }, + ), + Ok(client) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { ++ crate::_Wrappers_Compile::Result::Success { + value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), + }, + ), + } + } +} -diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -index ce6d90a2..3304d282 100644 ---- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -+++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -@@ -1,5 +1,8 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] -+use simple_boolean::implementation_from_dafny::*; -+use simple_boolean::*; -+mod _wrapped; - - pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { - pub struct _default {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml index 9ca423150..ecc00be43 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml @@ -13,11 +13,13 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies] simple_boolean = { path = ".", features = ["wrapped-client"] } [dependencies.tokio] version = "1.26.0" -features = ["full"] \ No newline at end of file +features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml deleted file mode 100644 index 31b603eef..000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "simple_boolean_dafny" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -dafny_runtime = { path = "../../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} - -[lib] -path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index 7a4f6c042..7c61a1402 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + crate::simple::types::boolean::internaldafny::_default::SimpleBoolean( &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs index e48128a5c..6e7334d53 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs @@ -1,13 +1,13 @@ /// Wraps up an arbitrary Rust Error value as a Dafny Error pub fn to_opaque_error(value: E) -> - ::std::rc::Rc + ::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::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::types::boolean::internaldafny::types::Error::Opaque { obj: error_obj, }, ) @@ -16,14 +16,14 @@ pub fn to_opaque_error(value: E) -> /// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure pub fn to_opaque_error_result(value: E) -> ::std::rc::Rc< - dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result< + crate::_Wrappers_Compile::Result< T, - ::std::rc::Rc + ::std::rc::Rc > > { ::std::rc::Rc::new( - dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + crate::_Wrappers_Compile::Result::Failure { error: to_opaque_error(value) } ) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index 22f78d17a..55d5124b9 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_boolean::GetBooleanError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::boolean::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::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + crate::r#simple::types::boolean::internaldafny::types::Error, >, ) -> crate::operation::get_boolean::GetBooleanError { // 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::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::boolean::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs index 27e4ef748..c00eb911f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + ::std::rc::Rc::new(crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput, >, ) -> crate::operation::get_boolean::GetBooleanInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs index 719f9692f..4014e0196 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + ::std::rc::Rc::new(crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput::GetBooleanOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput, >, ) -> crate::operation::get_boolean::GetBooleanOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs index 94c39f037..9c55fca9e 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + crate::simple::types::boolean::internaldafny::types::SimpleBooleanConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig::SimpleBooleanConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig, >, ) -> crate::types::simple_boolean_config::SimpleBooleanConfig { crate::types::simple_boolean_config::SimpleBooleanConfig {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..162bb766d --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2414 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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; + +#[cfg(feature = "wrapped-client")] +pub mod wrapped; + +pub use client::Client; +pub use types::simple_boolean_config::SimpleBooleanConfig; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod boolean { + pub mod internaldafny { + pub use crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleBooleanConfig() -> ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::SimpleBooleanConfig, + > { + ::std::rc::Rc::new(crate::simple::types::boolean::internaldafny::types::SimpleBooleanConfig::SimpleBooleanConfig {}) + } + pub fn SimpleBoolean( + config: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::Error, + >, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::boolean::internaldafny::SimpleBooleanClient::_allocate_object(); + crate::simple::types::boolean::internaldafny::SimpleBooleanClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleBooleanImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleBooleanClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleBooleanClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::types::boolean::internaldafny::SimpleBooleanClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesBooleanClient + for crate::simple::types::boolean::internaldafny::SimpleBooleanClient + { + fn GetBoolean(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleBooleanImpl_Compile::_default::GetBoolean( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::boolean::internaldafny::SimpleBooleanClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.boolean.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetBooleanInput { + GetBooleanInput { + value: ::std::rc::Rc>, + }, + } + + impl GetBooleanInput { + pub fn value( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetBooleanInput::GetBooleanInput { value } => value, + } + } + } + + impl Debug for GetBooleanInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetBooleanInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBooleanInput::GetBooleanInput { value } => { + write!(_formatter, "simple.types.boolean.internaldafny.types.GetBooleanInput.GetBooleanInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetBooleanInput {} + + impl Hash for GetBooleanInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBooleanInput::GetBooleanInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetBooleanInput { + fn default() -> GetBooleanInput { + GetBooleanInput::GetBooleanInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetBooleanInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetBooleanOutput { + GetBooleanOutput { + value: ::std::rc::Rc>, + }, + } + + impl GetBooleanOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetBooleanOutput::GetBooleanOutput { value } => value, + } + } + } + + impl Debug for GetBooleanOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetBooleanOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBooleanOutput::GetBooleanOutput { value } => { + write!(_formatter, "simple.types.boolean.internaldafny.types.GetBooleanOutput.GetBooleanOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetBooleanOutput {} + + impl Hash for GetBooleanOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBooleanOutput::GetBooleanOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetBooleanOutput { + fn default() -> GetBooleanOutput { + GetBooleanOutput::GetBooleanOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetBooleanOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleBooleanConfig { + SimpleBooleanConfig {}, + } + + impl SimpleBooleanConfig {} + + impl Debug for SimpleBooleanConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleBooleanConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleBooleanConfig::SimpleBooleanConfig {} => { + write!(_formatter, "simple.types.boolean.internaldafny.types.SimpleBooleanConfig.SimpleBooleanConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleBooleanConfig {} + + impl Hash for SimpleBooleanConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleBooleanConfig::SimpleBooleanConfig {} => {} + } + } + } + + impl Default for SimpleBooleanConfig { + fn default() -> SimpleBooleanConfig { + SimpleBooleanConfig::SimpleBooleanConfig {} + } + } + + impl AsRef for &SimpleBooleanConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesBooleanClientCallHistory {} + + impl ISimpleTypesBooleanClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesBooleanClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetBoolean(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.boolean.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.boolean.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + + pub mod wrapped { + pub struct _default {} + + impl _default { + pub fn WrappedDefaultSimpleBooleanConfig() -> ::std::rc::Rc{ + ::std::rc::Rc::new(crate::simple::types::boolean::internaldafny::types::SimpleBooleanConfig::SimpleBooleanConfig {}) + } + } + } + } + } + } +} +pub mod r#_SimpleBooleanImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetBoolean( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !(input.value().value().clone() == true || input.value().value().clone() == false) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::boolean::internaldafny::types::GetBooleanOutput::GetBooleanOutput { + value: input.value().clone() + }); + if !(res.value().value().clone() == true || res.value().value().clone() == false) { + panic!("Halt") + }; + let mut _e00: bool = input.value().value().clone(); + let mut _e10: bool = res.value().value().clone(); + if !(_e00 == _e10) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleBooleanImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod r#_SimpleBooleanImplTest_Compile { + pub struct _default {} + + impl _default { + pub fn GetBooleanTrue() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from(crate::simple::types::boolean::internaldafny::_default::SimpleBoolean(&crate::simple::types::boolean::internaldafny::_default::DefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + > = valueOrError0.read().Extract(); + crate::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::upcast_object::()(client.clone())); + return (); + } + pub fn GetBooleanFalse() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from(crate::simple::types::boolean::internaldafny::_default::SimpleBoolean(&crate::simple::types::boolean::internaldafny::_default::DefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object< + crate::simple::types::boolean::internaldafny::SimpleBooleanClient, + > = valueOrError0.read().Extract(); + crate::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::upcast_object::()(client.clone())); + return (); + } + pub fn TestGetBooleanTrue( + client: &::dafny_runtime::Object< + dyn crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient, + >, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out3 = ::dafny_runtime::MaybePlacebo::from(crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(crate::simple::types::boolean::internaldafny::types::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: true + }) + }))); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut ret: ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + > = valueOrError0.read().Extract(); + let mut _e01: bool = ret.value().UnwrapOr(&false); + let mut _e11: bool = true; + if !(_e01 == _e11) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); + return (); + } + pub fn TestGetBooleanFalse( + client: &::dafny_runtime::Object< + dyn crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient, + >, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out4 = ::dafny_runtime::MaybePlacebo::from(crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(crate::simple::types::boolean::internaldafny::types::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: false + }) + }))); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut ret: ::std::rc::Rc< + crate::simple::types::boolean::internaldafny::types::GetBooleanOutput, + > = valueOrError0.read().Extract(); + let mut _e02: bool = ret.value().UnwrapOr(&true); + let mut _e12: bool = false; + if !(_e02 == _e12) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); + return (); + } + } + + #[test] + pub fn GetBooleanTrue() { + _default::GetBooleanTrue() + } + + #[test] + pub fn GetBooleanFalse() { + _default::GetBooleanFalse() + } +} +pub mod r#_WrappedSimpleTypesBooleanTest_Compile { + pub struct _default {} + + impl _default { + pub fn GetBooleanTrue() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out5 = ::dafny_runtime::MaybePlacebo::from(crate::simple::types::boolean::internaldafny::wrapped::_default::WrappedSimpleBoolean(&crate::simple::types::boolean::internaldafny::wrapped::_default::WrappedDefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out5.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object< + dyn crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient, + > = valueOrError0.read().Extract(); + crate::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client); + return (); + } + pub fn GetBooleanFalse() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out6 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out6 = ::dafny_runtime::MaybePlacebo::from(crate::simple::types::boolean::internaldafny::wrapped::_default::WrappedSimpleBoolean(&crate::simple::types::boolean::internaldafny::wrapped::_default::WrappedDefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out6.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object< + dyn crate::simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient, + > = valueOrError0.read().Extract(); + crate::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client); + return (); + } + } + + #[test] + pub fn GetBooleanTrue() { + _default::GetBooleanTrue() + } + + #[test] + pub fn GetBooleanFalse() { + _default::GetBooleanFalse() + } +} +pub mod _module { + pub struct _default {} + + impl _default { + pub fn _Test__Main_() -> () { + let mut success: bool = true; + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"SimpleBooleanImplTest.GetBooleanTrue: "# + )) + ); + crate::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanTrue(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"SimpleBooleanImplTest.GetBooleanFalse: "# + )) + ); + crate::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanFalse(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"WrappedSimpleTypesBooleanTest.GetBooleanTrue: "# + )) + ); + crate::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanTrue(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"WrappedSimpleTypesBooleanTest.GetBooleanFalse: "# + )) + ); + crate::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanFalse(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + if !success { + panic!("Halt") + }; + return (); + } + } +} +fn main() { + _module::_default::_Test__Main_(); +} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs index b8e65a550..53977d7d6 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs @@ -13,8 +13,6 @@ pub mod operation; mod conversions; -pub mod implementation_from_dafny; - #[cfg(feature = "wrapped-client")] pub mod wrapped; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 5b1fec218..362a3cde1 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -20,7 +20,7 @@ impl GetBoolean { ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_boolean::_get_boolean_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs index 393551766..10349e123 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs @@ -1 +1,12 @@ -pub mod client; \ No newline at end of file +pub mod client; + +impl crate::r#simple::types::boolean::internaldafny::wrapped::_default { + pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< + crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig, + >) -> ::std::rc::Rc, + ::std::rc::Rc + >>{ + crate::wrapped::client::Client::from_conf(config) + } +} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs index 71509248e..3703ce670 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs @@ -8,8 +8,8 @@ pub struct Client { rt: Runtime } -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient); +impl dafny_runtime::UpcastObject for Client { + ::dafny_runtime::UpcastObjectFn!(dyn crate::r#simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient); } impl dafny_runtime::UpcastObject for Client { @@ -18,11 +18,11 @@ impl dafny_runtime::UpcastObject for Client { impl Client { pub fn from_conf(config: &::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + crate::r#simple::types::boolean::internaldafny::types::SimpleBooleanConfig, >) -> -::std::rc::Rc, - ::std::rc::Rc +::std::rc::Rc, + ::std::rc::Rc >> { let rt_result = tokio::runtime::Builder::new_current_thread() .enable_all() @@ -43,7 +43,7 @@ impl Client { rt }; std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + crate::_Wrappers_Compile::Result::Success { value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) } ) @@ -53,20 +53,20 @@ impl Client { } } -impl crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient +impl crate::r#simple::types::boolean::internaldafny::types::ISimpleTypesBooleanClient for Client { fn GetBoolean( &mut self, input: &std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + crate::r#simple::types::boolean::internaldafny::types::GetBooleanInput, >, ) -> std::rc::Rc< - crate::implementation_from_dafny::r#_Wrappers_Compile::Result< + crate::r#_Wrappers_Compile::Result< std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + crate::r#simple::types::boolean::internaldafny::types::GetBooleanOutput, >, - std::rc::Rc, + std::rc::Rc, >, >{ let inner_input = @@ -74,12 +74,12 @@ impl crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_ let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); match result { Err(error) => ::std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + crate::_Wrappers_Compile::Result::Failure { error: crate::conversions::get_boolean::to_dafny_error(error), }, ), Ok(client) => ::std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + crate::_Wrappers_Compile::Result::Success { value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), }, ), diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs index 9dc7b5d32..b0ca92b27 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs @@ -1,8 +1,5 @@ use simple_boolean::*; - -mod tests_from_dafny; - /* method{:test} GetBooleanTrue(){ var client :- expect SimpleBoolean.SimpleBoolean(); @@ -53,9 +50,4 @@ async fn test_get_boolean_false() { pub fn client() -> Client { let config = SimpleBooleanConfig::builder().build().unwrap(); Client::from_conf(config).unwrap() -} - -#[test] -fn dafny_tests() { - crate::tests_from_dafny::_module::_default::_Test__Main_() -} +} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs deleted file mode 100644 index 7c83b90fe..000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::tests_from_dafny::*; - -impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { - pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >) -> ::std::rc::Rc, - ::std::rc::Rc - >>{ - crate::wrapped::client::Client::from_conf(config) - } -} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs deleted file mode 100644 index 3304d282b..000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +++ /dev/null @@ -1,277 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -use simple_boolean::implementation_from_dafny::*; -use simple_boolean::*; -mod _wrapped; - -pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn WrappedDefaultSimpleBooleanConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_SimpleBooleanImplTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn GetBooleanTrue() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::upcast_object::()(client.clone())); - return (); - } - pub fn GetBooleanFalse() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::upcast_object::()(client.clone())); - return (); - } - pub fn TestGetBooleanTrue( - client: &::dafny_runtime::Object, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: true - }) - }))); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut ret: ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - > = valueOrError0.read().Extract(); - if !(ret.value().UnwrapOr(&false) == true) { - panic!("Halt") - }; - print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); - return (); - } - pub fn TestGetBooleanFalse( - client: &::dafny_runtime::Object, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: false - }) - }))); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut ret: ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - > = valueOrError0.read().Extract(); - if !(ret.value().UnwrapOr(&true) == false) { - panic!("Halt") - }; - print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_SimpleBooleanImplTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_WrappedSimpleTypesBooleanTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn GetBooleanTrue() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client); - return (); - } - pub fn GetBooleanFalse() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out5.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client); - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_WrappedSimpleTypesBooleanTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod _module { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _Test__Main_() -> () { - let mut success: bool = true; - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleBooleanImplTest.GetBooleanTrue: "# - )) - ); - super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanTrue(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleBooleanImplTest.GetBooleanFalse: "# - )) - ); - super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanFalse(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedSimpleTypesBooleanTest.GetBooleanTrue: "# - )) - ); - super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanTrue(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedSimpleTypesBooleanTest.GetBooleanFalse: "# - )) - ); - super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanFalse(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - if !success { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::_module::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -fn main() { - _module::_default::_Test__Main_(); -} diff --git a/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch index a450bba48..8c38d4a74 100644 --- a/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..7ea51cfb +index 00000000..58270834 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -10,7 +10,7 @@ index 00000000..7ea51cfb + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..7ea51cfb + conf: crate::types::simple_double_config::SimpleDoubleConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dsmithydouble_dinternaldafny::_default::SimpleDouble( ++ crate::simple::types::smithydouble::internaldafny::_default::SimpleDouble( + &crate::conversions::simple_double_config::_simple_double_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -72,7 +72,7 @@ index 00000000..08430ee3 +pub mod simple_double_config; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs new file mode 100644 -index 00000000..713fb19e +index 00000000..45f3afc1 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs @@ -0,0 +1,33 @@ @@ -83,22 +83,22 @@ index 00000000..713fb19e +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_double::GetDoubleError, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + match value { + crate::operation::get_double::GetDoubleError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithydouble::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::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithydouble::internaldafny::types::Error, + >, +) -> crate::operation::get_double::GetDoubleError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithydouble::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_double::GetDoubleError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -111,7 +111,7 @@ index 00000000..713fb19e +pub mod _get_double_output; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs new file mode 100644 -index 00000000..69b0e912 +index 00000000..1a6a82f8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs @@ -0,0 +1,47 @@ @@ -120,17 +120,17 @@ index 00000000..69b0e912 +pub fn to_dafny( + value: crate::operation::get_double::GetDoubleInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, ++ crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::dafny_runtime::Sequence::ArraySequence { + values: std::rc::Rc::new(f64::to_be_bytes(v).to_vec()), + }, + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput::GetDoubleInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleInput::GetDoubleInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -138,12 +138,12 @@ index 00000000..69b0e912 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, ++ crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleInput, + >, +) -> crate::operation::get_double::GetDoubleInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + let my_vec = dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( + &dafny_value.value().Extract(), @@ -154,7 +154,7 @@ index 00000000..69b0e912 + )) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -164,7 +164,7 @@ index 00000000..69b0e912 +} diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs new file mode 100644 -index 00000000..0dbe2a35 +index 00000000..5dcd0eb4 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs @@ -0,0 +1,47 @@ @@ -173,17 +173,17 @@ index 00000000..0dbe2a35 +pub fn to_dafny( + value: crate::operation::get_double::GetDoubleOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, ++ crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleOutput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::dafny_runtime::Sequence::ArraySequence { + values: std::rc::Rc::new(f64::to_be_bytes(v).to_vec()), + }, + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput::GetDoubleOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleOutput::GetDoubleOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -191,12 +191,12 @@ index 00000000..0dbe2a35 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, ++ crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleOutput, + >, +) -> crate::operation::get_double::GetDoubleOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + let my_vec = dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( + &dafny_value.value().Extract(), @@ -207,7 +207,7 @@ index 00000000..0dbe2a35 + )) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -226,7 +226,7 @@ index 00000000..52a68a7b +pub mod _simple_double_config; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs new file mode 100644 -index 00000000..9f14ccbb +index 00000000..f726f08b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs @@ -0,0 +1,19 @@ @@ -236,15 +236,15 @@ index 00000000..9f14ccbb +pub fn to_dafny( + value: crate::types::simple_double_config::SimpleDoubleConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig, ++ crate::simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig::SimpleDoubleConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig::SimpleDoubleConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig, ++ crate::r#simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig, + >, +) -> crate::types::simple_double_config::SimpleDoubleConfig { + crate::types::simple_double_config::SimpleDoubleConfig {} @@ -301,6 +301,33 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs +index f09879fc..e2aff694 100644 +--- b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,22 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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; ++mod standard_library_conversions; ++ ++pub use client::Client; ++pub use types::simple_double_config::SimpleDoubleConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..94379fc0 @@ -338,7 +365,7 @@ index 00000000..134175f8 +pub mod get_double; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs new file mode 100644 -index 00000000..d3b6744b +index 00000000..8b6d980d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs @@ -0,0 +1,145 @@ @@ -364,7 +391,7 @@ index 00000000..d3b6744b + ::dafny_runtime::md!(client.dafny_client.clone()).GetDouble(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_double::_get_double_output::from_dafny( @@ -695,6 +722,259 @@ index 00000000..ed9fd9a4 + self.inner.get_value() + } +} +diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/standard_library_conversions.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/types.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/types.rs new file mode 100644 index 00000000..92447294 diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/Cargo.toml index 13650ba47..3bb72ebe2 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs index 7ea51cfbb..582708346 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_double_config::SimpleDoubleConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dsmithydouble_dinternaldafny::_default::SimpleDouble( + crate::simple::types::smithydouble::internaldafny::_default::SimpleDouble( &crate::conversions::simple_double_config::_simple_double_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs index 713fb19eb..45f3afc17 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs @@ -5,22 +5,22 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_double::GetDoubleError, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { match value { crate::operation::get_double::GetDoubleError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithydouble::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::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithydouble::internaldafny::types::Error, >, ) -> crate::operation::get_double::GetDoubleError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithydouble::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_double::GetDoubleError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs index 69b0e9123..1a6a82f8e 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_double::GetDoubleInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, + crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::Sequence::ArraySequence { values: std::rc::Rc::new(f64::to_be_bytes(v).to_vec()), }, }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput::GetDoubleInput { + ::std::rc::Rc::new(crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleInput::GetDoubleInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, + crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleInput, >, ) -> crate::operation::get_double::GetDoubleInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { let my_vec = dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( &dafny_value.value().Extract(), @@ -37,7 +37,7 @@ pub fn from_dafny( )) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs index 0dbe2a350..5dcd0eb48 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double/_get_double_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_double::GetDoubleOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, + crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleOutput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::Sequence::ArraySequence { values: std::rc::Rc::new(f64::to_be_bytes(v).to_vec()), }, }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput::GetDoubleOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleOutput::GetDoubleOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, + crate::r#simple::types::smithydouble::internaldafny::types::GetDoubleOutput, >, ) -> crate::operation::get_double::GetDoubleOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { let my_vec = dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec( &dafny_value.value().Extract(), @@ -37,7 +37,7 @@ pub fn from_dafny( )) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs index 9f14ccbba..f726f08b6 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/simple_double_config/_simple_double_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_double_config::SimpleDoubleConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig, + crate::simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig::SimpleDoubleConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig::SimpleDoubleConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig, + crate::r#simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig, >, ) -> crate::types::simple_double_config::SimpleDoubleConfig { crate::types::simple_double_config::SimpleDoubleConfig {} diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..e2aff6944 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2065 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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; +mod standard_library_conversions; + +pub use client::Client; +pub use types::simple_double_config::SimpleDoubleConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod smithydouble { + pub mod internaldafny { + pub use crate::simple::types::smithydouble::internaldafny::types::ISimpleTypesDoubleClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleDoubleConfig() -> ::std::rc::Rc{ + ::std::rc::Rc::new(crate::simple::types::smithydouble::internaldafny::types::SimpleDoubleConfig::SimpleDoubleConfig {}) + } + pub fn SimpleDouble(config: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::smithydouble::internaldafny::SimpleDoubleClient::_allocate_object(); + crate::simple::types::smithydouble::internaldafny::SimpleDoubleClient::_ctor(&_nw1, &::std::rc::Rc::new(crate::r#_SimpleSmithyDoubleOperations_Compile::Config::Config {})); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleDoubleClient { + pub r#__i_config: + ::std::rc::Rc, + } + + impl SimpleDoubleClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::smithydouble::internaldafny::SimpleDoubleClient, + >, + config: &::std::rc::Rc< + crate::r#_SimpleSmithyDoubleOperations_Compile::Config, + >, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject + for crate::simple::types::smithydouble::internaldafny::SimpleDoubleClient + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesDoubleClient + for crate::simple::types::smithydouble::internaldafny::SimpleDoubleClient + { + fn GetDouble(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleSmithyDoubleOperations_Compile::_default::GetDouble( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::smithydouble::internaldafny::SimpleDoubleClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::smithydouble::internaldafny::types::ISimpleTypesDoubleClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.smithydouble.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetDoubleInput { + GetDoubleInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + }, + } + + impl GetDoubleInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetDoubleInput::GetDoubleInput { value } => value, + } + } + } + + impl Debug for GetDoubleInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetDoubleInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetDoubleInput::GetDoubleInput { value } => { + write!(_formatter, "simple.types.smithydouble.internaldafny.types.GetDoubleInput.GetDoubleInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetDoubleInput {} + + impl Hash for GetDoubleInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetDoubleInput::GetDoubleInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetDoubleInput { + fn default() -> GetDoubleInput { + GetDoubleInput::GetDoubleInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetDoubleInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetDoubleOutput { + GetDoubleOutput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + >, + }, + } + + impl GetDoubleOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence>, + > { + match self { + GetDoubleOutput::GetDoubleOutput { value } => value, + } + } + } + + impl Debug for GetDoubleOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetDoubleOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetDoubleOutput::GetDoubleOutput { value } => { + write!(_formatter, "simple.types.smithydouble.internaldafny.types.GetDoubleOutput.GetDoubleOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetDoubleOutput {} + + impl Hash for GetDoubleOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetDoubleOutput::GetDoubleOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetDoubleOutput { + fn default() -> GetDoubleOutput { + GetDoubleOutput::GetDoubleOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetDoubleOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleDoubleConfig { + SimpleDoubleConfig {}, + } + + impl SimpleDoubleConfig {} + + impl Debug for SimpleDoubleConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleDoubleConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleDoubleConfig::SimpleDoubleConfig {} => { + write!(_formatter, "simple.types.smithydouble.internaldafny.types.SimpleDoubleConfig.SimpleDoubleConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleDoubleConfig {} + + impl Hash for SimpleDoubleConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleDoubleConfig::SimpleDoubleConfig {} => {} + } + } + } + + impl Default for SimpleDoubleConfig { + fn default() -> SimpleDoubleConfig { + SimpleDoubleConfig::SimpleDoubleConfig {} + } + } + + impl AsRef for &SimpleDoubleConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesDoubleClientCallHistory {} + + impl ISimpleTypesDoubleClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::smithydouble::internaldafny::types::ISimpleTypesDoubleClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesDoubleClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetDouble(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithydouble::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithydouble::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.smithydouble.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!(_formatter, "simple.types.smithydouble.internaldafny.types.Error.Opaque(")?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = ::std::rc::Rc< + crate::simple::types::smithydouble::internaldafny::types::Error, + >; + } + } + } + } +} +pub mod r#_SimpleSmithyDoubleOperations_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn r#_ValidInternalConfig_q( + config: &::std::rc::Rc, + ) -> bool { + true + } + pub fn GetDouble( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithydouble::internaldafny::types::GetDoubleInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithydouble::internaldafny::types::GetDoubleOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut check: bool = ::default(); + let mut _out0: bool = ::default(); + _out0 = crate::r#_SimpleSmithyDoubleOperations_Compile::_default::ValidateDoubleType( + input.value().value(), + ); + check = _out0; + if !check { + panic!("Halt") + }; + let mut result: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithydouble::internaldafny::types::GetDoubleOutput::GetDoubleOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithydouble::internaldafny::types::GetDoubleOutput, + >, + ::std::rc::Rc, + >::Success { + value: result.clone(), + }, + )); + return output.read(); + } + pub fn ValidateDoubleType(input: &::dafny_runtime::Sequence) -> bool { + let mut output: bool = ::default(); + output = input.cardinality() == ::dafny_runtime::int!(8); + return output; + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!( + _formatter, + "SimpleSmithyDoubleOperations_Compile.Config.Config" + )?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs index d3b6744bd..8b6d980d9 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/operation/get_double.rs @@ -20,7 +20,7 @@ impl GetDouble { ::dafny_runtime::md!(client.dafny_client.clone()).GetDouble(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_double::_get_double_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/standard_library_conversions.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch index 83df42bfb..a04035865 100644 --- a/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..2256d42e +index 00000000..9649346b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs @@ -0,0 +1,41 @@ @@ -10,7 +10,7 @@ index 00000000..2256d42e + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..2256d42e + conf: crate::types::simple_enum_config::SimpleEnumConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dsmithyenum_dinternaldafny::_default::SimpleEnum( ++ crate::simple::types::smithyenum::internaldafny::_default::SimpleEnum( + &crate::conversions::simple_enum_config::_simple_enum_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -153,7 +153,7 @@ index 00000000..7361ee56 +pub mod simple_enum_shape; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs new file mode 100644 -index 00000000..e1e88552 +index 00000000..ef493d11 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs @@ -0,0 +1,32 @@ @@ -164,21 +164,21 @@ index 00000000..e1e88552 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum::GetEnumError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum::GetEnumError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithyenum::internaldafny::types::Error, + >, +) -> crate::operation::get_enum::GetEnumError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum::GetEnumError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -191,7 +191,7 @@ index 00000000..e1e88552 +pub mod _get_enum_output; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs new file mode 100644 -index 00000000..890d436c +index 00000000..3bbf1602 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs @@ -0,0 +1,45 @@ @@ -200,17 +200,17 @@ index 00000000..890d436c +pub fn to_dafny( + value: crate::operation::get_enum::GetEnumInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -218,12 +218,12 @@ index 00000000..890d436c +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, +) -> crate::operation::get_enum::GetEnumInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -232,7 +232,7 @@ index 00000000..890d436c + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -242,7 +242,7 @@ index 00000000..890d436c +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs new file mode 100644 -index 00000000..17fc6fcc +index 00000000..1ae04378 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs @@ -0,0 +1,45 @@ @@ -251,17 +251,17 @@ index 00000000..17fc6fcc +pub fn to_dafny( + value: crate::operation::get_enum::GetEnumOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -269,12 +269,12 @@ index 00000000..17fc6fcc +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, +) -> crate::operation::get_enum::GetEnumOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -283,7 +283,7 @@ index 00000000..17fc6fcc + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -293,7 +293,7 @@ index 00000000..17fc6fcc +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs new file mode 100644 -index 00000000..e7c42b88 +index 00000000..5e3e946f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs @@ -0,0 +1,32 @@ @@ -304,21 +304,21 @@ index 00000000..e7c42b88 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithyenum::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -331,7 +331,7 @@ index 00000000..e7c42b88 +pub mod _get_enum_first_known_value_test_output; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs new file mode 100644 -index 00000000..3ca27e40 +index 00000000..45398964 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs @@ -0,0 +1,45 @@ @@ -340,17 +340,17 @@ index 00000000..3ca27e40 +pub fn to_dafny( + value: crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -358,12 +358,12 @@ index 00000000..3ca27e40 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, +) -> crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -372,7 +372,7 @@ index 00000000..3ca27e40 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -382,7 +382,7 @@ index 00000000..3ca27e40 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs new file mode 100644 -index 00000000..9fe7a5c6 +index 00000000..c31403c9 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs @@ -0,0 +1,45 @@ @@ -391,17 +391,17 @@ index 00000000..9fe7a5c6 +pub fn to_dafny( + value: crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -409,12 +409,12 @@ index 00000000..9fe7a5c6 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, +) -> crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -423,7 +423,7 @@ index 00000000..9fe7a5c6 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -433,7 +433,7 @@ index 00000000..9fe7a5c6 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs new file mode 100644 -index 00000000..5496e4ae +index 00000000..afa0c42c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs @@ -0,0 +1,32 @@ @@ -444,21 +444,21 @@ index 00000000..5496e4ae +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithyenum::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -471,7 +471,7 @@ index 00000000..5496e4ae +pub mod _get_enum_second_known_value_test_output; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs new file mode 100644 -index 00000000..c3368baf +index 00000000..c73d8a63 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs @@ -0,0 +1,45 @@ @@ -480,17 +480,17 @@ index 00000000..c3368baf +pub fn to_dafny( + value: crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -498,12 +498,12 @@ index 00000000..c3368baf +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, +) -> crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -512,7 +512,7 @@ index 00000000..c3368baf + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -522,7 +522,7 @@ index 00000000..c3368baf +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs new file mode 100644 -index 00000000..7bcb3e13 +index 00000000..fbb2809e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs @@ -0,0 +1,45 @@ @@ -531,17 +531,17 @@ index 00000000..7bcb3e13 +pub fn to_dafny( + value: crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -549,12 +549,12 @@ index 00000000..7bcb3e13 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, +) -> crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -563,7 +563,7 @@ index 00000000..7bcb3e13 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -573,7 +573,7 @@ index 00000000..7bcb3e13 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs new file mode 100644 -index 00000000..a72cee55 +index 00000000..b3d8d118 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs @@ -0,0 +1,32 @@ @@ -584,21 +584,21 @@ index 00000000..a72cee55 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithyenum::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -611,7 +611,7 @@ index 00000000..a72cee55 +pub mod _get_enum_third_known_value_test_output; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs new file mode 100644 -index 00000000..bdca5a22 +index 00000000..73c9d9b6 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs @@ -0,0 +1,45 @@ @@ -620,17 +620,17 @@ index 00000000..bdca5a22 +pub fn to_dafny( + value: crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -638,12 +638,12 @@ index 00000000..bdca5a22 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, +) -> crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -652,7 +652,7 @@ index 00000000..bdca5a22 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -662,7 +662,7 @@ index 00000000..bdca5a22 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs new file mode 100644 -index 00000000..3f4e17ba +index 00000000..aafc1403 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs @@ -0,0 +1,45 @@ @@ -671,17 +671,17 @@ index 00000000..3f4e17ba +pub fn to_dafny( + value: crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -689,12 +689,12 @@ index 00000000..3f4e17ba +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, ++ crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, +) -> crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -703,7 +703,7 @@ index 00000000..3f4e17ba + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -722,7 +722,7 @@ index 00000000..973679ee +pub mod _simple_enum_config; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs new file mode 100644 -index 00000000..7c31b411 +index 00000000..a1e48e7f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs @@ -0,0 +1,19 @@ @@ -732,15 +732,15 @@ index 00000000..7c31b411 +pub fn to_dafny( + value: crate::types::simple_enum_config::SimpleEnumConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig, ++ crate::simple::types::smithyenum::internaldafny::types::SimpleEnumConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig::SimpleEnumConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumConfig::SimpleEnumConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig, ++ crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumConfig, + >, +) -> crate::types::simple_enum_config::SimpleEnumConfig { + crate::types::simple_enum_config::SimpleEnumConfig {} @@ -756,7 +756,7 @@ index 00000000..f531b553 +pub mod _simple_enum_shape; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs new file mode 100644 -index 00000000..47c3c897 +index 00000000..8519605a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs @@ -0,0 +1,23 @@ @@ -765,22 +765,22 @@ index 00000000..47c3c897 + +pub fn to_dafny( + value: &crate::types::simple_enum_shape::SimpleEnumShape, -+) -> crate::implementation_from_dafny::_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape { ++) -> crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape { + match value { -+ crate::types::simple_enum_shape::SimpleEnumShape::FIRST => crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::FIRST {}, -+ crate::types::simple_enum_shape::SimpleEnumShape::SECOND => crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::SECOND {}, -+ crate::types::simple_enum_shape::SimpleEnumShape::THIRD => crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::THIRD {}, ++ crate::types::simple_enum_shape::SimpleEnumShape::FIRST => crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::FIRST {}, ++ crate::types::simple_enum_shape::SimpleEnumShape::SECOND => crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::SECOND {}, ++ crate::types::simple_enum_shape::SimpleEnumShape::THIRD => crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::THIRD {}, + } +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape, ++ dafny_value: &crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape, +) -> crate::types::simple_enum_shape::SimpleEnumShape { + match dafny_value { -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::FIRST {} => crate::types::simple_enum_shape::SimpleEnumShape::FIRST, -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::SECOND {} => crate::types::simple_enum_shape::SimpleEnumShape::SECOND, -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::THIRD {} => crate::types::simple_enum_shape::SimpleEnumShape::THIRD, ++ crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::FIRST {} => crate::types::simple_enum_shape::SimpleEnumShape::FIRST, ++ crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::SECOND {} => crate::types::simple_enum_shape::SimpleEnumShape::SECOND, ++ crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::THIRD {} => crate::types::simple_enum_shape::SimpleEnumShape::THIRD, + } +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error.rs @@ -835,6 +835,32 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs +index 124e031e..c56fd3f3 100644 +--- b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,21 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_enum_config::SimpleEnumConfig; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..f914e7ba @@ -877,7 +903,7 @@ index 00000000..560af271 +pub mod get_enum_third_known_value_test; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs new file mode 100644 -index 00000000..53210a25 +index 00000000..d75b5ac4 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs @@ -0,0 +1,142 @@ @@ -902,7 +928,7 @@ index 00000000..53210a25 + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok(crate::conversions::get_enum::_get_enum_output::from_dafny( + inner_result.value().clone(), @@ -1253,7 +1279,7 @@ index 00000000..11e371c1 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs new file mode 100644 -index 00000000..d3db3b27 +index 00000000..106ec170 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs @@ -0,0 +1,149 @@ @@ -1279,7 +1305,7 @@ index 00000000..d3db3b27 + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_first_known_value_test::_get_enum_first_known_value_test_output::from_dafny( @@ -1648,7 +1674,7 @@ index 00000000..ca84c977 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs new file mode 100644 -index 00000000..241085f0 +index 00000000..b59e0ce5 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs @@ -0,0 +1,151 @@ @@ -1674,7 +1700,7 @@ index 00000000..241085f0 + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_second_known_value_test::_get_enum_second_known_value_test_output::from_dafny( @@ -2044,7 +2070,7 @@ index 00000000..e54348b3 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs new file mode 100644 -index 00000000..34d24692 +index 00000000..d5def6ff --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs @@ -0,0 +1,149 @@ @@ -2070,7 +2096,7 @@ index 00000000..34d24692 + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_third_known_value_test::_get_enum_third_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/Cargo.toml index 592698a12..a3026b8a6 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs index 2256d42ea..9649346b6 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_enum_config::SimpleEnumConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dsmithyenum_dinternaldafny::_default::SimpleEnum( + crate::simple::types::smithyenum::internaldafny::_default::SimpleEnum( &crate::conversions::simple_enum_config::_simple_enum_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs index e1e88552a..ef493d119 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum::GetEnumError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum::GetEnumError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithyenum::internaldafny::types::Error, >, ) -> crate::operation::get_enum::GetEnumError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum::GetEnumError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs index 890d436ca..3bbf16021 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum::GetEnumInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, >, ) -> crate::operation::get_enum::GetEnumInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs index 17fc6fcce..1ae04378c 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum/_get_enum_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum::GetEnumOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, >, ) -> crate::operation::get_enum::GetEnumOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs index e7c42b885..5e3e946f3 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithyenum::internaldafny::types::Error, >, ) -> crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs index 3ca27e403..453989647 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, >, ) -> crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs index 9fe7a5c63..c31403c9c 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test/_get_enum_first_known_value_test_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, >, ) -> crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs index 5496e4ae1..afa0c42cd 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithyenum::internaldafny::types::Error, >, ) -> crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs index c3368baf2..c73d8a630 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, >, ) -> crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs index 7bcb3e138..fbb2809ed 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test/_get_enum_second_known_value_test_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, >, ) -> crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs index a72cee55a..b3d8d1186 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithyenum::internaldafny::types::Error, >, ) -> crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithyenum::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs index bdca5a229..73c9d9b6f 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput::GetEnumInput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput::GetEnumInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumInput, >, ) -> crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs index 3f4e17ba2..aafc1403e 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test/_get_enum_third_known_value_test_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_shape::_simple_enum_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, + crate::r#simple::types::smithyenum::internaldafny::types::GetEnumOutput, >, ) -> crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_shape::_simple_enum_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs index 7c31b4114..a1e48e7f0 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_config/_simple_enum_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_enum_config::SimpleEnumConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig, + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig::SimpleEnumConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumConfig::SimpleEnumConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig, + crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumConfig, >, ) -> crate::types::simple_enum_config::SimpleEnumConfig { crate::types::simple_enum_config::SimpleEnumConfig {} diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs index 47c3c8975..8519605a7 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/simple_enum_shape/_simple_enum_shape.rs @@ -3,21 +3,21 @@ pub fn to_dafny( value: &crate::types::simple_enum_shape::SimpleEnumShape, -) -> crate::implementation_from_dafny::_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape { +) -> crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape { match value { - crate::types::simple_enum_shape::SimpleEnumShape::FIRST => crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::FIRST {}, - crate::types::simple_enum_shape::SimpleEnumShape::SECOND => crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::SECOND {}, - crate::types::simple_enum_shape::SimpleEnumShape::THIRD => crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::THIRD {}, + crate::types::simple_enum_shape::SimpleEnumShape::FIRST => crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::FIRST {}, + crate::types::simple_enum_shape::SimpleEnumShape::SECOND => crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::SECOND {}, + crate::types::simple_enum_shape::SimpleEnumShape::THIRD => crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::THIRD {}, } } #[allow(dead_code)] pub fn from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape, + dafny_value: &crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape, ) -> crate::types::simple_enum_shape::SimpleEnumShape { match dafny_value { - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::FIRST {} => crate::types::simple_enum_shape::SimpleEnumShape::FIRST, - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::SECOND {} => crate::types::simple_enum_shape::SimpleEnumShape::SECOND, - crate::implementation_from_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::THIRD {} => crate::types::simple_enum_shape::SimpleEnumShape::THIRD, + crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::FIRST {} => crate::types::simple_enum_shape::SimpleEnumShape::FIRST, + crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::SECOND {} => crate::types::simple_enum_shape::SimpleEnumShape::SECOND, + crate::r#simple::types::smithyenum::internaldafny::types::SimpleEnumShape::THIRD {} => crate::types::simple_enum_shape::SimpleEnumShape::THIRD, } } diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..c56fd3f3a --- /dev/null +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2460 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_enum_config::SimpleEnumConfig; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod smithyenum { + pub mod internaldafny { + pub use crate::simple::types::smithyenum::internaldafny::types::ISimpleTypesEnumClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleEnumConfig() -> ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumConfig, + > { + ::std::rc::Rc::new(crate::simple::types::smithyenum::internaldafny::types::SimpleEnumConfig::SimpleEnumConfig {}) + } + pub fn SimpleEnum( + config: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::smithyenum::internaldafny::SimpleEnumClient, + >, + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::types::smithyenum::internaldafny::SimpleEnumClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::smithyenum::internaldafny::SimpleEnumClient::_allocate_object(); + crate::simple::types::smithyenum::internaldafny::SimpleEnumClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleEnumImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleEnumClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleEnumClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::smithyenum::internaldafny::SimpleEnumClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::types::smithyenum::internaldafny::SimpleEnumClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesEnumClient for crate::simple::types::smithyenum::internaldafny::SimpleEnumClient { + fn GetEnum(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleEnumImpl_Compile::_default::GetEnum( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetEnumFirstKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleEnumImpl_Compile::_default::GetEnumFirstKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + fn GetEnumSecondKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleEnumImpl_Compile::_default::GetEnumSecondKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + return output.read(); + } + fn GetEnumThirdKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out3 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleEnumImpl_Compile::_default::GetEnumThirdKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out3.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::smithyenum::internaldafny::SimpleEnumClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::smithyenum::internaldafny::types::ISimpleTypesEnumClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetEnumInput { + GetEnumInput { + value: ::std::rc::Rc>> + } + } + + impl GetEnumInput { + pub fn value(&self) -> &::std::rc::Rc>>{ + match self { + GetEnumInput::GetEnumInput { value } => value, + } + } + } + + impl Debug for GetEnumInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetEnumInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetEnumInput::GetEnumInput { value } => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.GetEnumInput.GetEnumInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetEnumInput {} + + impl Hash for GetEnumInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetEnumInput::GetEnumInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetEnumInput { + fn default() -> GetEnumInput { + GetEnumInput::GetEnumInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetEnumInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetEnumOutput { + GetEnumOutput { + value: ::std::rc::Rc>> + } + } + + impl GetEnumOutput { + pub fn value(&self) -> &::std::rc::Rc>>{ + match self { + GetEnumOutput::GetEnumOutput { value } => value, + } + } + } + + impl Debug for GetEnumOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetEnumOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetEnumOutput::GetEnumOutput { value } => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.GetEnumOutput.GetEnumOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetEnumOutput {} + + impl Hash for GetEnumOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetEnumOutput::GetEnumOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetEnumOutput { + fn default() -> GetEnumOutput { + GetEnumOutput::GetEnumOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetEnumOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleEnumConfig { + SimpleEnumConfig {}, + } + + impl SimpleEnumConfig {} + + impl Debug for SimpleEnumConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleEnumConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleEnumConfig::SimpleEnumConfig {} => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.SimpleEnumConfig.SimpleEnumConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleEnumConfig {} + + impl Hash for SimpleEnumConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleEnumConfig::SimpleEnumConfig {} => {} + } + } + } + + impl Default for SimpleEnumConfig { + fn default() -> SimpleEnumConfig { + SimpleEnumConfig::SimpleEnumConfig {} + } + } + + impl AsRef for &SimpleEnumConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleEnumShape { + FIRST {}, + SECOND {}, + THIRD {}, + } + + impl SimpleEnumShape {} + + impl Debug for SimpleEnumShape { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleEnumShape { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleEnumShape::FIRST {} => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.SimpleEnumShape.FIRST")?; + Ok(()) + } + SimpleEnumShape::SECOND {} => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.SimpleEnumShape.SECOND")?; + Ok(()) + } + SimpleEnumShape::THIRD {} => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.SimpleEnumShape.THIRD")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleEnumShape {} + + impl Hash for SimpleEnumShape { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleEnumShape::FIRST {} => {} + SimpleEnumShape::SECOND {} => {} + SimpleEnumShape::THIRD {} => {} + } + } + } + + impl Default for SimpleEnumShape { + fn default() -> SimpleEnumShape { + SimpleEnumShape::FIRST {} + } + } + + impl AsRef for &SimpleEnumShape { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesEnumClientCallHistory {} + + impl ISimpleTypesEnumClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::smithyenum::internaldafny::types::ISimpleTypesEnumClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesEnumClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetEnum(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetEnumFirstKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetEnumSecondKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetEnumThirdKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.smithyenum.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.smithyenum.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >; + } + } + } + } +} +pub mod r#_SimpleEnumImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetEnum( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetEnumFirstKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e00: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = input.value().value().clone(); + let mut _e10: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = ::std::rc::Rc::new( + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape::FIRST {}, + ); + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e01: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = res.value().value().clone(); + let mut _e11: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = ::std::rc::Rc::new( + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape::FIRST {}, + ); + if !(_e01.clone() == _e11.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetEnumSecondKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e02: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = input.value().value().clone(); + let mut _e12: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = ::std::rc::Rc::new( + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape::SECOND {}, + ); + if !(_e02.clone() == _e12.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e03: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = res.value().value().clone(); + let mut _e13: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = ::std::rc::Rc::new( + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape::SECOND {}, + ); + if !(_e03.clone() == _e13.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e03)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e13)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetEnumThirdKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::Error, + >, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e04: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = input.value().value().clone(); + let mut _e14: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = ::std::rc::Rc::new( + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape::THIRD {}, + ); + if !(_e04.clone() == _e14.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e04)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e14)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput::GetEnumOutput { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e05: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = res.value().value().clone(); + let mut _e15: ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape, + > = ::std::rc::Rc::new( + crate::simple::types::smithyenum::internaldafny::types::SimpleEnumShape::THIRD {}, + ); + if !(_e05.clone() == _e15.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e05)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e15)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithyenum::internaldafny::types::GetEnumOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleEnumImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs index 53210a251..d75b5ac44 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum.rs @@ -19,7 +19,7 @@ impl GetEnum { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok(crate::conversions::get_enum::_get_enum_output::from_dafny( inner_result.value().clone(), diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs index d3db3b272..106ec1702 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_first_known_value_test.rs @@ -20,7 +20,7 @@ impl GetEnumFirstKnownValueTest { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_first_known_value_test::_get_enum_first_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs index 241085f06..b59e0ce56 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_second_known_value_test.rs @@ -20,7 +20,7 @@ impl GetEnumSecondKnownValueTest { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_second_known_value_test::_get_enum_second_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs index 34d246920..d5def6ff2 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/operation/get_enum_third_known_value_test.rs @@ -20,7 +20,7 @@ impl GetEnumThirdKnownValueTest { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetEnum(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_third_known_value_test::_get_enum_third_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch index eb065ca9f..6efd51ecc 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..d98cef25 +index 00000000..f7bbdbfa --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs @@ -0,0 +1,41 @@ @@ -10,7 +10,7 @@ index 00000000..d98cef25 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..d98cef25 + conf: crate::types::simple_enum_v2_config::SimpleEnumV2Config, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_denumv2_dinternaldafny::_default::SimpleEnumV2( ++ crate::simple::types::enumv2::internaldafny::_default::SimpleEnumV2( + &crate::conversions::simple_enum_v2_config::_simple_enum_v2_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -153,7 +153,7 @@ index 00000000..323761ef +pub mod simple_enum_v2_shape; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs new file mode 100644 -index 00000000..99f3865f +index 00000000..e9b9909b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs @@ -0,0 +1,37 @@ @@ -164,10 +164,10 @@ index 00000000..99f3865f +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_v2::GetEnumV2Error, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_v2::GetEnumV2Error::Unhandled(unhandled) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::types::enumv2::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -179,11 +179,11 @@ index 00000000..99f3865f +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::enumv2::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_v2::GetEnumV2Error { + // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_v2::GetEnumV2Error::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -196,7 +196,7 @@ index 00000000..99f3865f +pub mod _get_enum_v2_output; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs new file mode 100644 -index 00000000..21d03899 +index 00000000..236bf355 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs @@ -0,0 +1,45 @@ @@ -205,17 +205,17 @@ index 00000000..21d03899 +pub fn to_dafny( + value: crate::operation::get_enum_v2::GetEnumV2Input, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -223,12 +223,12 @@ index 00000000..21d03899 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, +) -> crate::operation::get_enum_v2::GetEnumV2Input { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -237,7 +237,7 @@ index 00000000..21d03899 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -247,7 +247,7 @@ index 00000000..21d03899 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs new file mode 100644 -index 00000000..7db0ec0f +index 00000000..84d950d9 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs @@ -0,0 +1,45 @@ @@ -256,17 +256,17 @@ index 00000000..7db0ec0f +pub fn to_dafny( + value: crate::operation::get_enum_v2::GetEnumV2Output, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -274,12 +274,12 @@ index 00000000..7db0ec0f +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, +) -> crate::operation::get_enum_v2::GetEnumV2Output { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -288,7 +288,7 @@ index 00000000..7db0ec0f + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -298,7 +298,7 @@ index 00000000..7db0ec0f +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs new file mode 100644 -index 00000000..b8e4e062 +index 00000000..9e850944 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs @@ -0,0 +1,32 @@ @@ -309,21 +309,21 @@ index 00000000..b8e4e062 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::enumv2::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -336,7 +336,7 @@ index 00000000..b8e4e062 +pub mod _get_enum_v2_first_known_value_test_output; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs new file mode 100644 -index 00000000..c2dc9a57 +index 00000000..043d6933 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs @@ -0,0 +1,47 @@ @@ -345,17 +345,17 @@ index 00000000..c2dc9a57 +pub fn to_dafny( + value: crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -363,12 +363,12 @@ index 00000000..c2dc9a57 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, +) -> crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -377,7 +377,7 @@ index 00000000..c2dc9a57 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -389,7 +389,7 @@ index 00000000..c2dc9a57 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs new file mode 100644 -index 00000000..b636f233 +index 00000000..7378e117 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs @@ -0,0 +1,47 @@ @@ -398,17 +398,17 @@ index 00000000..b636f233 +pub fn to_dafny( + value: crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -416,12 +416,12 @@ index 00000000..b636f233 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, +) -> crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -430,7 +430,7 @@ index 00000000..b636f233 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -442,7 +442,7 @@ index 00000000..b636f233 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs new file mode 100644 -index 00000000..dbb580e6 +index 00000000..b6de63fa --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs @@ -0,0 +1,32 @@ @@ -453,21 +453,21 @@ index 00000000..dbb580e6 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::enumv2::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -480,7 +480,7 @@ index 00000000..dbb580e6 +pub mod _get_enum_v2_second_known_value_test_output; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs new file mode 100644 -index 00000000..0921259a +index 00000000..a7a40bf4 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs @@ -0,0 +1,47 @@ @@ -489,17 +489,17 @@ index 00000000..0921259a +pub fn to_dafny( + value: crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -507,12 +507,12 @@ index 00000000..0921259a +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, +) -> crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -521,7 +521,7 @@ index 00000000..0921259a + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -533,7 +533,7 @@ index 00000000..0921259a +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs new file mode 100644 -index 00000000..6c9e79ae +index 00000000..07bec266 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs @@ -0,0 +1,47 @@ @@ -542,17 +542,17 @@ index 00000000..6c9e79ae +pub fn to_dafny( + value: crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -560,12 +560,12 @@ index 00000000..6c9e79ae +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, +) -> crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -574,7 +574,7 @@ index 00000000..6c9e79ae + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -586,7 +586,7 @@ index 00000000..6c9e79ae +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs new file mode 100644 -index 00000000..760b6c68 +index 00000000..a1ddd7da --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs @@ -0,0 +1,32 @@ @@ -597,21 +597,21 @@ index 00000000..760b6c68 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::enumv2::internaldafny::types::Error, + >, +) -> crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError { + // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -624,7 +624,7 @@ index 00000000..760b6c68 +pub mod _get_enum_v2_third_known_value_test_output; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs new file mode 100644 -index 00000000..7675f6c9 +index 00000000..8adc054b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs @@ -0,0 +1,47 @@ @@ -633,17 +633,17 @@ index 00000000..7675f6c9 +pub fn to_dafny( + value: crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -651,12 +651,12 @@ index 00000000..7675f6c9 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, +) -> crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -665,7 +665,7 @@ index 00000000..7675f6c9 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -677,7 +677,7 @@ index 00000000..7675f6c9 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs new file mode 100644 -index 00000000..0d198776 +index 00000000..1607c800 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs @@ -0,0 +1,47 @@ @@ -686,17 +686,17 @@ index 00000000..0d198776 +pub fn to_dafny( + value: crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(b) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), + ), + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -704,12 +704,12 @@ index 00000000..0d198776 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, ++ crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, +) -> crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -718,7 +718,7 @@ index 00000000..0d198776 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -739,7 +739,7 @@ index 00000000..3eaacd61 +pub mod _simple_enum_v2_config; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs new file mode 100644 -index 00000000..3b854743 +index 00000000..f0a68045 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs @@ -0,0 +1,19 @@ @@ -749,15 +749,15 @@ index 00000000..3b854743 +pub fn to_dafny( + value: crate::types::simple_enum_v2_config::SimpleEnumV2Config, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config, ++ crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Config, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config::SimpleEnumV2Config {}) ++ ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Config::SimpleEnumV2Config {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config, ++ crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Config, + >, +) -> crate::types::simple_enum_v2_config::SimpleEnumV2Config { + crate::types::simple_enum_v2_config::SimpleEnumV2Config {} @@ -773,7 +773,7 @@ index 00000000..b4f4a50f +pub mod _simple_enum_v2_shape; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs new file mode 100644 -index 00000000..884f87fa +index 00000000..d48a6337 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs @@ -0,0 +1,23 @@ @@ -782,22 +782,22 @@ index 00000000..884f87fa + +pub fn to_dafny( + value: &crate::types::simple_enum_v2_shape::SimpleEnumV2Shape, -+) -> crate::implementation_from_dafny::_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape { ++) -> crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape { + match value { -+ crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST => crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::FIRST {}, -+ crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND => crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::SECOND {}, -+ crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD => crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::THIRD {}, ++ crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST => crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::FIRST {}, ++ crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND => crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::SECOND {}, ++ crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD => crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::THIRD {}, + } +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape, ++ dafny_value: &crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, +) -> crate::types::simple_enum_v2_shape::SimpleEnumV2Shape { + match dafny_value { -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::FIRST {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST, -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::SECOND {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND, -+ crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::THIRD {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD, ++ crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::FIRST {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST, ++ crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::SECOND {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND, ++ crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::THIRD {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD, + } +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error.rs @@ -852,6 +852,31 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs +index a4aa104f..5dcd7a05 100644 +--- b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,20 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_enum_v2_config::SimpleEnumV2Config; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..fcb015ba @@ -894,7 +919,7 @@ index 00000000..565298a1 +pub mod get_enum_v2_third_known_value_test; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs new file mode 100644 -index 00000000..2c1feba6 +index 00000000..f556fbe3 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs @@ -0,0 +1,145 @@ @@ -920,7 +945,7 @@ index 00000000..2c1feba6 + ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_v2::_get_enum_v2_output::from_dafny( @@ -1279,7 +1304,7 @@ index 00000000..e742b3d9 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs new file mode 100644 -index 00000000..569a701d +index 00000000..57c67e00 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs @@ -0,0 +1,152 @@ @@ -1306,7 +1331,7 @@ index 00000000..569a701d + ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_v2_first_known_value_test::_get_enum_v2_first_known_value_test_output::from_dafny( @@ -1681,7 +1706,7 @@ index 00000000..c88ff6ef +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs new file mode 100644 -index 00000000..a88982f5 +index 00000000..9fecf26d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs @@ -0,0 +1,152 @@ @@ -1708,7 +1733,7 @@ index 00000000..a88982f5 + ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_v2_second_known_value_test::_get_enum_v2_second_known_value_test_output::from_dafny( @@ -2082,7 +2107,7 @@ index 00000000..5137b217 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs new file mode 100644 -index 00000000..b72e05fd +index 00000000..bf5efb30 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs @@ -0,0 +1,152 @@ @@ -2109,7 +2134,7 @@ index 00000000..b72e05fd + ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_enum_v2_third_known_value_test::_get_enum_v2_third_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/Cargo.toml index 9771b1604..dbaad13bf 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs index d98cef259..f7bbdbfac 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_enum_v2_config::SimpleEnumV2Config, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_denumv2_dinternaldafny::_default::SimpleEnumV2( + crate::simple::types::enumv2::internaldafny::_default::SimpleEnumV2( &crate::conversions::simple_enum_v2_config::_simple_enum_v2_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs index 99f3865f6..e9b9909b5 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs @@ -5,10 +5,10 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_v2::GetEnumV2Error, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_v2::GetEnumV2Error::Unhandled(unhandled) => ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::types::enumv2::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -20,11 +20,11 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, + crate::r#simple::types::enumv2::internaldafny::types::Error, >, ) -> crate::operation::get_enum_v2::GetEnumV2Error { // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_v2::GetEnumV2Error::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs index 21d03899d..236bf3550 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2::GetEnumV2Input, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, >, ) -> crate::operation::get_enum_v2::GetEnumV2Input { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs index 7db0ec0f1..84d950d91 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2/_get_enum_v2_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2::GetEnumV2Output, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, >, ) -> crate::operation::get_enum_v2::GetEnumV2Output { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs index b8e4e0624..9e8509446 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::enumv2::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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, + crate::r#simple::types::enumv2::internaldafny::types::Error, >, ) -> crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError { // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs index c2dc9a57f..043d69333 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, >, ) -> crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs index b636f2330..7378e1178 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test/_get_enum_v2_first_known_value_test_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, >, ) -> crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs index dbb580e62..b6de63fad 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::enumv2::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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, + crate::r#simple::types::enumv2::internaldafny::types::Error, >, ) -> crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError { // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs index 0921259a1..a7a40bf49 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, >, ) -> crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs index 6c9e79aea..07bec2664 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test/_get_enum_v2_second_known_value_test_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, >, ) -> crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs index 760b6c689..a1ddd7dab 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::enumv2::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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error, + crate::r#simple::types::enumv2::internaldafny::types::Error, >, ) -> crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError { // 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::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::enumv2::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs index 7675f6c9b..8adc054b0 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_input.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&v), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input::GetEnumV2Input { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input::GetEnumV2Input { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Input, >, ) -> crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs index 0d198776e..1607c8003 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test/_get_enum_v2_third_known_value_test_output.rs @@ -3,17 +3,17 @@ pub fn to_dafny( value: crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(b) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::to_dafny(&b), ), }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { value: ::std::rc::Rc::new(dafny_value) }) } @@ -21,12 +21,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, + crate::r#simple::types::enumv2::internaldafny::types::GetEnumV2Output, >, ) -> crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( crate::conversions::simple_enum_v2_shape::_simple_enum_v2_shape::from_dafny( @@ -35,7 +35,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs index 3b8547437..f0a680451 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_config/_simple_enum_v2_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_enum_v2_config::SimpleEnumV2Config, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config, + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Config, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config::SimpleEnumV2Config {}) + ::std::rc::Rc::new(crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Config::SimpleEnumV2Config {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config, + crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Config, >, ) -> crate::types::simple_enum_v2_config::SimpleEnumV2Config { crate::types::simple_enum_v2_config::SimpleEnumV2Config {} diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs index 884f87fac..d48a6337b 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/simple_enum_v2_shape/_simple_enum_v2_shape.rs @@ -3,21 +3,21 @@ pub fn to_dafny( value: &crate::types::simple_enum_v2_shape::SimpleEnumV2Shape, -) -> crate::implementation_from_dafny::_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape { +) -> crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape { match value { - crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST => crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::FIRST {}, - crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND => crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::SECOND {}, - crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD => crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::THIRD {}, + crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST => crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::FIRST {}, + crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND => crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::SECOND {}, + crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD => crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::THIRD {}, } } #[allow(dead_code)] pub fn from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape, + dafny_value: &crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, ) -> crate::types::simple_enum_v2_shape::SimpleEnumV2Shape { match dafny_value { - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::FIRST {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST, - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::SECOND {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND, - crate::implementation_from_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::THIRD {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD, + crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::FIRST {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::FIRST, + crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::SECOND {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::SECOND, + crate::r#simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::THIRD {} => crate::types::simple_enum_v2_shape::SimpleEnumV2Shape::THIRD, } } diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..5dcd7a058 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2494 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_enum_v2_config::SimpleEnumV2Config; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod enumv2 { + pub mod internaldafny { + pub use crate::simple::types::enumv2::internaldafny::types::ISimpleTypesEnumV2Client; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleEnumV2Config() -> ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Config, + > { + ::std::rc::Rc::new(crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Config::SimpleEnumV2Config {}) + } + pub fn SimpleEnumV2( + config: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Config, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client, + >, + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client::_allocate_object(); + crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleEnumV2Impl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client, + >, + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >::Success { + value: client.read(), + }, + )); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleEnumV2Client { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleEnumV2Client { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesEnumV2Client for crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client { + fn GetEnumV2( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetEnumV2FirstKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from(crate::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2FirstKnownValueTest(&self.config().clone(), input)); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + fn GetEnumV2SecondKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from(crate::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2SecondKnownValueTest(&self.config().clone(), input)); + output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + return output.read(); + } + fn GetEnumV2ThirdKnownValueTest( + &mut self, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out3 = ::dafny_runtime::MaybePlacebo::from(crate::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2ThirdKnownValueTest(&self.config().clone(), input)); + output = ::dafny_runtime::MaybePlacebo::from(_out3.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::enumv2::internaldafny::SimpleEnumV2Client + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::enumv2::internaldafny::types::ISimpleTypesEnumV2Client); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetEnumV2Input { + GetEnumV2Input { + value: ::std::rc::Rc>> + } + } + + impl GetEnumV2Input { + pub fn value(&self) -> &::std::rc::Rc>>{ + match self { + GetEnumV2Input::GetEnumV2Input { value } => value, + } + } + } + + impl Debug for GetEnumV2Input { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetEnumV2Input { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetEnumV2Input::GetEnumV2Input { value } => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.GetEnumV2Input.GetEnumV2Input(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetEnumV2Input {} + + impl Hash for GetEnumV2Input { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetEnumV2Input::GetEnumV2Input { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetEnumV2Input { + fn default() -> GetEnumV2Input { + GetEnumV2Input::GetEnumV2Input { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetEnumV2Input { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetEnumV2Output { + GetEnumV2Output { + value: ::std::rc::Rc>> + } + } + + impl GetEnumV2Output { + pub fn value(&self) -> &::std::rc::Rc>>{ + match self { + GetEnumV2Output::GetEnumV2Output { value } => value, + } + } + } + + impl Debug for GetEnumV2Output { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetEnumV2Output { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetEnumV2Output::GetEnumV2Output { value } => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.GetEnumV2Output.GetEnumV2Output(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetEnumV2Output {} + + impl Hash for GetEnumV2Output { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetEnumV2Output::GetEnumV2Output { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetEnumV2Output { + fn default() -> GetEnumV2Output { + GetEnumV2Output::GetEnumV2Output { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetEnumV2Output { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleEnumV2Config { + SimpleEnumV2Config {}, + } + + impl SimpleEnumV2Config {} + + impl Debug for SimpleEnumV2Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleEnumV2Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleEnumV2Config::SimpleEnumV2Config {} => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.SimpleEnumV2Config.SimpleEnumV2Config")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleEnumV2Config {} + + impl Hash for SimpleEnumV2Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleEnumV2Config::SimpleEnumV2Config {} => {} + } + } + } + + impl Default for SimpleEnumV2Config { + fn default() -> SimpleEnumV2Config { + SimpleEnumV2Config::SimpleEnumV2Config {} + } + } + + impl AsRef for &SimpleEnumV2Config { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleEnumV2Shape { + FIRST {}, + SECOND {}, + THIRD {}, + } + + impl SimpleEnumV2Shape {} + + impl Debug for SimpleEnumV2Shape { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleEnumV2Shape { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleEnumV2Shape::FIRST {} => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.SimpleEnumV2Shape.FIRST")?; + Ok(()) + } + SimpleEnumV2Shape::SECOND {} => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.SimpleEnumV2Shape.SECOND")?; + Ok(()) + } + SimpleEnumV2Shape::THIRD {} => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.SimpleEnumV2Shape.THIRD")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleEnumV2Shape {} + + impl Hash for SimpleEnumV2Shape { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleEnumV2Shape::FIRST {} => {} + SimpleEnumV2Shape::SECOND {} => {} + SimpleEnumV2Shape::THIRD {} => {} + } + } + } + + impl Default for SimpleEnumV2Shape { + fn default() -> SimpleEnumV2Shape { + SimpleEnumV2Shape::FIRST {} + } + } + + impl AsRef for &SimpleEnumV2Shape { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesEnumV2ClientCallHistory {} + + impl ISimpleTypesEnumV2ClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::enumv2::internaldafny::types::ISimpleTypesEnumV2ClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesEnumV2Client: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetEnumV2(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetEnumV2FirstKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetEnumV2SecondKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetEnumV2ThirdKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.enumv2.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.enumv2.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } + } +} +pub mod r#_SimpleEnumV2Impl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetEnumV2( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetEnumV2FirstKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e00: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = input.value().value().clone(); + let mut _e10: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = ::std::rc::Rc::new( + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::FIRST {}, + ); + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e01: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = res.value().value().clone(); + let mut _e11: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = ::std::rc::Rc::new( + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::FIRST {}, + ); + if !(_e01.clone() == _e11.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetEnumV2SecondKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e02: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = input.value().value().clone(); + let mut _e12: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = ::std::rc::Rc::new( + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::SECOND {}, + ); + if !(_e02.clone() == _e12.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e03: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = res.value().value().clone(); + let mut _e13: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = ::std::rc::Rc::new( + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::SECOND {}, + ); + if !(_e03.clone() == _e13.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e03)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e13)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetEnumV2ThirdKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Input, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e04: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = input.value().value().clone(); + let mut _e14: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = ::std::rc::Rc::new( + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::THIRD {}, + ); + if !(_e04.clone() == _e14.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e04)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e14)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output::GetEnumV2Output { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e05: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = res.value().value().clone(); + let mut _e15: ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape, + > = ::std::rc::Rc::new( + crate::simple::types::enumv2::internaldafny::types::SimpleEnumV2Shape::THIRD {}, + ); + if !(_e05.clone() == _e15.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e05)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e15)); + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::enumv2::internaldafny::types::GetEnumV2Output, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleEnumV2Impl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs index 2c1feba68..f556fbe3e 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2.rs @@ -20,7 +20,7 @@ impl GetEnumV2 { ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_v2::_get_enum_v2_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs index 569a701d6..57c67e00b 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_first_known_value_test.rs @@ -21,7 +21,7 @@ impl GetEnumV2FirstKnownValueTest { ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_v2_first_known_value_test::_get_enum_v2_first_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs index a88982f58..9fecf26d2 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_second_known_value_test.rs @@ -21,7 +21,7 @@ impl GetEnumV2SecondKnownValueTest { ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_v2_second_known_value_test::_get_enum_v2_second_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs index b72e05fd1..bf5efb30b 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/operation/get_enum_v2_third_known_value_test.rs @@ -21,7 +21,7 @@ impl GetEnumV2ThirdKnownValueTest { ::dafny_runtime::md!(client.dafny_client.clone()).GetEnumV2(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_enum_v2_third_known_value_test::_get_enum_v2_third_known_value_test_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch index 9c69af39e..3b8e9f443 100644 --- a/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..2dd7a562 +index 00000000..a82eefe9 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs @@ -0,0 +1,39 @@ @@ -10,7 +10,7 @@ index 00000000..2dd7a562 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..2dd7a562 + conf: crate::types::simple_integer_config::SimpleIntegerConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dinteger_dinternaldafny::_default::SimpleInteger( ++ crate::simple::types::integer::internaldafny::_default::SimpleInteger( + &crate::conversions::simple_integer_config::_simple_integer_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -100,7 +100,7 @@ index 00000000..9d397cd0 +pub mod simple_integer_config; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs new file mode 100644 -index 00000000..c6a1e08f +index 00000000..3637ac26 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs @@ -0,0 +1,32 @@ @@ -111,21 +111,21 @@ index 00000000..c6a1e08f +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_integer::GetIntegerError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_integer::GetIntegerError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::integer::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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::integer::internaldafny::types::Error, + >, +) -> crate::operation::get_integer::GetIntegerError { + // 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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::integer::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_integer::GetIntegerError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -138,7 +138,7 @@ index 00000000..c6a1e08f +pub mod _get_integer_output; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs new file mode 100644 -index 00000000..9434318f +index 00000000..9b5403e0 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs @@ -0,0 +1,37 @@ @@ -147,13 +147,13 @@ index 00000000..9434318f +pub fn to_dafny( + value: crate::operation::get_integer::GetIntegerInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput::GetIntegerInput { ++ ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerInput::GetIntegerInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -161,17 +161,17 @@ index 00000000..9434318f +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, + >, +) -> crate::operation::get_integer::GetIntegerInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -181,7 +181,7 @@ index 00000000..9434318f +} diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs new file mode 100644 -index 00000000..b22c89e6 +index 00000000..08831772 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs @@ -0,0 +1,37 @@ @@ -190,13 +190,13 @@ index 00000000..b22c89e6 +pub fn to_dafny( + value: crate::operation::get_integer::GetIntegerOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput::GetIntegerOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -204,17 +204,17 @@ index 00000000..b22c89e6 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, + >, +) -> crate::operation::get_integer::GetIntegerOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -224,7 +224,7 @@ index 00000000..b22c89e6 +} diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs new file mode 100644 -index 00000000..0b0c5da8 +index 00000000..15c6b7c8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs @@ -0,0 +1,32 @@ @@ -235,21 +235,21 @@ index 00000000..0b0c5da8 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_integer_known_value::GetIntegerKnownValueError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_integer_known_value::GetIntegerKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::integer::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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::integer::internaldafny::types::Error, + >, +) -> crate::operation::get_integer_known_value::GetIntegerKnownValueError { + // 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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::integer::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_integer_known_value::GetIntegerKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -262,7 +262,7 @@ index 00000000..0b0c5da8 +pub mod _get_integer_known_value_output; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs new file mode 100644 -index 00000000..9f260381 +index 00000000..40db6820 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs @@ -0,0 +1,37 @@ @@ -271,13 +271,13 @@ index 00000000..9f260381 +pub fn to_dafny( + value: crate::operation::get_integer_known_value::GetIntegerKnownValueInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput::GetIntegerInput { ++ ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerInput::GetIntegerInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -285,17 +285,17 @@ index 00000000..9f260381 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, + >, +) -> crate::operation::get_integer_known_value::GetIntegerKnownValueInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -305,7 +305,7 @@ index 00000000..9f260381 +} diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs new file mode 100644 -index 00000000..2cf230ef +index 00000000..c122e6be --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs @@ -0,0 +1,37 @@ @@ -314,13 +314,13 @@ index 00000000..2cf230ef +pub fn to_dafny( + value: crate::operation::get_integer_known_value::GetIntegerKnownValueOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput::GetIntegerOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -328,17 +328,17 @@ index 00000000..2cf230ef +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, ++ crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, + >, +) -> crate::operation::get_integer_known_value::GetIntegerKnownValueOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -357,7 +357,7 @@ index 00000000..f3cdb738 +pub mod _simple_integer_config; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs new file mode 100644 -index 00000000..08cfc8bf +index 00000000..360d1989 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs @@ -0,0 +1,19 @@ @@ -367,15 +367,15 @@ index 00000000..08cfc8bf +pub fn to_dafny( + value: crate::types::simple_integer_config::SimpleIntegerConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig, ++ crate::simple::types::integer::internaldafny::types::SimpleIntegerConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig::SimpleIntegerConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::SimpleIntegerConfig::SimpleIntegerConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig, ++ crate::r#simple::types::integer::internaldafny::types::SimpleIntegerConfig, + >, +) -> crate::types::simple_integer_config::SimpleIntegerConfig { + crate::types::simple_integer_config::SimpleIntegerConfig {} @@ -432,6 +432,31 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs +index 2cac6001..08623efb 100644 +--- b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,20 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_integer_config::SimpleIntegerConfig; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..e427bffa @@ -472,7 +497,7 @@ index 00000000..faaa994c +pub mod get_integer_known_value; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs new file mode 100644 -index 00000000..52f7b049 +index 00000000..3cb49535 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs @@ -0,0 +1,145 @@ @@ -498,7 +523,7 @@ index 00000000..52f7b049 + ::dafny_runtime::md!(client.dafny_client.clone()).GetInteger(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_integer::_get_integer_output::from_dafny( @@ -831,7 +856,7 @@ index 00000000..74d985a9 +} diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs new file mode 100644 -index 00000000..27fe320f +index 00000000..06e0fa0c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs @@ -0,0 +1,150 @@ @@ -860,7 +885,7 @@ index 00000000..27fe320f + ::dafny_runtime::md!(client.dafny_client.clone()).GetInteger(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_integer_known_value::_get_integer_known_value_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/Cargo.toml index eda8e6d1a..d14ad003b 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs index 2dd7a5628..a82eefe99 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_integer_config::SimpleIntegerConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dinteger_dinternaldafny::_default::SimpleInteger( + crate::simple::types::integer::internaldafny::_default::SimpleInteger( &crate::conversions::simple_integer_config::_simple_integer_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs index c6a1e08fe..3637ac26f 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_integer::GetIntegerError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_integer::GetIntegerError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::integer::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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error, + crate::r#simple::types::integer::internaldafny::types::Error, >, ) -> crate::operation::get_integer::GetIntegerError { // 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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::integer::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_integer::GetIntegerError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs index 9434318f2..9b5403e08 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_integer::GetIntegerInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput::GetIntegerInput { + ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerInput::GetIntegerInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, >, ) -> crate::operation::get_integer::GetIntegerInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs index b22c89e6d..088317722 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer/_get_integer_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_integer::GetIntegerOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { + ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput::GetIntegerOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, >, ) -> crate::operation::get_integer::GetIntegerOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs index 0b0c5da83..15c6b7c8b 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_integer_known_value::GetIntegerKnownValueError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_integer_known_value::GetIntegerKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::integer::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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error, + crate::r#simple::types::integer::internaldafny::types::Error, >, ) -> crate::operation::get_integer_known_value::GetIntegerKnownValueError { // 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::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::integer::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_integer_known_value::GetIntegerKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs index 9f260381f..40db6820d 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_integer_known_value::GetIntegerKnownValueInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput::GetIntegerInput { + ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerInput::GetIntegerInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerInput, >, ) -> crate::operation::get_integer_known_value::GetIntegerKnownValueInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs index 2cf230efa..c122e6bee 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value/_get_integer_known_value_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_integer_known_value::GetIntegerKnownValueOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { + ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput::GetIntegerOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, + crate::r#simple::types::integer::internaldafny::types::GetIntegerOutput, >, ) -> crate::operation::get_integer_known_value::GetIntegerKnownValueOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs index 08cfc8bf4..360d19898 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/simple_integer_config/_simple_integer_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_integer_config::SimpleIntegerConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig, + crate::simple::types::integer::internaldafny::types::SimpleIntegerConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig::SimpleIntegerConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::integer::internaldafny::types::SimpleIntegerConfig::SimpleIntegerConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig, + crate::r#simple::types::integer::internaldafny::types::SimpleIntegerConfig, >, ) -> crate::types::simple_integer_config::SimpleIntegerConfig { crate::types::simple_integer_config::SimpleIntegerConfig {} diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..08623efb6 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2142 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_integer_config::SimpleIntegerConfig; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod integer { + pub mod internaldafny { + pub use crate::simple::types::integer::internaldafny::types::ISimpleTypesIntegerClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleIntegerConfig() -> ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::SimpleIntegerConfig, + > { + ::std::rc::Rc::new(crate::simple::types::integer::internaldafny::types::SimpleIntegerConfig::SimpleIntegerConfig {}) + } + pub fn SimpleInteger( + config: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::integer::internaldafny::SimpleIntegerClient, + >, + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::Error, + >, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::types::integer::internaldafny::SimpleIntegerClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::integer::internaldafny::SimpleIntegerClient::_allocate_object(); + crate::simple::types::integer::internaldafny::SimpleIntegerClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleIntegerImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleIntegerClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleIntegerClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::integer::internaldafny::SimpleIntegerClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::types::integer::internaldafny::SimpleIntegerClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesIntegerClient + for crate::simple::types::integer::internaldafny::SimpleIntegerClient + { + fn GetInteger(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleIntegerImpl_Compile::_default::GetInteger( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetIntegerKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleIntegerImpl_Compile::_default::GetIntegerKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::integer::internaldafny::SimpleIntegerClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::integer::internaldafny::types::ISimpleTypesIntegerClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.integer.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetIntegerInput { + GetIntegerInput { + value: ::std::rc::Rc>, + }, + } + + impl GetIntegerInput { + pub fn value( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetIntegerInput::GetIntegerInput { value } => value, + } + } + } + + impl Debug for GetIntegerInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetIntegerInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetIntegerInput::GetIntegerInput { value } => { + write!(_formatter, "simple.types.integer.internaldafny.types.GetIntegerInput.GetIntegerInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetIntegerInput {} + + impl Hash for GetIntegerInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetIntegerInput::GetIntegerInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetIntegerInput { + fn default() -> GetIntegerInput { + GetIntegerInput::GetIntegerInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetIntegerInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetIntegerOutput { + GetIntegerOutput { + value: ::std::rc::Rc>, + }, + } + + impl GetIntegerOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetIntegerOutput::GetIntegerOutput { value } => value, + } + } + } + + impl Debug for GetIntegerOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetIntegerOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetIntegerOutput::GetIntegerOutput { value } => { + write!(_formatter, "simple.types.integer.internaldafny.types.GetIntegerOutput.GetIntegerOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetIntegerOutput {} + + impl Hash for GetIntegerOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetIntegerOutput::GetIntegerOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetIntegerOutput { + fn default() -> GetIntegerOutput { + GetIntegerOutput::GetIntegerOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetIntegerOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleIntegerConfig { + SimpleIntegerConfig {}, + } + + impl SimpleIntegerConfig {} + + impl Debug for SimpleIntegerConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleIntegerConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleIntegerConfig::SimpleIntegerConfig {} => { + write!(_formatter, "simple.types.integer.internaldafny.types.SimpleIntegerConfig.SimpleIntegerConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleIntegerConfig {} + + impl Hash for SimpleIntegerConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleIntegerConfig::SimpleIntegerConfig {} => {} + } + } + } + + impl Default for SimpleIntegerConfig { + fn default() -> SimpleIntegerConfig { + SimpleIntegerConfig::SimpleIntegerConfig {} + } + } + + impl AsRef for &SimpleIntegerConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesIntegerClientCallHistory {} + + impl ISimpleTypesIntegerClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::integer::internaldafny::types::ISimpleTypesIntegerClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesIntegerClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetInteger(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetIntegerKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.integer.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.integer.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } + } +} +pub mod r#_SimpleIntegerImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetInteger( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !(::dafny_runtime::truncate!(::dafny_runtime::int!(0) - crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::INT32_MAX_LIMIT(), i32) <= input.value().UnwrapOr(&0) && input.value().UnwrapOr(&0) <= ::dafny_runtime::truncate!(crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::INT32_MAX_LIMIT() - ::dafny_runtime::int!(1), i32)) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::integer::internaldafny::types::GetIntegerOutput::GetIntegerOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetIntegerKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e00: i32 = input.value().UnwrapOr(&0); + let mut _e10: i32 = 20; + if !(_e00 == _e10) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::integer::internaldafny::types::GetIntegerOutput::GetIntegerOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::integer::internaldafny::types::GetIntegerOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleIntegerImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs index 52f7b049d..3cb49535a 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer.rs @@ -20,7 +20,7 @@ impl GetInteger { ::dafny_runtime::md!(client.dafny_client.clone()).GetInteger(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_integer::_get_integer_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs index 27fe320ff..06e0fa0cb 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/operation/get_integer_known_value.rs @@ -23,7 +23,7 @@ impl GetIntegerKnownValue { ::dafny_runtime::md!(client.dafny_client.clone()).GetInteger(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_integer_known_value::_get_integer_known_value_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch index c902d9681..a015cf77a 100644 --- a/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..ec6c3884 +index 00000000..0529ead1 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs @@ -0,0 +1,39 @@ @@ -10,7 +10,7 @@ index 00000000..ec6c3884 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..ec6c3884 + conf: crate::types::simple_long_config::SimpleLongConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dsmithylong_dinternaldafny::_default::SimpleLong( ++ crate::simple::types::smithylong::internaldafny::_default::SimpleLong( + &crate::conversions::simple_long_config::_simple_long_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -99,7 +99,7 @@ index 00000000..4ff5bcbc +pub mod simple_long_config; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs new file mode 100644 -index 00000000..3073a178 +index 00000000..59558ca1 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs @@ -0,0 +1,32 @@ @@ -110,21 +110,21 @@ index 00000000..3073a178 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_long::GetLongError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_long::GetLongError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithylong::internaldafny::types::Error, + >, +) -> crate::operation::get_long::GetLongError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithylong::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_long::GetLongError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -137,7 +137,7 @@ index 00000000..3073a178 +pub mod _get_long_output; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs new file mode 100644 -index 00000000..d0655d84 +index 00000000..83929597 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs @@ -0,0 +1,37 @@ @@ -146,13 +146,13 @@ index 00000000..d0655d84 +pub fn to_dafny( + value: crate::operation::get_long::GetLongInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput::GetLongInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongInput::GetLongInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -160,17 +160,17 @@ index 00000000..d0655d84 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, + >, +) -> crate::operation::get_long::GetLongInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -180,7 +180,7 @@ index 00000000..d0655d84 +} diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs new file mode 100644 -index 00000000..bb7c42ac +index 00000000..68ff34de --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs @@ -0,0 +1,37 @@ @@ -189,13 +189,13 @@ index 00000000..bb7c42ac +pub fn to_dafny( + value: crate::operation::get_long::GetLongOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput::GetLongOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -203,17 +203,17 @@ index 00000000..bb7c42ac +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, + >, +) -> crate::operation::get_long::GetLongOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -223,7 +223,7 @@ index 00000000..bb7c42ac +} diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs new file mode 100644 -index 00000000..bfc8c951 +index 00000000..f4c90a3a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs @@ -0,0 +1,32 @@ @@ -234,21 +234,21 @@ index 00000000..bfc8c951 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_long_known_value::GetLongKnownValueError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_long_known_value::GetLongKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithylong::internaldafny::types::Error, + >, +) -> crate::operation::get_long_known_value::GetLongKnownValueError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithylong::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_long_known_value::GetLongKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -261,7 +261,7 @@ index 00000000..bfc8c951 +pub mod _get_long_known_value_output; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs new file mode 100644 -index 00000000..79014df7 +index 00000000..aae39905 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs @@ -0,0 +1,37 @@ @@ -270,13 +270,13 @@ index 00000000..79014df7 +pub fn to_dafny( + value: crate::operation::get_long_known_value::GetLongKnownValueInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput::GetLongInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongInput::GetLongInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -284,17 +284,17 @@ index 00000000..79014df7 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, + >, +) -> crate::operation::get_long_known_value::GetLongKnownValueInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -304,7 +304,7 @@ index 00000000..79014df7 +} diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs new file mode 100644 -index 00000000..02deef90 +index 00000000..bdc927aa --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs @@ -0,0 +1,37 @@ @@ -313,13 +313,13 @@ index 00000000..02deef90 +pub fn to_dafny( + value: crate::operation::get_long_known_value::GetLongKnownValueOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput::GetLongOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -327,17 +327,17 @@ index 00000000..02deef90 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, ++ crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, + >, +) -> crate::operation::get_long_known_value::GetLongKnownValueOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -356,7 +356,7 @@ index 00000000..129c7eb4 +pub mod _simple_long_config; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs new file mode 100644 -index 00000000..7c88e816 +index 00000000..4bb610c4 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs @@ -0,0 +1,19 @@ @@ -366,15 +366,15 @@ index 00000000..7c88e816 +pub fn to_dafny( + value: crate::types::simple_long_config::SimpleLongConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig, ++ crate::simple::types::smithylong::internaldafny::types::SimpleLongConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig::SimpleLongConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::SimpleLongConfig::SimpleLongConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig, ++ crate::r#simple::types::smithylong::internaldafny::types::SimpleLongConfig, + >, +) -> crate::types::simple_long_config::SimpleLongConfig { + crate::types::simple_long_config::SimpleLongConfig {} @@ -431,6 +431,31 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs +index 383ec2da..dfb4f9de 100644 +--- b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,20 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_long_config::SimpleLongConfig; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..1248f583 @@ -471,7 +496,7 @@ index 00000000..93787200 +pub mod get_long_known_value; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs new file mode 100644 -index 00000000..fc47dede +index 00000000..44259e5b --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs @@ -0,0 +1,142 @@ @@ -496,7 +521,7 @@ index 00000000..fc47dede + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetLong(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok(crate::conversions::get_long::_get_long_output::from_dafny( + inner_result.value().clone(), @@ -823,7 +848,7 @@ index 00000000..cf89d6b3 +} diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs new file mode 100644 -index 00000000..a9fb5d0f +index 00000000..b434182d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs @@ -0,0 +1,145 @@ @@ -849,7 +874,7 @@ index 00000000..a9fb5d0f + let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetLong(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_long_known_value::_get_long_known_value_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/Cargo.toml index 5b13e1952..6fa3747d2 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs index ec6c3884f..0529ead1f 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_long_config::SimpleLongConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dsmithylong_dinternaldafny::_default::SimpleLong( + crate::simple::types::smithylong::internaldafny::_default::SimpleLong( &crate::conversions::simple_long_config::_simple_long_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs index 3073a1786..59558ca19 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_long::GetLongError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_long::GetLongError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithylong::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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithylong::internaldafny::types::Error, >, ) -> crate::operation::get_long::GetLongError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithylong::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_long::GetLongError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs index d0655d842..839295972 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_long::GetLongInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput::GetLongInput { + ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongInput::GetLongInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, >, ) -> crate::operation::get_long::GetLongInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs index bb7c42ac1..68ff34def 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long/_get_long_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_long::GetLongOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput::GetLongOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, >, ) -> crate::operation::get_long::GetLongOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs index bfc8c951d..f4c90a3a2 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_long_known_value::GetLongKnownValueError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_long_known_value::GetLongKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithylong::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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithylong::internaldafny::types::Error, >, ) -> crate::operation::get_long_known_value::GetLongKnownValueError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithylong::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_long_known_value::GetLongKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs index 79014df7f..aae399058 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_long_known_value::GetLongKnownValueInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: v }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(v) => crate::_Wrappers_Compile::Option::Some { value: v }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput::GetLongInput { + ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongInput::GetLongInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongInput, >, ) -> crate::operation::get_long_known_value::GetLongKnownValueInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs index 02deef904..bdc927aae 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value/_get_long_known_value_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_long_known_value::GetLongKnownValueOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::_Wrappers_Compile::Option::Some { value: b }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput::GetLongOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, + crate::r#simple::types::smithylong::internaldafny::types::GetLongOutput, >, ) -> crate::operation::get_long_known_value::GetLongKnownValueOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs index 7c88e816f..4bb610c4d 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/simple_long_config/_simple_long_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_long_config::SimpleLongConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig, + crate::simple::types::smithylong::internaldafny::types::SimpleLongConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig::SimpleLongConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::smithylong::internaldafny::types::SimpleLongConfig::SimpleLongConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig, + crate::r#simple::types::smithylong::internaldafny::types::SimpleLongConfig, >, ) -> crate::types::simple_long_config::SimpleLongConfig { crate::types::simple_long_config::SimpleLongConfig {} diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..dfb4f9de0 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2190 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_long_config::SimpleLongConfig; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod smithylong { + pub mod internaldafny { + pub use crate::simple::types::smithylong::internaldafny::types::ISimpleTypesLongClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleLongConfig() -> ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::SimpleLongConfig, + > { + ::std::rc::Rc::new(crate::simple::types::smithylong::internaldafny::types::SimpleLongConfig::SimpleLongConfig {}) + } + pub fn SimpleLong( + config: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::types::smithylong::internaldafny::SimpleLongClient, + >, + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::Error, + >, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::types::smithylong::internaldafny::SimpleLongClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::smithylong::internaldafny::SimpleLongClient::_allocate_object(); + crate::simple::types::smithylong::internaldafny::SimpleLongClient::_ctor( + &_nw1, + &::std::rc::Rc::new( + crate::r#_SimpleLongImpl_Compile::Config::Config {}, + ), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleLongClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleLongClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::smithylong::internaldafny::SimpleLongClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::types::smithylong::internaldafny::SimpleLongClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesLongClient for crate::simple::types::smithylong::internaldafny::SimpleLongClient { + fn GetLong(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleLongImpl_Compile::_default::GetLong( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetLongKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleLongImpl_Compile::_default::GetLongKnownValueTest( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::smithylong::internaldafny::SimpleLongClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::smithylong::internaldafny::types::ISimpleTypesLongClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.smithylong.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetLongInput { + GetLongInput { + value: ::std::rc::Rc>, + }, + } + + impl GetLongInput { + pub fn value( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetLongInput::GetLongInput { value } => value, + } + } + } + + impl Debug for GetLongInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetLongInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetLongInput::GetLongInput { value } => { + write!(_formatter, "simple.types.smithylong.internaldafny.types.GetLongInput.GetLongInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetLongInput {} + + impl Hash for GetLongInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetLongInput::GetLongInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetLongInput { + fn default() -> GetLongInput { + GetLongInput::GetLongInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetLongInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetLongOutput { + GetLongOutput { + value: ::std::rc::Rc>, + }, + } + + impl GetLongOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc> + { + match self { + GetLongOutput::GetLongOutput { value } => value, + } + } + } + + impl Debug for GetLongOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetLongOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetLongOutput::GetLongOutput { value } => { + write!(_formatter, "simple.types.smithylong.internaldafny.types.GetLongOutput.GetLongOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetLongOutput {} + + impl Hash for GetLongOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetLongOutput::GetLongOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetLongOutput { + fn default() -> GetLongOutput { + GetLongOutput::GetLongOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetLongOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleLongConfig { + SimpleLongConfig {}, + } + + impl SimpleLongConfig {} + + impl Debug for SimpleLongConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleLongConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleLongConfig::SimpleLongConfig {} => { + write!(_formatter, "simple.types.smithylong.internaldafny.types.SimpleLongConfig.SimpleLongConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleLongConfig {} + + impl Hash for SimpleLongConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleLongConfig::SimpleLongConfig {} => {} + } + } + } + + impl Default for SimpleLongConfig { + fn default() -> SimpleLongConfig { + SimpleLongConfig::SimpleLongConfig {} + } + } + + impl AsRef for &SimpleLongConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesLongClientCallHistory {} + + impl ISimpleTypesLongClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::smithylong::internaldafny::types::ISimpleTypesLongClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesLongClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetLong(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetLongKnownValueTest(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.smithylong.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.smithylong.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::Error, + >; + } + } + } + } +} +pub mod r#_SimpleLongImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetLong( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongOutput, + >, + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::Error, + >, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleLongImpl_Compile::_default::ValidateLongType( + input.value().value().clone(), + ); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithylong::internaldafny::types::GetLongOutput::GetLongOutput { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleLongImpl_Compile::_default::ValidateLongType( + res.value().value().clone(), + ); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetLongKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongOutput, + >, + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::Error, + >, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleLongImpl_Compile::_default::ValidateLongType( + input.value().value().clone(), + ); + let mut _e00: i64 = input.value().value().clone(); + let mut _e10: i64 = 33; + if !(_e00 == _e10) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithylong::internaldafny::types::GetLongOutput::GetLongOutput { + value: input.value().clone() + }); + if !matches!( + res.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + crate::r#_SimpleLongImpl_Compile::_default::ValidateLongType( + res.value().value().clone(), + ); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithylong::internaldafny::types::GetLongOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn ValidateLongType(input: i64) -> () { + if input >= 0 { + if input >= ::dafny_runtime::truncate!(crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::INT32_MAX_LIMIT(), i64) { + return (); + }; + if !(0 < input + ::dafny_runtime::truncate!(crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::INT32_MAX_LIMIT(), i64)) { + panic!("Halt") + } + } else { + if input < 0 { + if input < 0 - ::dafny_runtime::truncate!(crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::INT32_MAX_LIMIT(), i64) { + return (); + }; + if !(input + (0 - ::dafny_runtime::truncate!(crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::INT32_MAX_LIMIT(), i64)) < 0) { + panic!("Halt") + } + } else { + if !false { + panic!("Halt") + } + } + }; + return (); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleLongImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs index fc47dede6..44259e5ba 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long.rs @@ -19,7 +19,7 @@ impl GetLong { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetLong(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok(crate::conversions::get_long::_get_long_output::from_dafny( inner_result.value().clone(), diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs index a9fb5d0f3..b434182d0 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/operation/get_long_known_value.rs @@ -20,7 +20,7 @@ impl GetLongKnownValue { let inner_result = ::dafny_runtime::md!(client.dafny_client.clone()).GetLong(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_long_known_value::_get_long_known_value_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch index bda9931db..346bd03b1 100644 --- a/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..c85e6fed +index 00000000..fc54e838 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs @@ -0,0 +1,43 @@ @@ -10,7 +10,7 @@ index 00000000..c85e6fed + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -22,12 +22,12 @@ index 00000000..c85e6fed + // If this service had any configuration properties, + // they would need converting here too. + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dsmithystring_dinternaldafny::_default::SimpleString( ++ crate::simple::types::smithystring::internaldafny::_default::SimpleString( + &crate::conversions::simple_string_config::_simple_string_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -149,7 +149,7 @@ index 00000000..0c2b4cf1 +pub mod simple_string_config; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs new file mode 100644 -index 00000000..a2df3f51 +index 00000000..4a11ce93 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs @@ -0,0 +1,33 @@ @@ -160,22 +160,22 @@ index 00000000..a2df3f51 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_string::GetStringError, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + match value { + crate::operation::get_string::GetStringError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithystring::internaldafny::types::Error, + >, +) -> crate::operation::get_string::GetStringError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithystring::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_string::GetStringError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -188,7 +188,7 @@ index 00000000..a2df3f51 +pub mod _get_string_output; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs new file mode 100644 -index 00000000..ec391cc1 +index 00000000..2b7ac1e6 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs @@ -0,0 +1,43 @@ @@ -197,15 +197,15 @@ index 00000000..ec391cc1 +pub fn to_dafny( + value: crate::operation::get_string::GetStringInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(s) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput::GetStringInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringInput::GetStringInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -213,12 +213,12 @@ index 00000000..ec391cc1 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, + >, +) -> crate::operation::get_string::GetStringInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -227,7 +227,7 @@ index 00000000..ec391cc1 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -237,7 +237,7 @@ index 00000000..ec391cc1 +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs new file mode 100644 -index 00000000..ac546e50 +index 00000000..66cfd606 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs @@ -0,0 +1,41 @@ @@ -246,26 +246,26 @@ index 00000000..ac546e50 +pub fn to_dafny( + value: crate::operation::get_string::GetStringOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(s) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: ::std::rc::Rc, ++ dafny_value: ::std::rc::Rc, +) -> crate::operation::get_string::GetStringOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -274,7 +274,7 @@ index 00000000..ac546e50 + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -284,7 +284,7 @@ index 00000000..ac546e50 +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs new file mode 100644 -index 00000000..99b1bf78 +index 00000000..680fd6ad --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs @@ -0,0 +1,33 @@ @@ -295,22 +295,22 @@ index 00000000..99b1bf78 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_string_known_value::GetStringKnownValueError, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + match value { + crate::operation::get_string_known_value::GetStringKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithystring::internaldafny::types::Error, + >, +) -> crate::operation::get_string_known_value::GetStringKnownValueError { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithystring::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_string_known_value::GetStringKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -323,7 +323,7 @@ index 00000000..99b1bf78 +pub mod _get_string_known_value_output; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs new file mode 100644 -index 00000000..d27ff4ee +index 00000000..2a638911 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs @@ -0,0 +1,43 @@ @@ -332,15 +332,15 @@ index 00000000..d27ff4ee +pub fn to_dafny( + value: crate::operation::get_string_known_value::GetStringKnownValueInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(s) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput::GetStringInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringInput::GetStringInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -348,12 +348,12 @@ index 00000000..d27ff4ee +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, + >, +) -> crate::operation::get_string_known_value::GetStringKnownValueInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -362,7 +362,7 @@ index 00000000..d27ff4ee + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -372,7 +372,7 @@ index 00000000..d27ff4ee +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs new file mode 100644 -index 00000000..86278e6f +index 00000000..00f53c20 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs @@ -0,0 +1,41 @@ @@ -381,26 +381,26 @@ index 00000000..86278e6f +pub fn to_dafny( + value: crate::operation::get_string_known_value::GetStringKnownValueOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(s) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: ::std::rc::Rc, ++ dafny_value: ::std::rc::Rc, +) -> crate::operation::get_string_known_value::GetStringKnownValueOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -409,7 +409,7 @@ index 00000000..86278e6f + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -419,7 +419,7 @@ index 00000000..86278e6f +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs new file mode 100644 -index 00000000..5b983954 +index 00000000..1f3d581e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs @@ -0,0 +1,33 @@ @@ -430,22 +430,22 @@ index 00000000..5b983954 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_string_utf8::GetStringUTF8Error, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + match value { + crate::operation::get_string_utf8::GetStringUTF8Error::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::smithystring::internaldafny::types::Error, + >, +) -> crate::operation::get_string_utf8::GetStringUTF8Error { + // 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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithystring::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_string_utf8::GetStringUTF8Error::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -458,7 +458,7 @@ index 00000000..5b983954 +pub mod _get_string_utf8_output; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs new file mode 100644 -index 00000000..94bece3b +index 00000000..52a7039e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs @@ -0,0 +1,43 @@ @@ -467,15 +467,15 @@ index 00000000..94bece3b +pub fn to_dafny( + value: crate::operation::get_string_utf8::GetStringUTF8Input, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(s) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput::GetStringInput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringInput::GetStringInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -483,12 +483,12 @@ index 00000000..94bece3b +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, + >, +) -> crate::operation::get_string_utf8::GetStringUTF8Input { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -497,7 +497,7 @@ index 00000000..94bece3b + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -507,7 +507,7 @@ index 00000000..94bece3b +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs new file mode 100644 -index 00000000..13fa503a +index 00000000..a07f35ea --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs @@ -0,0 +1,41 @@ @@ -516,26 +516,26 @@ index 00000000..13fa503a +pub fn to_dafny( + value: crate::operation::get_string_utf8::GetStringUTF8Output, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, ++ crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(s) => crate::_Wrappers_Compile::Option::Some { + value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: ::std::rc::Rc, ++ dafny_value: ::std::rc::Rc, +) -> crate::operation::get_string_utf8::GetStringUTF8Output { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -544,7 +544,7 @@ index 00000000..13fa503a + ) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -563,7 +563,7 @@ index 00000000..286313ae +pub mod _simple_string_config; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs new file mode 100644 -index 00000000..e2e8a616 +index 00000000..95d7da8d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs @@ -0,0 +1,19 @@ @@ -573,15 +573,15 @@ index 00000000..e2e8a616 +pub fn to_dafny( + value: crate::types::simple_string_config::SimpleStringConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, ++ crate::simple::types::smithystring::internaldafny::types::SimpleStringConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig::SimpleStringConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::SimpleStringConfig::SimpleStringConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, ++ crate::r#simple::types::smithystring::internaldafny::types::SimpleStringConfig, + >, +) -> crate::types::simple_string_config::SimpleStringConfig { + crate::types::simple_string_config::SimpleStringConfig {} @@ -638,12 +638,38 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs +index 2f103858..25eb73a1 100644 +--- b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,21 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_string_config::SimpleStringConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..3340c2d9 +index 00000000..4315dacf --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs -@@ -0,0 +1,19 @@ +@@ -0,0 +1,17 @@ +#![allow(deprecated)] + +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. @@ -659,8 +685,6 @@ index 00000000..3340c2d9 + +mod conversions; + -+pub mod implementation_from_dafny; -+ +pub use client::Client; +pub use types::simple_string_config::SimpleStringConfig; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation.rs @@ -681,7 +705,7 @@ index 00000000..af6d5f9c +pub mod get_string_utf8; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs new file mode 100644 -index 00000000..10dc7758 +index 00000000..813f2280 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs @@ -0,0 +1,145 @@ @@ -707,7 +731,7 @@ index 00000000..10dc7758 + ::dafny_runtime::md!(client.dafny_client.clone()).GetString(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_string::_get_string_output::from_dafny( @@ -1034,7 +1058,7 @@ index 00000000..ec32b2e2 +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs new file mode 100644 -index 00000000..58d58594 +index 00000000..bae4c3d9 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs @@ -0,0 +1,146 @@ @@ -1063,7 +1087,7 @@ index 00000000..58d58594 + ::dafny_runtime::md!(client.dafny_client.clone()).GetStringUTF8(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok(crate::conversions::get_string_known_value::_get_string_known_value_output::from_dafny(inner_result.value().clone())) + } else { @@ -1400,7 +1424,7 @@ index 00000000..82b4c7fb +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs new file mode 100644 -index 00000000..08e8cb25 +index 00000000..966f2152 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs @@ -0,0 +1,146 @@ @@ -1427,7 +1451,7 @@ index 00000000..08e8cb25 + ::dafny_runtime::md!(client.dafny_client.clone()).GetStringUTF8(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_string_utf8::_get_string_utf8_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleString/runtimes/rust/Cargo.toml index 1e29efa6a..3f66bd6aa 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" -features = ["full"] \ No newline at end of file +features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs index c85e6fede..fc54e838c 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -16,12 +16,12 @@ impl Client { // If this service had any configuration properties, // they would need converting here too. let inner = - crate::implementation_from_dafny::_simple_dtypes_dsmithystring_dinternaldafny::_default::SimpleString( + crate::simple::types::smithystring::internaldafny::_default::SimpleString( &crate::conversions::simple_string_config::_simple_string_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs index a2df3f519..4a11ce932 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs @@ -5,22 +5,22 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_string::GetStringError, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { match value { crate::operation::get_string::GetStringError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithystring::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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithystring::internaldafny::types::Error, >, ) -> crate::operation::get_string::GetStringError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithystring::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_string::GetStringError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs index ec391cc13..2b7ac1e68 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_input.rs @@ -3,15 +3,15 @@ pub fn to_dafny( value: crate::operation::get_string::GetStringInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput::GetStringInput { + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringInput::GetStringInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,12 +19,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, >, ) -> crate::operation::get_string::GetStringInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -33,7 +33,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs index ac546e50e..66cfd6061 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string/_get_string_output.rs @@ -3,26 +3,26 @@ pub fn to_dafny( value: crate::operation::get_string::GetStringOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { value: ::std::rc::Rc::new(dafny_value) }) } #[allow(dead_code)] pub fn from_dafny( - dafny_value: ::std::rc::Rc, + dafny_value: ::std::rc::Rc, ) -> crate::operation::get_string::GetStringOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -31,7 +31,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs index 99b1bf78a..680fd6ad8 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs @@ -5,22 +5,22 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_string_known_value::GetStringKnownValueError, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { match value { crate::operation::get_string_known_value::GetStringKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithystring::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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithystring::internaldafny::types::Error, >, ) -> crate::operation::get_string_known_value::GetStringKnownValueError { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithystring::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_string_known_value::GetStringKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs index d27ff4eee..2a638911d 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_input.rs @@ -3,15 +3,15 @@ pub fn to_dafny( value: crate::operation::get_string_known_value::GetStringKnownValueInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput::GetStringInput { + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringInput::GetStringInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,12 +19,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, >, ) -> crate::operation::get_string_known_value::GetStringKnownValueInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -33,7 +33,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs index 86278e6ff..00f53c20b 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value/_get_string_known_value_output.rs @@ -3,26 +3,26 @@ pub fn to_dafny( value: crate::operation::get_string_known_value::GetStringKnownValueOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { value: ::std::rc::Rc::new(dafny_value) }) } #[allow(dead_code)] pub fn from_dafny( - dafny_value: ::std::rc::Rc, + dafny_value: ::std::rc::Rc, ) -> crate::operation::get_string_known_value::GetStringKnownValueOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -31,7 +31,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs index 5b9839541..1f3d581ec 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs @@ -5,22 +5,22 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_string_utf8::GetStringUTF8Error, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { match value { crate::operation::get_string_utf8::GetStringUTF8Error::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::smithystring::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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, + crate::r#simple::types::smithystring::internaldafny::types::Error, >, ) -> crate::operation::get_string_utf8::GetStringUTF8Error { // 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::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::smithystring::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_string_utf8::GetStringUTF8Error::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs index 94bece3b4..52a7039e1 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_input.rs @@ -3,15 +3,15 @@ pub fn to_dafny( value: crate::operation::get_string_utf8::GetStringUTF8Input, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput::GetStringInput { + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringInput::GetStringInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,12 +19,12 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringInput, >, ) -> crate::operation::get_string_utf8::GetStringUTF8Input { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -33,7 +33,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs index 13fa503a5..a07f35ea4 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8/_get_string_utf8_output.rs @@ -3,26 +3,26 @@ pub fn to_dafny( value: crate::operation::get_string_utf8::GetStringUTF8Output, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, + crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(s) => crate::_Wrappers_Compile::Option::Some { value: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { value: ::std::rc::Rc::new(dafny_value) }) } #[allow(dead_code)] pub fn from_dafny( - dafny_value: ::std::rc::Rc, + dafny_value: ::std::rc::Rc, ) -> crate::operation::get_string_utf8::GetStringUTF8Output { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( @@ -31,7 +31,7 @@ pub fn from_dafny( ) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs index e2e8a616e..95d7da8d4 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/simple_string_config/_simple_string_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_string_config::SimpleStringConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, + crate::simple::types::smithystring::internaldafny::types::SimpleStringConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig::SimpleStringConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::smithystring::internaldafny::types::SimpleStringConfig::SimpleStringConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, + crate::r#simple::types::smithystring::internaldafny::types::SimpleStringConfig, >, ) -> crate::types::simple_string_config::SimpleStringConfig { crate::types::simple_string_config::SimpleStringConfig {} diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..25eb73a19 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2158 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_string_config::SimpleStringConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod smithystring { + pub mod internaldafny { + pub use crate::simple::types::smithystring::internaldafny::types::ISimpleTypesStringClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleStringConfig() -> ::std::rc::Rc{ + ::std::rc::Rc::new(crate::simple::types::smithystring::internaldafny::types::SimpleStringConfig::SimpleStringConfig {}) + } + pub fn SimpleString(config: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::smithystring::internaldafny::SimpleStringClient::_allocate_object(); + crate::simple::types::smithystring::internaldafny::SimpleStringClient::_ctor(&_nw1, &::std::rc::Rc::new(crate::r#_SimpleStringImpl_Compile::Config::Config {})); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleStringClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleStringClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::smithystring::internaldafny::SimpleStringClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject + for crate::simple::types::smithystring::internaldafny::SimpleStringClient + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesStringClient + for crate::simple::types::smithystring::internaldafny::SimpleStringClient + { + fn GetString(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleStringImpl_Compile::_default::GetString( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetStringKnownValue(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleStringImpl_Compile::_default::GetStringKnownValue( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + fn GetStringUTF8(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleStringImpl_Compile::_default::GetStringUTF8( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::smithystring::internaldafny::SimpleStringClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::smithystring::internaldafny::types::ISimpleTypesStringClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.smithystring.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetStringInput { + GetStringInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetStringInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetStringInput::GetStringInput { value } => value, + } + } + } + + impl Debug for GetStringInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetStringInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetStringInput::GetStringInput { value } => { + write!(_formatter, "simple.types.smithystring.internaldafny.types.GetStringInput.GetStringInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetStringInput {} + + impl Hash for GetStringInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetStringInput::GetStringInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetStringInput { + fn default() -> GetStringInput { + GetStringInput::GetStringInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetStringInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetStringOutput { + GetStringOutput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetStringOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetStringOutput::GetStringOutput { value } => value, + } + } + } + + impl Debug for GetStringOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetStringOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetStringOutput::GetStringOutput { value } => { + write!(_formatter, "simple.types.smithystring.internaldafny.types.GetStringOutput.GetStringOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetStringOutput {} + + impl Hash for GetStringOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetStringOutput::GetStringOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetStringOutput { + fn default() -> GetStringOutput { + GetStringOutput::GetStringOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetStringOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleStringConfig { + SimpleStringConfig {}, + } + + impl SimpleStringConfig {} + + impl Debug for SimpleStringConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleStringConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleStringConfig::SimpleStringConfig {} => { + write!(_formatter, "simple.types.smithystring.internaldafny.types.SimpleStringConfig.SimpleStringConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleStringConfig {} + + impl Hash for SimpleStringConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleStringConfig::SimpleStringConfig {} => {} + } + } + } + + impl Default for SimpleStringConfig { + fn default() -> SimpleStringConfig { + SimpleStringConfig::SimpleStringConfig {} + } + } + + impl AsRef for &SimpleStringConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesStringClientCallHistory {} + + impl ISimpleTypesStringClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::smithystring::internaldafny::types::ISimpleTypesStringClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesStringClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetString(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetStringKnownValue(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetStringUTF8(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.smithystring.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!(_formatter, "simple.types.smithystring.internaldafny.types.Error.Opaque(")?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::Error, + >; + } + } + } + } +} +pub mod r#_SimpleStringImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetString( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetStringKnownValue( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e00: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + input.value().value().clone(); + let mut _e10: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::string_utf16_of("TEST_SIMPLE_STRING_KNOWN_VALUE"); + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetStringUTF8( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + if !matches!( + input.value().as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::smithystring::internaldafny::types::GetStringOutput::GetStringOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::smithystring::internaldafny::types::GetStringOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleStringImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs index 3340c2d9f..4315dacf4 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs @@ -13,7 +13,5 @@ pub mod operation; mod conversions; -pub mod implementation_from_dafny; - pub use client::Client; pub use types::simple_string_config::SimpleStringConfig; diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs index 10dc7758a..813f2280e 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs @@ -20,7 +20,7 @@ impl GetString { ::dafny_runtime::md!(client.dafny_client.clone()).GetString(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_string::_get_string_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs index 58d585940..bae4c3d99 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs @@ -23,7 +23,7 @@ impl GetStringKnownValue { ::dafny_runtime::md!(client.dafny_client.clone()).GetStringUTF8(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok(crate::conversions::get_string_known_value::_get_string_known_value_output::from_dafny(inner_result.value().clone())) } else { diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs index 08e8cb254..966f21525 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs @@ -21,7 +21,7 @@ impl GetStringUTF8 { ::dafny_runtime::md!(client.dafny_client.clone()).GetStringUTF8(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_string_utf8::_get_string_utf8_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleTimestamp/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleTimestamp/codegen-patches/rust/dafny-4.5.0.patch index 689290153..814de41f4 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleTimestamp/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..c6ba180a +index 00000000..1691812f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -10,7 +10,7 @@ index 00000000..c6ba180a + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..c6ba180a + conf: crate::types::simple_timestamp_config::SimpleTimestampConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dtimestamp_dinternaldafny::_default::SimpleTimestamp( ++ crate::simple::types::timestamp::internaldafny::_default::SimpleTimestamp( + &crate::conversions::simple_timestamp_config::_simple_timestamp_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -74,7 +74,7 @@ index 00000000..6c19c684 +pub mod simple_timestamp_config; diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs new file mode 100644 -index 00000000..faf18468 +index 00000000..64d9cf3a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs @@ -0,0 +1,33 @@ @@ -85,22 +85,22 @@ index 00000000..faf18468 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_timestamp::GetTimestampError, -+) -> ::std::rc::Rc ++) -> ::std::rc::Rc +{ + match value { + crate::operation::get_timestamp::GetTimestampError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::r#simple::types::timestamp::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::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error, ++ crate::r#simple::types::timestamp::internaldafny::types::Error, + >, +) -> crate::operation::get_timestamp::GetTimestampError { + // 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::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::r#simple::types::timestamp::internaldafny::types::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_timestamp::GetTimestampError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -113,22 +113,22 @@ index 00000000..faf18468 +pub mod _get_timestamp_output; diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs new file mode 100644 -index 00000000..eed8f2f3 +index 00000000..ec1fde89 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs -@@ -0,0 +1,40 @@ +@@ -0,0 +1,39 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_timestamp::GetTimestampInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, ++ crate::r#simple::types::timestamp::internaldafny::types::GetTimestampInput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput::GetTimestampInput { ++ ::std::rc::Rc::new(crate::r#simple::types::timestamp::internaldafny::types::GetTimestampInput::GetTimestampInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -136,15 +136,15 @@ index 00000000..eed8f2f3 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, ++ crate::r#simple::types::timestamp::internaldafny::types::GetTimestampInput, + >, +) -> Result< + crate::operation::get_timestamp::GetTimestampInput, + aws_smithy_types::date_time::DateTimeParseError, +> { + let value = match dafny_value.value().as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::None {} => None, ++ crate::_Wrappers_Compile::Option::Some { value } => { + let value = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value); + let value = ::aws_smithy_types::DateTime::from_str( + &value, @@ -152,29 +152,28 @@ index 00000000..eed8f2f3 + )?; + Some(value) + } -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + }; + + Ok(crate::operation::get_timestamp::GetTimestampInput { value }) +} diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs new file mode 100644 -index 00000000..7b170a68 +index 00000000..958069da --- /dev/null +++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs -@@ -0,0 +1,40 @@ +@@ -0,0 +1,39 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_timestamp::GetTimestampOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, ++ crate::r#simple::types::timestamp::internaldafny::types::GetTimestampOutput, +> { + let dafny_value = match value.value { -+ Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(s) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput::GetTimestampOutput { ++ ::std::rc::Rc::new(crate::r#simple::types::timestamp::internaldafny::types::GetTimestampOutput::GetTimestampOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -182,15 +181,15 @@ index 00000000..7b170a68 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, ++ crate::r#simple::types::timestamp::internaldafny::types::GetTimestampOutput, + >, +) -> Result< + crate::operation::get_timestamp::GetTimestampOutput, + aws_smithy_types::date_time::DateTimeParseError, +> { + let value = match dafny_value.value().as_ref() { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => None, -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::None {} => None, ++ crate::_Wrappers_Compile::Option::Some { value } => { + let value = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value); + let value = ::aws_smithy_types::DateTime::from_str( + &value, @@ -198,7 +197,6 @@ index 00000000..7b170a68 + )?; + Some(value) + } -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), + }; + + Ok(crate::operation::get_timestamp::GetTimestampOutput { value }) @@ -214,7 +212,7 @@ index 00000000..3ab14490 +pub mod _simple_timestamp_config; diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs new file mode 100644 -index 00000000..e63d9f57 +index 00000000..7a6ad17f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs @@ -0,0 +1,19 @@ @@ -224,15 +222,15 @@ index 00000000..e63d9f57 +pub fn to_dafny( + value: crate::types::simple_timestamp_config::SimpleTimestampConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig, ++ crate::simple::types::timestamp::internaldafny::types::SimpleTimestampConfig, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig::SimpleTimestampConfig {}) ++ ::std::rc::Rc::new(crate::r#simple::types::timestamp::internaldafny::types::SimpleTimestampConfig::SimpleTimestampConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig, ++ crate::r#simple::types::timestamp::internaldafny::types::SimpleTimestampConfig, + >, +) -> crate::types::simple_timestamp_config::SimpleTimestampConfig { + crate::types::simple_timestamp_config::SimpleTimestampConfig {} @@ -289,6 +287,32 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs +index 61147902..f16e01c9 100644 +--- b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,21 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_timestamp_config::SimpleTimestampConfig; ++ ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..4e55b724 @@ -326,7 +350,7 @@ index 00000000..14ae6ca5 +pub mod get_timestamp; diff --git b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs new file mode 100644 -index 00000000..099c8377 +index 00000000..27f406c7 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs @@ -0,0 +1,144 @@ @@ -352,7 +376,7 @@ index 00000000..099c8377 + ::dafny_runtime::md!(client.dafny_client.clone()).GetTimestamp(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + crate::conversions::get_timestamp::_get_timestamp_output::from_dafny( + inner_result.value().clone(), diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/Cargo.toml index b7bd77a8f..94927ac48 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/Cargo.toml @@ -7,10 +7,12 @@ edition = "2021" [dependencies] dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} aws-smithy-runtime = { version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = { version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" [dev-dependencies] tokio = { version = "1.26.0", features = ["full"] } + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs index c6ba180a9..1691812f1 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_timestamp_config::SimpleTimestampConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dtimestamp_dinternaldafny::_default::SimpleTimestamp( + crate::simple::types::timestamp::internaldafny::_default::SimpleTimestamp( &crate::conversions::simple_timestamp_config::_simple_timestamp_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs index faf184689..64d9cf3a1 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs @@ -5,22 +5,22 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_timestamp::GetTimestampError, -) -> ::std::rc::Rc +) -> ::std::rc::Rc { match value { crate::operation::get_timestamp::GetTimestampError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::r#simple::types::timestamp::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::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error, + crate::r#simple::types::timestamp::internaldafny::types::Error, >, ) -> crate::operation::get_timestamp::GetTimestampError { // 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::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::r#simple::types::timestamp::internaldafny::types::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_timestamp::GetTimestampError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs index eed8f2f3c..ec1fde893 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_timestamp::GetTimestampInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, + crate::r#simple::types::timestamp::internaldafny::types::GetTimestampInput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput::GetTimestampInput { + ::std::rc::Rc::new(crate::r#simple::types::timestamp::internaldafny::types::GetTimestampInput::GetTimestampInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,15 +17,15 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, + crate::r#simple::types::timestamp::internaldafny::types::GetTimestampInput, >, ) -> Result< crate::operation::get_timestamp::GetTimestampInput, aws_smithy_types::date_time::DateTimeParseError, > { let value = match dafny_value.value().as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::None {} => None, + crate::_Wrappers_Compile::Option::Some { value } => { let value = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value); let value = ::aws_smithy_types::DateTime::from_str( &value, @@ -33,7 +33,6 @@ pub fn from_dafny( )?; Some(value) } - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), }; Ok(crate::operation::get_timestamp::GetTimestampInput { value }) diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs index 7b170a683..958069da0 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp/_get_timestamp_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_timestamp::GetTimestampOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, + crate::r#simple::types::timestamp::internaldafny::types::GetTimestampOutput, > { let dafny_value = match value.value { - Some(s) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(s) => crate::_Wrappers_Compile::Option::Some { value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s.to_string()) }, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput::GetTimestampOutput { + ::std::rc::Rc::new(crate::r#simple::types::timestamp::internaldafny::types::GetTimestampOutput::GetTimestampOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,15 +17,15 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, + crate::r#simple::types::timestamp::internaldafny::types::GetTimestampOutput, >, ) -> Result< crate::operation::get_timestamp::GetTimestampOutput, aws_smithy_types::date_time::DateTimeParseError, > { let value = match dafny_value.value().as_ref() { - crate::implementation_from_dafny::_Wrappers_Compile::Option::None {} => None, - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::None {} => None, + crate::_Wrappers_Compile::Option::Some { value } => { let value = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(&value); let value = ::aws_smithy_types::DateTime::from_str( &value, @@ -33,7 +33,6 @@ pub fn from_dafny( )?; Some(value) } - crate::implementation_from_dafny::_Wrappers_Compile::Option::_PhantomVariant(_) => unreachable!(), }; Ok(crate::operation::get_timestamp::GetTimestampOutput { value }) diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs index e63d9f57d..7a6ad17f9 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/simple_timestamp_config/_simple_timestamp_config.rs @@ -4,15 +4,15 @@ pub fn to_dafny( value: crate::types::simple_timestamp_config::SimpleTimestampConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig, + crate::simple::types::timestamp::internaldafny::types::SimpleTimestampConfig, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig::SimpleTimestampConfig {}) + ::std::rc::Rc::new(crate::r#simple::types::timestamp::internaldafny::types::SimpleTimestampConfig::SimpleTimestampConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig, + crate::r#simple::types::timestamp::internaldafny::types::SimpleTimestampConfig, >, ) -> crate::types::simple_timestamp_config::SimpleTimestampConfig { crate::types::simple_timestamp_config::SimpleTimestampConfig {} diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..f16e01c9a --- /dev/null +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2044 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_timestamp_config::SimpleTimestampConfig; + + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod types { + pub mod timestamp { + pub mod internaldafny { + pub use crate::simple::types::timestamp::internaldafny::types::ISimpleTypesTimestampClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleTimestampConfig() -> ::std::rc::Rc{ + ::std::rc::Rc::new(crate::simple::types::timestamp::internaldafny::types::SimpleTimestampConfig::SimpleTimestampConfig {}) + } + pub fn SimpleTimestamp(config: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut _nw1: ::dafny_runtime::Object = crate::simple::types::timestamp::internaldafny::SimpleTimestampClient::_allocate_object(); + crate::simple::types::timestamp::internaldafny::SimpleTimestampClient::_ctor(&_nw1, &::std::rc::Rc::new(crate::r#_SimpleTypesTimestampImpl_Compile::Config::Config {})); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.read() + })); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleTimestampClient { + pub r#__i_config: + ::std::rc::Rc, + } + + impl SimpleTimestampClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::types::timestamp::internaldafny::SimpleTimestampClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config( + &self, + ) -> ::std::rc::Rc + { + self.r#__i_config.clone() + } + } + + impl UpcastObject + for crate::simple::types::timestamp::internaldafny::SimpleTimestampClient + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleTypesTimestampClient + for crate::simple::types::timestamp::internaldafny::SimpleTimestampClient + { + fn GetTimestamp(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleTypesTimestampImpl_Compile::_default::GetTimestamp( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::types::timestamp::internaldafny::SimpleTimestampClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::types::timestamp::internaldafny::types::ISimpleTypesTimestampClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.types.timestamp.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetTimestampInput { + GetTimestampInput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetTimestampInput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetTimestampInput::GetTimestampInput { value } => value, + } + } + } + + impl Debug for GetTimestampInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetTimestampInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetTimestampInput::GetTimestampInput { value } => { + write!(_formatter, "simple.types.timestamp.internaldafny.types.GetTimestampInput.GetTimestampInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetTimestampInput {} + + impl Hash for GetTimestampInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetTimestampInput::GetTimestampInput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetTimestampInput { + fn default() -> GetTimestampInput { + GetTimestampInput::GetTimestampInput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetTimestampInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetTimestampOutput { + GetTimestampOutput { + value: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + }, + } + + impl GetTimestampOutput { + pub fn value( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetTimestampOutput::GetTimestampOutput { value } => value, + } + } + } + + impl Debug for GetTimestampOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetTimestampOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetTimestampOutput::GetTimestampOutput { value } => { + write!(_formatter, "simple.types.timestamp.internaldafny.types.GetTimestampOutput.GetTimestampOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + value, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetTimestampOutput {} + + impl Hash for GetTimestampOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetTimestampOutput::GetTimestampOutput { value } => { + ::std::hash::Hash::hash(value, _state) + } + } + } + } + + impl Default for GetTimestampOutput { + fn default() -> GetTimestampOutput { + GetTimestampOutput::GetTimestampOutput { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetTimestampOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleTimestampConfig { + SimpleTimestampConfig {}, + } + + impl SimpleTimestampConfig {} + + impl Debug for SimpleTimestampConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleTimestampConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleTimestampConfig::SimpleTimestampConfig {} => { + write!(_formatter, "simple.types.timestamp.internaldafny.types.SimpleTimestampConfig.SimpleTimestampConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleTimestampConfig {} + + impl Hash for SimpleTimestampConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleTimestampConfig::SimpleTimestampConfig {} => {} + } + } + } + + impl Default for SimpleTimestampConfig { + fn default() -> SimpleTimestampConfig { + SimpleTimestampConfig::SimpleTimestampConfig {} + } + } + + impl AsRef for &SimpleTimestampConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesTimestampClientCallHistory {} + + impl ISimpleTypesTimestampClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::types::timestamp::internaldafny::types::ISimpleTypesTimestampClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait ISimpleTypesTimestampClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn GetTimestamp(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::timestamp::internaldafny::types::Error, + >, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc< + crate::simple::types::timestamp::internaldafny::types::Error, + >, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "simple.types.timestamp.internaldafny.types.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + list, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.types.timestamp.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } + } +} +pub mod r#_SimpleTypesTimestampImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetTimestamp( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::types::timestamp::internaldafny::types::GetTimestampInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::types::timestamp::internaldafny::types::GetTimestampOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::types::timestamp::internaldafny::types::GetTimestampOutput::GetTimestampOutput { + value: input.value().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::types::timestamp::internaldafny::types::GetTimestampOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleTypesTimestampImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs index 099c83775..27f406c72 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/operation/get_timestamp.rs @@ -20,7 +20,7 @@ impl GetTimestamp { ::dafny_runtime::md!(client.dafny_client.clone()).GetTimestamp(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { crate::conversions::get_timestamp::_get_timestamp_output::from_dafny( inner_result.value().clone(), diff --git a/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch index 513782337..ef1adc342 100644 --- a/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Union/runtimes/rust/src/client.rs a/TestModels/Union/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..f53a57ea +index 00000000..437b70f3 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/client.rs @@ -0,0 +1,40 @@ @@ -11,7 +11,7 @@ index 00000000..f53a57ea +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { + pub(crate) dafny_client: ::dafny_runtime::Object< -+ dyn crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, ++ dyn crate::r#simple::union::internaldafny::types::ISimpleUnionClient, + >, +} + @@ -21,12 +21,12 @@ index 00000000..f53a57ea + pub fn from_conf( + conf: crate::types::simple_union_config::SimpleUnionConfig, + ) -> Result { -+ let inner = crate::implementation_from_dafny::_simple_dunion_dinternaldafny::_default::SimpleUnion( ++ let inner = crate::simple::union::internaldafny::_default::SimpleUnion( + &crate::conversions::simple_union_config::_simple_union_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -102,7 +102,7 @@ index 00000000..375f610e +pub mod simple_union_config; diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs new file mode 100644 -index 00000000..bb849ee9 +index 00000000..d8ba15d7 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs @@ -0,0 +1,48 @@ @@ -113,11 +113,11 @@ index 00000000..bb849ee9 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_known_value_union::GetKnownValueUnionError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_known_value_union::GetKnownValueUnionError::Unhandled(unhandled) => { + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::union::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -129,12 +129,12 @@ index 00000000..bb849ee9 + +#[allow(dead_code)] +pub fn from_dafny_error( -+ dafny_value: ::std::rc::Rc, ++ dafny_value: ::std::rc::Rc, +) -> crate::operation::get_known_value_union::GetKnownValueUnionError { + // 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::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::CollectionOfErrors { .. } ++ crate::r#simple::union::internaldafny::types::Error::CollectionOfErrors { .. } + ) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_known_value_union::GetKnownValueUnionError::generic( @@ -156,7 +156,7 @@ index 00000000..bb849ee9 +pub mod _get_known_value_union_output; diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs new file mode 100644 -index 00000000..b967c23e +index 00000000..05142362 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs @@ -0,0 +1,56 @@ @@ -165,14 +165,14 @@ index 00000000..b967c23e +pub fn to_dafny( + value: crate::operation::get_known_value_union::GetKnownValueUnionInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, ++ crate::r#simple::union::internaldafny::types::GetKnownValueUnionInput, +> { + let dafny_value = match value.value { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: { + let v = match v { + crate::types::_known_value_union::KnownValueUnion::Value(n) => { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::KnownValueUnion::Value { Value: n } ++ crate::simple::union::internaldafny::types::KnownValueUnion::Value { Value: n } + } + crate::types::_known_value_union::KnownValueUnion::Unknown => unreachable!() + }; @@ -180,9 +180,9 @@ index 00000000..b967c23e + ::std::rc::Rc::new(v) + }, + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput::GetKnownValueUnionInput { ++ ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetKnownValueUnionInput::GetKnownValueUnionInput { + r#union: ::std::rc::Rc::new(dafny_value) + }) +} @@ -190,24 +190,24 @@ index 00000000..b967c23e +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, ++ crate::r#simple::union::internaldafny::types::GetKnownValueUnionInput, + >, +) -> crate::operation::get_known_value_union::GetKnownValueUnionInput { + let value = if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + let v = dafny_value.union().Extract(); + let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); + let v = match v { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::KnownValueUnion::Value { ++ crate::simple::union::internaldafny::types::KnownValueUnion::Value { + Value, + } => crate::types::_known_value_union::KnownValueUnion::Value(Value), + }; + Some(v) + } else if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -218,7 +218,7 @@ index 00000000..b967c23e +} diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs new file mode 100644 -index 00000000..fecbc721 +index 00000000..a6222365 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs @@ -0,0 +1,54 @@ @@ -226,13 +226,13 @@ index 00000000..fecbc721 +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_known_value_union::GetKnownValueUnionOutput, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + let dafny_value = match value.union { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: { + let v = match v { + crate::types::_known_value_union::KnownValueUnion::Value(n) => { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { IntegerValue: n } ++ crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue: n } + } + crate::types::_known_value_union::KnownValueUnion::Unknown => unreachable!(), + }; @@ -240,9 +240,9 @@ index 00000000..fecbc721 + ::std::rc::Rc::new(v) + }, + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput::GetUnionOutput { ++ ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetUnionOutput::GetUnionOutput { + r#union: ::std::rc::Rc::new(dafny_value) + }) +} @@ -250,24 +250,24 @@ index 00000000..fecbc721 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, ++ crate::r#simple::union::internaldafny::types::GetKnownValueUnionOutput, + >, +) -> crate::operation::get_known_value_union::GetKnownValueUnionOutput { + let union = if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + let v = dafny_value.union().Extract(); + let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); + let v = match v { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::KnownValueUnion::Value { ++ crate::simple::union::internaldafny::types::KnownValueUnion::Value { + Value, + } => crate::types::_known_value_union::KnownValueUnion::Value(Value), + }; + Some(v) + } else if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -278,7 +278,7 @@ index 00000000..fecbc721 +} diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_union.rs a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs new file mode 100644 -index 00000000..de6ea98e +index 00000000..9d32485a --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs @@ -0,0 +1,46 @@ @@ -289,10 +289,10 @@ index 00000000..de6ea98e +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_union::GetUnionError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_union::GetUnionError::Unhandled(unhandled) => ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#simple::union::internaldafny::types::Error::Opaque { + obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), @@ -303,12 +303,12 @@ index 00000000..de6ea98e + +#[allow(dead_code)] +pub fn from_dafny_error( -+ dafny_value: ::std::rc::Rc, ++ dafny_value: ::std::rc::Rc, +) -> crate::operation::get_union::GetUnionError { + // 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::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::CollectionOfErrors { .. } ++ crate::r#simple::union::internaldafny::types::Error::CollectionOfErrors { .. } + ) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_union::GetUnionError::generic( @@ -330,7 +330,7 @@ index 00000000..de6ea98e +pub mod _get_union_output; diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs new file mode 100644 -index 00000000..bed4e88a +index 00000000..ec0294ea --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs @@ -0,0 +1,60 @@ @@ -338,24 +338,24 @@ index 00000000..bed4e88a +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_union::GetUnionInput, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + let dafny_value = match value.union { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: { + let v = match v { + crate::types::_my_union::MyUnion::IntegerValue(n) => { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { IntegerValue: n } ++ crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue: n } + } -+ crate::types::_my_union::MyUnion::StringValue(s) => crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ crate::types::_my_union::MyUnion::StringValue(s) => crate::simple::union::internaldafny::types::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + crate::types::_my_union::MyUnion::Unknown => unreachable!(), + }; + + ::std::rc::Rc::new(v) + }, + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionInput::GetUnionInput { ++ ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetUnionInput::GetUnionInput { + r#union: ::std::rc::Rc::new(dafny_value) + }) +} @@ -363,20 +363,20 @@ index 00000000..bed4e88a +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionInput, ++ crate::r#simple::union::internaldafny::types::GetUnionInput, + >, +) -> crate::operation::get_union::GetUnionInput { + let value = if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + let v = dafny_value.union().Extract(); + let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); + let v = match v { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { ++ crate::simple::union::internaldafny::types::MyUnion::IntegerValue { + IntegerValue, + } => crate::types::_my_union::MyUnion::IntegerValue(IntegerValue), -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { ++ crate::simple::union::internaldafny::types::MyUnion::StringValue { + StringValue, + } => crate::types::_my_union::MyUnion::StringValue(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( + &StringValue, @@ -385,7 +385,7 @@ index 00000000..bed4e88a + Some(v) + } else if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -396,7 +396,7 @@ index 00000000..bed4e88a +} diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs new file mode 100644 -index 00000000..cd9c9fdf +index 00000000..08fc13f5 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs @@ -0,0 +1,60 @@ @@ -404,24 +404,24 @@ index 00000000..cd9c9fdf +#[allow(dead_code)] +pub fn to_dafny( + value: crate::operation::get_union::GetUnionOutput, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc { + let dafny_value = match value.union { -+ Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ Some(v) => crate::_Wrappers_Compile::Option::Some { + value: { + let v = match v { + crate::types::_my_union::MyUnion::IntegerValue(n) => { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { IntegerValue: n } ++ crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue: n } + } -+ crate::types::_my_union::MyUnion::StringValue(s) => crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, ++ crate::types::_my_union::MyUnion::StringValue(s) => crate::simple::union::internaldafny::types::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + crate::types::_my_union::MyUnion::Unknown => unreachable!(), + }; + + ::std::rc::Rc::new(v) + }, + }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ None => crate::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput::GetUnionOutput { ++ ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetUnionOutput::GetUnionOutput { + r#union: ::std::rc::Rc::new(dafny_value) + }) +} @@ -429,20 +429,20 @@ index 00000000..cd9c9fdf +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput, ++ crate::r#simple::union::internaldafny::types::GetUnionOutput, + >, +) -> crate::operation::get_union::GetUnionOutput { + let union = if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::_Wrappers_Compile::Option::Some { .. } + ) { + let v = dafny_value.union().Extract(); + let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); + let v = match v { -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { ++ crate::simple::union::internaldafny::types::MyUnion::IntegerValue { + IntegerValue, + } => crate::types::_my_union::MyUnion::IntegerValue(IntegerValue), -+ crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { ++ crate::simple::union::internaldafny::types::MyUnion::StringValue { + StringValue, + } => crate::types::_my_union::MyUnion::StringValue(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( + &StringValue, @@ -451,7 +451,7 @@ index 00000000..cd9c9fdf + Some(v) + } else if matches!( + dafny_value.union().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -471,7 +471,7 @@ index 00000000..f47a69b4 +pub mod _simple_union_config; diff --git b/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs a/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs new file mode 100644 -index 00000000..287ad929 +index 00000000..773e0e4f --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs @@ -0,0 +1,17 @@ @@ -480,14 +480,14 @@ index 00000000..287ad929 + +pub fn to_dafny( + value: crate::types::simple_union_config::SimpleUnionConfig, -+) -> ::std::rc::Rc { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::SimpleUnionConfig::SimpleUnionConfig {}) ++) -> ::std::rc::Rc { ++ ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::SimpleUnionConfig::SimpleUnionConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::SimpleUnionConfig, ++ crate::r#simple::union::internaldafny::types::SimpleUnionConfig, + >, +) -> crate::types::simple_union_config::SimpleUnionConfig { + crate::types::simple_union_config::SimpleUnionConfig {} @@ -544,6 +544,31 @@ index 00000000..cce22d1c +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} +diff --git b/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs +index 49d30605..a49d9b04 100644 +--- b/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,20 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++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 use client::Client; ++pub use types::simple_union_config::SimpleUnionConfig; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/Union/runtimes/rust/src/lib.rs a/TestModels/Union/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..6c0e841e @@ -584,7 +609,7 @@ index 00000000..91564304 +pub mod get_known_value_union; diff --git b/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs a/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs new file mode 100644 -index 00000000..16a7ab87 +index 00000000..1bbf03ca --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs @@ -0,0 +1,148 @@ @@ -613,7 +638,7 @@ index 00000000..16a7ab87 + ::dafny_runtime::md!(client.dafny_client.clone()).GetKnownValueUnion(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_known_value_union::_get_known_value_union_output::from_dafny( @@ -967,7 +992,7 @@ index 00000000..bff69f92 +} diff --git b/TestModels/Union/runtimes/rust/src/operation/get_union.rs a/TestModels/Union/runtimes/rust/src/operation/get_union.rs new file mode 100644 -index 00000000..d9f65f53 +index 00000000..66f6e875 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/operation/get_union.rs @@ -0,0 +1,145 @@ @@ -993,7 +1018,7 @@ index 00000000..d9f65f53 + ::dafny_runtime::md!(client.dafny_client.clone()).GetUnion(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_union::_get_union_output::from_dafny( diff --git a/TestModels/Union/runtimes/rust/Cargo.toml b/TestModels/Union/runtimes/rust/Cargo.toml index 80abf664c..f61170d04 100644 --- a/TestModels/Union/runtimes/rust/Cargo.toml +++ b/TestModels/Union/runtimes/rust/Cargo.toml @@ -10,8 +10,10 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../dafny-dependencies/StandardLibrary/runtimes/rust"} [dev-dependencies.tokio] version = "1.26.0" features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/Union/runtimes/rust/src/client.rs b/TestModels/Union/runtimes/rust/src/client.rs index f53a57eab..437b70f3d 100644 --- a/TestModels/Union/runtimes/rust/src/client.rs +++ b/TestModels/Union/runtimes/rust/src/client.rs @@ -5,7 +5,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { pub(crate) dafny_client: ::dafny_runtime::Object< - dyn crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, + dyn crate::r#simple::union::internaldafny::types::ISimpleUnionClient, >, } @@ -15,12 +15,12 @@ impl Client { pub fn from_conf( conf: crate::types::simple_union_config::SimpleUnionConfig, ) -> Result { - let inner = crate::implementation_from_dafny::_simple_dunion_dinternaldafny::_default::SimpleUnion( + let inner = crate::simple::union::internaldafny::_default::SimpleUnion( &crate::conversions::simple_union_config::_simple_union_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs index bb849ee9b..d8ba15d71 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs @@ -5,11 +5,11 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_known_value_union::GetKnownValueUnionError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_known_value_union::GetKnownValueUnionError::Unhandled(unhandled) => { ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::union::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -21,12 +21,12 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( - dafny_value: ::std::rc::Rc, + dafny_value: ::std::rc::Rc, ) -> crate::operation::get_known_value_union::GetKnownValueUnionError { // 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::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::CollectionOfErrors { .. } + crate::r#simple::union::internaldafny::types::Error::CollectionOfErrors { .. } ) { let error_message = "TODO: can't get message yet"; crate::operation::get_known_value_union::GetKnownValueUnionError::generic( diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs index b967c23e3..05142362d 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_input.rs @@ -3,14 +3,14 @@ pub fn to_dafny( value: crate::operation::get_known_value_union::GetKnownValueUnionInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, + crate::r#simple::union::internaldafny::types::GetKnownValueUnionInput, > { let dafny_value = match value.value { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: { let v = match v { crate::types::_known_value_union::KnownValueUnion::Value(n) => { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::KnownValueUnion::Value { Value: n } + crate::simple::union::internaldafny::types::KnownValueUnion::Value { Value: n } } crate::types::_known_value_union::KnownValueUnion::Unknown => unreachable!() }; @@ -18,9 +18,9 @@ pub fn to_dafny( ::std::rc::Rc::new(v) }, }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput::GetKnownValueUnionInput { + ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetKnownValueUnionInput::GetKnownValueUnionInput { r#union: ::std::rc::Rc::new(dafny_value) }) } @@ -28,24 +28,24 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, + crate::r#simple::union::internaldafny::types::GetKnownValueUnionInput, >, ) -> crate::operation::get_known_value_union::GetKnownValueUnionInput { let value = if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { let v = dafny_value.union().Extract(); let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); let v = match v { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::KnownValueUnion::Value { + crate::simple::union::internaldafny::types::KnownValueUnion::Value { Value, } => crate::types::_known_value_union::KnownValueUnion::Value(Value), }; Some(v) } else if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs index fecbc7210..a62223656 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union/_get_known_value_union_output.rs @@ -2,13 +2,13 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_known_value_union::GetKnownValueUnionOutput, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { let dafny_value = match value.union { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: { let v = match v { crate::types::_known_value_union::KnownValueUnion::Value(n) => { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { IntegerValue: n } + crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue: n } } crate::types::_known_value_union::KnownValueUnion::Unknown => unreachable!(), }; @@ -16,9 +16,9 @@ pub fn to_dafny( ::std::rc::Rc::new(v) }, }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput::GetUnionOutput { + ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetUnionOutput::GetUnionOutput { r#union: ::std::rc::Rc::new(dafny_value) }) } @@ -26,24 +26,24 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, + crate::r#simple::union::internaldafny::types::GetKnownValueUnionOutput, >, ) -> crate::operation::get_known_value_union::GetKnownValueUnionOutput { let union = if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { let v = dafny_value.union().Extract(); let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); let v = match v { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::KnownValueUnion::Value { + crate::simple::union::internaldafny::types::KnownValueUnion::Value { Value, } => crate::types::_known_value_union::KnownValueUnion::Value(Value), }; Some(v) } else if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs b/TestModels/Union/runtimes/rust/src/conversions/get_union.rs index de6ea98e5..9d32485ac 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_union.rs @@ -5,10 +5,10 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_union::GetUnionError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { match value { crate::operation::get_union::GetUnionError::Unhandled(unhandled) => ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { + crate::r#simple::union::internaldafny::types::Error::Opaque { obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), @@ -19,12 +19,12 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( - dafny_value: ::std::rc::Rc, + dafny_value: ::std::rc::Rc, ) -> crate::operation::get_union::GetUnionError { // 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::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::CollectionOfErrors { .. } + crate::r#simple::union::internaldafny::types::Error::CollectionOfErrors { .. } ) { let error_message = "TODO: can't get message yet"; crate::operation::get_union::GetUnionError::generic( diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs b/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs index bed4e88a9..ec0294eac 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_input.rs @@ -2,24 +2,24 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_union::GetUnionInput, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { let dafny_value = match value.union { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: { let v = match v { crate::types::_my_union::MyUnion::IntegerValue(n) => { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { IntegerValue: n } + crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue: n } } - crate::types::_my_union::MyUnion::StringValue(s) => crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + crate::types::_my_union::MyUnion::StringValue(s) => crate::simple::union::internaldafny::types::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, crate::types::_my_union::MyUnion::Unknown => unreachable!(), }; ::std::rc::Rc::new(v) }, }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionInput::GetUnionInput { + ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetUnionInput::GetUnionInput { r#union: ::std::rc::Rc::new(dafny_value) }) } @@ -27,20 +27,20 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionInput, + crate::r#simple::union::internaldafny::types::GetUnionInput, >, ) -> crate::operation::get_union::GetUnionInput { let value = if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { let v = dafny_value.union().Extract(); let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); let v = match v { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { + crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue, } => crate::types::_my_union::MyUnion::IntegerValue(IntegerValue), - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { + crate::simple::union::internaldafny::types::MyUnion::StringValue { StringValue, } => crate::types::_my_union::MyUnion::StringValue(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( &StringValue, @@ -49,7 +49,7 @@ pub fn from_dafny( Some(v) } else if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs b/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs index cd9c9fdf9..08fc13f51 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_union/_get_union_output.rs @@ -2,24 +2,24 @@ #[allow(dead_code)] pub fn to_dafny( value: crate::operation::get_union::GetUnionOutput, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc { let dafny_value = match value.union { - Some(v) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + Some(v) => crate::_Wrappers_Compile::Option::Some { value: { let v = match v { crate::types::_my_union::MyUnion::IntegerValue(n) => { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { IntegerValue: n } + crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue: n } } - crate::types::_my_union::MyUnion::StringValue(s) => crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, + crate::types::_my_union::MyUnion::StringValue(s) => crate::simple::union::internaldafny::types::MyUnion::StringValue { StringValue: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }, crate::types::_my_union::MyUnion::Unknown => unreachable!(), }; ::std::rc::Rc::new(v) }, }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + None => crate::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput::GetUnionOutput { + ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::GetUnionOutput::GetUnionOutput { r#union: ::std::rc::Rc::new(dafny_value) }) } @@ -27,20 +27,20 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput, + crate::r#simple::union::internaldafny::types::GetUnionOutput, >, ) -> crate::operation::get_union::GetUnionOutput { let union = if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + crate::_Wrappers_Compile::Option::Some { .. } ) { let v = dafny_value.union().Extract(); let v = ::std::rc::Rc::try_unwrap(v).unwrap_or_else(|rc| (*rc).clone()); let v = match v { - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::IntegerValue { + crate::simple::union::internaldafny::types::MyUnion::IntegerValue { IntegerValue, } => crate::types::_my_union::MyUnion::IntegerValue(IntegerValue), - crate::implementation_from_dafny::_simple_dunion_dinternaldafny_dtypes::MyUnion::StringValue { + crate::simple::union::internaldafny::types::MyUnion::StringValue { StringValue, } => crate::types::_my_union::MyUnion::StringValue(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string( &StringValue, @@ -49,7 +49,7 @@ pub fn from_dafny( Some(v) } else if matches!( dafny_value.union().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + crate::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs b/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs index 287ad929b..773e0e4f7 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/simple_union_config/_simple_union_config.rs @@ -3,14 +3,14 @@ pub fn to_dafny( value: crate::types::simple_union_config::SimpleUnionConfig, -) -> ::std::rc::Rc { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::SimpleUnionConfig::SimpleUnionConfig {}) +) -> ::std::rc::Rc { + ::std::rc::Rc::new(crate::r#simple::union::internaldafny::types::SimpleUnionConfig::SimpleUnionConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dunion_dinternaldafny_dtypes::SimpleUnionConfig, + crate::r#simple::union::internaldafny::types::SimpleUnionConfig, >, ) -> crate::types::simple_union_config::SimpleUnionConfig { crate::types::simple_union_config::SimpleUnionConfig {} diff --git a/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..a49d9b049 --- /dev/null +++ b/TestModels/Union/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2525 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +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 use client::Client; +pub use types::simple_union_config::SimpleUnionConfig; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod simple { + pub mod r#union { + pub mod internaldafny { + pub use crate::simple::r#union::internaldafny::types::ISimpleUnionClient; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct _default {} + + impl _default { + pub fn DefaultSimpleUnionConfig( + ) -> ::std::rc::Rc + { + ::std::rc::Rc::new(crate::simple::r#union::internaldafny::types::SimpleUnionConfig::SimpleUnionConfig {}) + } + pub fn SimpleUnion( + config: &::std::rc::Rc< + crate::simple::r#union::internaldafny::types::SimpleUnionConfig, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::r#union::internaldafny::SimpleUnionClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + crate::simple::r#union::internaldafny::SimpleUnionClient, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + crate::simple::r#union::internaldafny::SimpleUnionClient, + >, + >::new(); + let mut _nw1: ::dafny_runtime::Object< + crate::simple::r#union::internaldafny::SimpleUnionClient, + > = crate::simple::r#union::internaldafny::SimpleUnionClient::_allocate_object( + ); + crate::simple::r#union::internaldafny::SimpleUnionClient::_ctor( + &_nw1, + &::std::rc::Rc::new(crate::r#_SimpleUnionImpl_Compile::Config::Config {}), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + crate::simple::r#union::internaldafny::SimpleUnionClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + } + pub fn CreateSuccessOfClient( + client: &::dafny_runtime::Object< + dyn crate::simple::r#union::internaldafny::types::ISimpleUnionClient, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + dyn crate::simple::r#union::internaldafny::types::ISimpleUnionClient, + >, + ::std::rc::Rc, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + dyn crate::simple::r#union::internaldafny::types::ISimpleUnionClient, + >, + ::std::rc::Rc, + >::Success { + value: client.clone(), + }) + } + pub fn CreateFailureOfError( + error: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + dyn crate::simple::r#union::internaldafny::types::ISimpleUnionClient, + >, + ::std::rc::Rc, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + dyn crate::simple::r#union::internaldafny::types::ISimpleUnionClient, + >, + ::std::rc::Rc, + >::Failure { + error: error.clone(), + }) + } + } + + pub struct SimpleUnionClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleUnionClient { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _ctor( + this: &::dafny_runtime::Object< + crate::simple::r#union::internaldafny::SimpleUnionClient, + >, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_object!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config(&self) -> ::std::rc::Rc { + self.r#__i_config.clone() + } + } + + impl UpcastObject for crate::simple::r#union::internaldafny::SimpleUnionClient { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + impl ISimpleUnionClient for crate::simple::r#union::internaldafny::SimpleUnionClient { + fn GetUnion( + &mut self, + input: &::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetUnionInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetUnionOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetUnionOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleUnionImpl_Compile::_default::GetUnion( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + fn GetKnownValueUnion( + &mut self, + input: &::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetKnownValueUnionInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetKnownValueUnionOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + crate::r#_SimpleUnionImpl_Compile::_default::GetKnownValueUnion( + &self.config().clone(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); + } + } + + impl UpcastObject + for crate::simple::r#union::internaldafny::SimpleUnionClient + { + ::dafny_runtime::UpcastObjectFn!(dyn crate::simple::r#union::internaldafny::types::ISimpleUnionClient); + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "simple.union.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetKnownValueUnionInput { + GetKnownValueUnionInput { + r#union: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::KnownValueUnion, + >, + >, + >, + }, + } + + impl GetKnownValueUnionInput { + pub fn r#union( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::KnownValueUnion, + >, + >, + > { + match self { + GetKnownValueUnionInput::GetKnownValueUnionInput { r#union } => r#union, + } + } + } + + impl Debug for GetKnownValueUnionInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetKnownValueUnionInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetKnownValueUnionInput::GetKnownValueUnionInput { r#union } => { + write!(_formatter, "simple.union.internaldafny.types.GetKnownValueUnionInput.GetKnownValueUnionInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetKnownValueUnionInput {} + + impl Hash for GetKnownValueUnionInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetKnownValueUnionInput::GetKnownValueUnionInput { r#union } => { + ::std::hash::Hash::hash(r#union, _state) + } + } + } + } + + impl Default for GetKnownValueUnionInput { + fn default() -> GetKnownValueUnionInput { + GetKnownValueUnionInput::GetKnownValueUnionInput { + r#union: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetKnownValueUnionInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetKnownValueUnionOutput { + GetKnownValueUnionOutput { + r#union: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::KnownValueUnion, + >, + >, + >, + }, + } + + impl GetKnownValueUnionOutput { + pub fn r#union( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::KnownValueUnion, + >, + >, + > { + match self { + GetKnownValueUnionOutput::GetKnownValueUnionOutput { r#union } => { + r#union + } + } + } + } + + impl Debug for GetKnownValueUnionOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetKnownValueUnionOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetKnownValueUnionOutput::GetKnownValueUnionOutput { r#union } => { + write!(_formatter, "simple.union.internaldafny.types.GetKnownValueUnionOutput.GetKnownValueUnionOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetKnownValueUnionOutput {} + + impl Hash for GetKnownValueUnionOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetKnownValueUnionOutput::GetKnownValueUnionOutput { r#union } => { + ::std::hash::Hash::hash(r#union, _state) + } + } + } + } + + impl Default for GetKnownValueUnionOutput { + fn default() -> GetKnownValueUnionOutput { + GetKnownValueUnionOutput::GetKnownValueUnionOutput { + r#union: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetKnownValueUnionOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetUnionInput { + GetUnionInput { + r#union: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::MyUnion, + >, + >, + >, + }, + } + + impl GetUnionInput { + pub fn r#union( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc, + >, + > { + match self { + GetUnionInput::GetUnionInput { r#union } => r#union, + } + } + } + + impl Debug for GetUnionInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetUnionInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetUnionInput::GetUnionInput { r#union } => { + write!( + _formatter, + "simple.union.internaldafny.types.GetUnionInput.GetUnionInput(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetUnionInput {} + + impl Hash for GetUnionInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetUnionInput::GetUnionInput { r#union } => { + ::std::hash::Hash::hash(r#union, _state) + } + } + } + } + + impl Default for GetUnionInput { + fn default() -> GetUnionInput { + GetUnionInput::GetUnionInput { + r#union: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetUnionInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetUnionOutput { + GetUnionOutput { + r#union: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::MyUnion, + >, + >, + >, + }, + } + + impl GetUnionOutput { + pub fn r#union( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::std::rc::Rc, + >, + > { + match self { + GetUnionOutput::GetUnionOutput { r#union } => r#union, + } + } + } + + impl Debug for GetUnionOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetUnionOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetUnionOutput::GetUnionOutput { r#union } => { + write!(_formatter, "simple.union.internaldafny.types.GetUnionOutput.GetUnionOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetUnionOutput {} + + impl Hash for GetUnionOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetUnionOutput::GetUnionOutput { r#union } => { + ::std::hash::Hash::hash(r#union, _state) + } + } + } + } + + impl Default for GetUnionOutput { + fn default() -> GetUnionOutput { + GetUnionOutput::GetUnionOutput { + r#union: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetUnionOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum KnownValueUnion { + Value { Value: i32 }, + } + + impl KnownValueUnion { + pub fn Value(&self) -> &i32 { + match self { + KnownValueUnion::Value { Value } => Value, + } + } + } + + impl Debug for KnownValueUnion { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for KnownValueUnion { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + KnownValueUnion::Value { Value } => { + write!( + _formatter, + "simple.union.internaldafny.types.KnownValueUnion.Value(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(Value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for KnownValueUnion {} + + impl Hash for KnownValueUnion { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + KnownValueUnion::Value { Value } => { + ::std::hash::Hash::hash(Value, _state) + } + } + } + } + + impl Default for KnownValueUnion { + fn default() -> KnownValueUnion { + KnownValueUnion::Value { + Value: ::std::default::Default::default(), + } + } + } + + impl AsRef for &KnownValueUnion { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum MyUnion { + IntegerValue { + IntegerValue: i32, + }, + StringValue { + StringValue: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + } + + impl MyUnion { + pub fn IntegerValue(&self) -> &i32 { + match self { + MyUnion::IntegerValue { IntegerValue } => IntegerValue, + MyUnion::StringValue { StringValue } => { + panic!("field does not exist on this variant") + } + } + } + pub fn StringValue( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + MyUnion::IntegerValue { IntegerValue } => { + panic!("field does not exist on this variant") + } + MyUnion::StringValue { StringValue } => StringValue, + } + } + } + + impl Debug for MyUnion { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for MyUnion { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + MyUnion::IntegerValue { IntegerValue } => { + write!( + _formatter, + "simple.union.internaldafny.types.MyUnion.IntegerValue(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print( + IntegerValue, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + MyUnion::StringValue { StringValue } => { + write!( + _formatter, + "simple.union.internaldafny.types.MyUnion.StringValue(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print( + StringValue, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for MyUnion {} + + impl Hash for MyUnion { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + MyUnion::IntegerValue { IntegerValue } => { + ::std::hash::Hash::hash(IntegerValue, _state) + } + MyUnion::StringValue { StringValue } => { + ::std::hash::Hash::hash(StringValue, _state) + } + } + } + } + + impl Default for MyUnion { + fn default() -> MyUnion { + MyUnion::IntegerValue { + IntegerValue: ::std::default::Default::default(), + } + } + } + + impl AsRef for &MyUnion { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleUnionClientCallHistory {} + + impl ISimpleUnionClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::simple::r#union::internaldafny::types::ISimpleUnionClientCallHistory + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } + + pub trait ISimpleUnionClient: + ::std::any::Any + ::dafny_runtime::UpcastObject + { + fn GetUnion( + &mut self, + input: &::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetUnionInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetUnionOutput, + >, + ::std::rc::Rc, + >, + >; + fn GetKnownValueUnion(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum SimpleUnionConfig { + SimpleUnionConfig {}, + } + + impl SimpleUnionConfig {} + + impl Debug for SimpleUnionConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SimpleUnionConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleUnionConfig::SimpleUnionConfig {} => { + write!(_formatter, "simple.union.internaldafny.types.SimpleUnionConfig.SimpleUnionConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleUnionConfig {} + + impl Hash for SimpleUnionConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleUnionConfig::SimpleUnionConfig {} => {} + } + } + } + + impl Default for SimpleUnionConfig { + fn default() -> SimpleUnionConfig { + SimpleUnionConfig::SimpleUnionConfig {} + } + } + + impl AsRef for &SimpleUnionConfig { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn message( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!( + _formatter, + "simple.union.internaldafny.types.Error.CollectionOfErrors(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "simple.union.internaldafny.types.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + ::std::hash::Hash::hash(list, _state); + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; + } + } + } +} +pub mod r#_SimpleUnionImpl_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn GetUnion( + config: &::std::rc::Rc, + input: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetUnionOutput, + > = ::std::rc::Rc::new( + crate::simple::r#union::internaldafny::types::GetUnionOutput::GetUnionOutput { + r#union: input.r#union().clone(), + }, + ); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + pub fn GetKnownValueUnion( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetKnownValueUnionInput, + >, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetKnownValueUnionOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetKnownValueUnionOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(crate::simple::r#union::internaldafny::types::GetKnownValueUnionOutput::GetKnownValueUnionOutput { + r#union: input.r#union().clone() + }); + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + crate::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + crate::simple::r#union::internaldafny::types::GetKnownValueUnionOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "SimpleUnionImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module {} diff --git a/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs b/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs index 16a7ab872..1bbf03cad 100644 --- a/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs +++ b/TestModels/Union/runtimes/rust/src/operation/get_known_value_union.rs @@ -23,7 +23,7 @@ impl GetKnownValueUnion { ::dafny_runtime::md!(client.dafny_client.clone()).GetKnownValueUnion(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_known_value_union::_get_known_value_union_output::from_dafny( diff --git a/TestModels/Union/runtimes/rust/src/operation/get_union.rs b/TestModels/Union/runtimes/rust/src/operation/get_union.rs index d9f65f538..66f6e8751 100644 --- a/TestModels/Union/runtimes/rust/src/operation/get_union.rs +++ b/TestModels/Union/runtimes/rust/src/operation/get_union.rs @@ -20,7 +20,7 @@ impl GetUnion { ::dafny_runtime::md!(client.dafny_client.clone()).GetUnion(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_union::_get_union_output::from_dafny( diff --git a/TestModels/aws-sdks/kms-lite/Makefile b/TestModels/aws-sdks/kms-lite/Makefile index a485f1d9d..8d1a64328 100644 --- a/TestModels/aws-sdks/kms-lite/Makefile +++ b/TestModels/aws-sdks/kms-lite/Makefile @@ -3,6 +3,8 @@ CORES=2 +TRANSPILE_TESTS_IN_RUST=1 + include ../../SharedMakefile.mk NAMESPACE=com.amazonaws.kms diff --git a/TestModels/aws-sdks/kms-lite/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/aws-sdks/kms-lite/codegen-patches/rust/dafny-4.5.0.patch index e5a48c77f..0180d1d53 100644 --- a/TestModels/aws-sdks/kms-lite/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/aws-sdks/kms-lite/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..b0091d98 +index 00000000..762b58c7 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs @@ -0,0 +1,88 @@ @@ -16,65 +16,65 @@ index 00000000..b0091d98 + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); +} + -+impl dafny_runtime::UpcastObject for Client { -+ ::dafny_runtime::UpcastObjectFn!(dyn crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient); ++impl dafny_runtime::UpcastObject for Client { ++ ::dafny_runtime::UpcastObjectFn!(dyn crate::r#software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient); +} + -+impl crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient ++impl crate::r#software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient + for Client { -+ fn Decrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn Decrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + let native_result = + self.rt.block_on(conversions::decrypt::_decrypt_request::from_dafny(input.clone(), self.inner.clone()).send()); -+ dafny_standard_library::conversion::result_to_dafny(&native_result, ++ crate::standard_library_conversions::result_to_dafny(&native_result, + conversions::decrypt::_decrypt_response::to_dafny, + conversions::decrypt::to_dafny_error) + } + -+ fn Encrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn Encrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + let native_result = + self.rt.block_on(conversions::encrypt::_encrypt_request::from_dafny(input.clone(), self.inner.clone()).send()); -+ dafny_standard_library::conversion::result_to_dafny(&native_result, ++ crate::standard_library_conversions::result_to_dafny(&native_result, + conversions::encrypt::_encrypt_response::to_dafny, + conversions::encrypt::to_dafny_error) + } + -+ fn GenerateDataKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn GenerateDataKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + let native_result = + self.rt.block_on(conversions::generate_data_key::_generate_data_key_request::from_dafny(input.clone(), self.inner.clone()).send()); -+ dafny_standard_library::conversion::result_to_dafny(&native_result, ++ crate::standard_library_conversions::result_to_dafny(&native_result, + conversions::generate_data_key::_generate_data_key_response::to_dafny, + conversions::generate_data_key::to_dafny_error) + } + -+ fn GenerateDataKeyWithoutPlaintext(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn GenerateDataKeyWithoutPlaintext(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + let native_result = + self.rt.block_on(conversions::generate_data_key_without_plaintext::_generate_data_key_without_plaintext_request::from_dafny(input.clone(), self.inner.clone()).send()); -+ dafny_standard_library::conversion::result_to_dafny(&native_result, ++ crate::standard_library_conversions::result_to_dafny(&native_result, + conversions::generate_data_key_without_plaintext::_generate_data_key_without_plaintext_response::to_dafny, + conversions::generate_data_key_without_plaintext::to_dafny_error) + } + + // Leaving untested operations out for now + -+ fn DeriveSharedSecret(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn DeriveSharedSecret(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + todo!() + } + -+ fn GetPublicKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn GetPublicKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + todo!() + } + -+ fn ReEncrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { ++ fn ReEncrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + todo!() + } + } + +#[allow(non_snake_case)] -+impl crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny::_default { ++impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_default { + pub fn KMSClient() -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result< -+ ::dafny_runtime::Object, -+ ::std::rc::Rc ++ crate::r#_Wrappers_Compile::Result< ++ ::dafny_runtime::Object, ++ ::std::rc::Rc + > + > { + let rt_result = tokio::runtime::Builder::new_current_thread() @@ -89,7 +89,7 @@ index 00000000..b0091d98 + let inner = aws_sdk_kms::Client::new(&shared_config); + let client = Client { inner, rt }; + let dafny_client = ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(client)); -+ std::rc::Rc::new(crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { value: dafny_client }) ++ std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::Success { value: dafny_client }) + } +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions.rs @@ -119,7 +119,7 @@ index 00000000..8f8fb189 +pub mod error; diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs new file mode 100644 -index 00000000..24905032 +index 00000000..deadcdda --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs @@ -0,0 +1,22 @@ @@ -128,26 +128,26 @@ index 00000000..24905032 + +pub fn to_dafny( + value: aws_sdk_kms::types::DataKeySpec, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new(match value { -+ aws_sdk_kms::types::DataKeySpec::Aes128 => crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_128 {}, -+ aws_sdk_kms::types::DataKeySpec::Aes256 => crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_256 {}, ++ aws_sdk_kms::types::DataKeySpec::Aes128 => crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_128 {}, ++ aws_sdk_kms::types::DataKeySpec::Aes256 => crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_256 {}, + _ => panic!() + }) +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec, ++ dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec, +) -> aws_sdk_kms::types::DataKeySpec { + match dafny_value { -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_128 {} => aws_sdk_kms::types::DataKeySpec::Aes128, -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_256 {} => aws_sdk_kms::types::DataKeySpec::Aes256, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_128 {} => aws_sdk_kms::types::DataKeySpec::Aes128, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_256 {} => aws_sdk_kms::types::DataKeySpec::Aes256, + } +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs new file mode 100644 -index 00000000..68c7b13f +index 00000000..fe0708d2 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs @@ -0,0 +1,45 @@ @@ -156,7 +156,7 @@ index 00000000..68c7b13f +pub mod _decrypt_response; + +use aws_sdk_kms::error::SdkError; -+use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; ++use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; + +#[allow(dead_code)] +pub fn to_dafny_error( @@ -198,7 +198,7 @@ index 00000000..68c7b13f +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs new file mode 100644 -index 00000000..7bf5704d +index 00000000..0fbf835c --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs @@ -0,0 +1,88 @@ @@ -207,41 +207,41 @@ index 00000000..7bf5704d +pub fn to_dafny( + value: aws_sdk_kms::operation::decrypt::DecryptInput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest::DecryptRequest { -+ CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob).Extract(), -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest::DecryptRequest { ++ CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob).Extract(), ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), + EncryptionContext: + ::std::rc::Rc::new(match value.encryption_context() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + GrantTokens: + ::std::rc::Rc::new( + // Have to clone or else this becomes a borrow that can interfere with other branches + match value.grant_tokens.clone() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + Recipient: crate::conversions::recipient_info::option_to_dafny(value.recipient()), -+ DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), ++ DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), + EncryptionAlgorithm: ::std::rc::Rc::new(match value.encryption_algorithm { -+ Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None { } ++ Some(x) => crate::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, ++ None => crate::_Wrappers_Compile::Option::None { } + }) + }) +} @@ -249,18 +249,18 @@ index 00000000..7bf5704d +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest, + >, + client: aws_sdk_kms::Client, +) -> aws_sdk_kms::operation::decrypt::builders::DecryptFluentBuilder { + client.decrypt() + .set_ciphertext_blob(Some( -+ dafny_standard_library::conversion::blob_from_dafny(dafny_value.CiphertextBlob().clone()))) ++ crate::standard_library_conversions::blob_from_dafny(dafny_value.CiphertextBlob().clone()))) + .set_key_id( -+ dafny_standard_library::conversion::ostring_from_dafny(dafny_value.KeyId().clone()), ++ crate::standard_library_conversions::ostring_from_dafny(dafny_value.KeyId().clone()), + ) + .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -270,7 +270,7 @@ index 00000000..7bf5704d + _ => None + }) + .set_grant_tokens(match &**dafny_value.GrantTokens() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) @@ -278,21 +278,21 @@ index 00000000..7bf5704d + _ => None + }) + .set_recipient(match &**dafny_value.Recipient() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + crate::conversions::recipient_info::from_dafny(value.clone()) + ), + _ => None + }) -+ .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) ++ .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) + .set_encryption_algorithm( -+ dafny_standard_library::conversion::option_from_dafny( ++ crate::standard_library_conversions::option_from_dafny( + dafny_value.EncryptionAlgorithm().clone(), + |x| crate::conversions::encryption_algorithm_spec::from_dafny(x))) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs new file mode 100644 -index 00000000..bc89ab27 +index 00000000..b185a590 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs @@ -0,0 +1,17 @@ @@ -301,13 +301,13 @@ index 00000000..bc89ab27 +pub fn to_dafny( + value: &aws_sdk_kms::operation::decrypt::DecryptOutput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptResponse, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptResponse, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptResponse::DecryptResponse { -+ Plaintext: dafny_standard_library::conversion::oblob_to_dafny(&value.plaintext), -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), -+ CiphertextForRecipient: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_for_recipient), -+ EncryptionAlgorithm: dafny_standard_library::conversion::option_to_dafny(&value.encryption_algorithm, ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptResponse::DecryptResponse { ++ Plaintext: crate::standard_library_conversions::oblob_to_dafny(&value.plaintext), ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), ++ CiphertextForRecipient: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_for_recipient), ++ EncryptionAlgorithm: crate::standard_library_conversions::option_to_dafny(&value.encryption_algorithm, + |x| crate::conversions::encryption_algorithm_spec::to_dafny(x.clone())), + }) +} @@ -315,7 +315,7 @@ index 00000000..bc89ab27 +// from_dafny ommitted to save time until we get to actual code generation diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs new file mode 100644 -index 00000000..3620a36f +index 00000000..1dffbe0b --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs @@ -0,0 +1,41 @@ @@ -324,7 +324,7 @@ index 00000000..3620a36f +pub mod _encrypt_response; + +use aws_sdk_kms::error::SdkError; -+use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; ++use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; + +#[allow(dead_code)] +pub fn to_dafny_error( @@ -362,7 +362,7 @@ index 00000000..3620a36f +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs new file mode 100644 -index 00000000..936569ca +index 00000000..42cdae13 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs @@ -0,0 +1,79 @@ @@ -371,40 +371,40 @@ index 00000000..936569ca +pub fn to_dafny( + value: aws_sdk_kms::operation::encrypt::EncryptInput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest::EncryptRequest { -+ Plaintext: dafny_standard_library::conversion::oblob_to_dafny(&value.plaintext).Extract(), -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id).Extract(), ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest::EncryptRequest { ++ Plaintext: crate::standard_library_conversions::oblob_to_dafny(&value.plaintext).Extract(), ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id).Extract(), + EncryptionContext: + ::std::rc::Rc::new(match value.encryption_context() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), + GrantTokens: + ::std::rc::Rc::new( + // Have to clone or else this becomes a borrow that can interfere with other branches + match value.grant_tokens.clone() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), -+ DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), ++ DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), + EncryptionAlgorithm: ::std::rc::Rc::new(match value.encryption_algorithm { -+ Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None { } ++ Some(x) => crate::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, ++ None => crate::_Wrappers_Compile::Option::None { } + }) + }) +} @@ -412,17 +412,17 @@ index 00000000..936569ca +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest, + >, + client: aws_sdk_kms::Client, +) -> aws_sdk_kms::operation::encrypt::builders::EncryptFluentBuilder { + client.encrypt() -+ .set_plaintext(Some(dafny_standard_library::conversion::blob_from_dafny(dafny_value.Plaintext().clone()))) ++ .set_plaintext(Some(crate::standard_library_conversions::blob_from_dafny(dafny_value.Plaintext().clone()))) + .set_key_id(Some( + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(dafny_value.KeyId())), + ) + .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -432,22 +432,22 @@ index 00000000..936569ca + _ => None + }) + .set_grant_tokens(match &**dafny_value.GrantTokens() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) + ), + _ => None + }) -+ .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) ++ .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) + .set_encryption_algorithm( -+ dafny_standard_library::conversion::option_from_dafny( ++ crate::standard_library_conversions::option_from_dafny( + dafny_value.EncryptionAlgorithm().clone(), + |x| crate::conversions::encryption_algorithm_spec::from_dafny(x))) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs new file mode 100644 -index 00000000..9a5c55dc +index 00000000..b8e0f586 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs @@ -0,0 +1,16 @@ @@ -456,12 +456,12 @@ index 00000000..9a5c55dc +pub fn to_dafny( + value: &aws_sdk_kms::operation::encrypt::EncryptOutput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptResponse, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptResponse, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptResponse::EncryptResponse { -+ CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob), -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), -+ EncryptionAlgorithm: dafny_standard_library::conversion::option_to_dafny(&value.encryption_algorithm, ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptResponse::EncryptResponse { ++ CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob), ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), ++ EncryptionAlgorithm: crate::standard_library_conversions::option_to_dafny(&value.encryption_algorithm, + |x| crate::conversions::encryption_algorithm_spec::to_dafny(x.clone())), + }) +} @@ -469,7 +469,7 @@ index 00000000..9a5c55dc +// from_dafny ommitted to save time until we get to actual code generation diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs new file mode 100644 -index 00000000..304f1ac0 +index 00000000..0328c46b --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs @@ -0,0 +1,32 @@ @@ -478,14 +478,14 @@ index 00000000..304f1ac0 + +pub fn to_dafny( + value: aws_sdk_kms::types::EncryptionAlgorithmSpec, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new(match value { + aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha1 => -+ crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { }, ++ crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { }, + aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256 => -+ crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { }, ++ crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { }, + aws_sdk_kms::types::EncryptionAlgorithmSpec::SymmetricDefault => -+ crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { }, ++ crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { }, + // TODO: This should not be a panic, but the Dafny image of the enum shape doesn't have an Unknown variant of any kind, + // so there's no way to succeed. + // See https://github.com/smithy-lang/smithy-dafny/issues/476. @@ -497,17 +497,17 @@ index 00000000..304f1ac0 + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec, ++ dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec, +) -> aws_sdk_kms::types::EncryptionAlgorithmSpec { + match dafny_value { -+ crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::SymmetricDefault, -+ crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha1, -+ crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256, ++ crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::SymmetricDefault, ++ crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha1, ++ crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256, + } +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs new file mode 100644 -index 00000000..d844a1c7 +index 00000000..d59e6fed --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs @@ -0,0 +1,51 @@ @@ -535,13 +535,13 @@ index 00000000..d844a1c7 + +/// Wraps up an arbitrary Rust Error value as a Dafny Error +pub fn to_opaque_error(value: E) -> -+ ::std::rc::Rc ++ ::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::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::Opaque { ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::Opaque { + obj: error_obj, + }, + ) @@ -550,21 +550,21 @@ index 00000000..d844a1c7 +/// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure +pub fn to_opaque_error_result(value: E) -> + ::std::rc::Rc< -+ dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result< ++ crate::_Wrappers_Compile::Result< + T, -+ ::std::rc::Rc ++ ::std::rc::Rc + > + > +{ + ::std::rc::Rc::new( -+ dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result::Failure { ++ crate::_Wrappers_Compile::Result::Failure { + error: to_opaque_error(value), + }, + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs new file mode 100644 -index 00000000..b2d7d133 +index 00000000..4576a6d6 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs @@ -0,0 +1,12 @@ @@ -573,16 +573,16 @@ index 00000000..b2d7d133 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::DependencyTimeoutException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::DependencyTimeoutException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::DependencyTimeoutException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs new file mode 100644 -index 00000000..14c5e6a7 +index 00000000..9cfcd3a7 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs @@ -0,0 +1,12 @@ @@ -591,16 +591,16 @@ index 00000000..14c5e6a7 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::DisabledException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::DisabledException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::DisabledException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs new file mode 100644 -index 00000000..99206d5b +index 00000000..487cb145 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs @@ -0,0 +1,12 @@ @@ -609,16 +609,16 @@ index 00000000..99206d5b +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::DryRunOperationException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::DryRunOperationException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::DryRunOperationException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs new file mode 100644 -index 00000000..42175b79 +index 00000000..6a2c6c50 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs @@ -0,0 +1,12 @@ @@ -627,16 +627,16 @@ index 00000000..42175b79 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::IncorrectKeyException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::IncorrectKeyException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::IncorrectKeyException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs new file mode 100644 -index 00000000..67a392ec +index 00000000..8de0704e --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs @@ -0,0 +1,12 @@ @@ -645,16 +645,16 @@ index 00000000..67a392ec +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::InvalidCiphertextException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::InvalidCiphertextException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::InvalidCiphertextException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs new file mode 100644 -index 00000000..7f3ca6f0 +index 00000000..2e406152 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs @@ -0,0 +1,12 @@ @@ -663,16 +663,16 @@ index 00000000..7f3ca6f0 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::InvalidGrantTokenException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::InvalidGrantTokenException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::InvalidGrantTokenException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs new file mode 100644 -index 00000000..b0f2bf08 +index 00000000..36bc1292 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs @@ -0,0 +1,12 @@ @@ -681,16 +681,16 @@ index 00000000..b0f2bf08 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::InvalidKeyUsageException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::InvalidKeyUsageException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::InvalidKeyUsageException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs new file mode 100644 -index 00000000..e38fa034 +index 00000000..20466e96 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs @@ -0,0 +1,12 @@ @@ -699,16 +699,16 @@ index 00000000..e38fa034 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::KeyUnavailableException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::KeyUnavailableException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::KeyUnavailableException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs new file mode 100644 -index 00000000..23938932 +index 00000000..1a239549 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs @@ -0,0 +1,12 @@ @@ -717,16 +717,16 @@ index 00000000..23938932 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::KmsInternalException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::KMSInternalException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::KMSInternalException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs new file mode 100644 -index 00000000..1f9c6404 +index 00000000..ec20b94f --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs @@ -0,0 +1,12 @@ @@ -735,16 +735,16 @@ index 00000000..1f9c6404 +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::KmsInvalidStateException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::KMSInvalidStateException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::KMSInvalidStateException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs new file mode 100644 -index 00000000..2956e9dc +index 00000000..e847930e --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs @@ -0,0 +1,12 @@ @@ -753,16 +753,16 @@ index 00000000..2956e9dc +#[allow(dead_code)] +pub fn to_dafny( + value: aws_sdk_kms::types::error::NotFoundException, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + ::std::rc::Rc::new( -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::NotFoundException { -+ message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::NotFoundException { ++ message: crate::standard_library_conversions::ostring_to_dafny(&value.message) + } + ) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs new file mode 100644 -index 00000000..e0fd2ad0 +index 00000000..061c384a --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs @@ -0,0 +1,41 @@ @@ -771,7 +771,7 @@ index 00000000..e0fd2ad0 +pub mod _generate_data_key_response; + +use aws_sdk_kms::error::SdkError; -+use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; ++use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; + +#[allow(dead_code)] +pub fn to_dafny_error( @@ -809,7 +809,7 @@ index 00000000..e0fd2ad0 +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs new file mode 100644 -index 00000000..e49a3e41 +index 00000000..6a7ffe06 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs @@ -0,0 +1,95 @@ @@ -818,52 +818,52 @@ index 00000000..e49a3e41 +pub fn to_dafny( + value: aws_sdk_kms::operation::generate_data_key::GenerateDataKeyInput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest::GenerateDataKeyRequest { -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id).Extract(), ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest::GenerateDataKeyRequest { ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id).Extract(), + EncryptionContext: + ::std::rc::Rc::new(match value.encryption_context() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), -+ NumberOfBytes: dafny_standard_library::conversion::oint_to_dafny(value.number_of_bytes), ++ NumberOfBytes: crate::standard_library_conversions::oint_to_dafny(value.number_of_bytes), + KeySpec: + ::std::rc::Rc::new(match value.key_spec() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { + value: crate::conversions::data_key_spec::to_dafny(x.clone()) + }, -+ _ => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ _ => crate::r#_Wrappers_Compile::Option::None {} + }), + GrantTokens: + ::std::rc::Rc::new( + // Have to clone or else this becomes a borrow that can interfere with other branches + match value.grant_tokens.clone() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), + Recipient: crate::conversions::recipient_info::option_to_dafny(value.recipient()), -+ DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), ++ DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), + }) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest, + >, + client: aws_sdk_kms::Client, +) -> aws_sdk_kms::operation::generate_data_key::builders::GenerateDataKeyFluentBuilder { @@ -874,7 +874,7 @@ index 00000000..e49a3e41 + ), + )) + .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -883,16 +883,16 @@ index 00000000..e49a3e41 + ), + _ => None + }) -+ .set_number_of_bytes(dafny_standard_library::conversion::oint_from_dafny(dafny_value.NumberOfBytes().clone())) ++ .set_number_of_bytes(crate::standard_library_conversions::oint_from_dafny(dafny_value.NumberOfBytes().clone())) + .set_key_spec(match &**dafny_value.KeySpec() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + crate::conversions::data_key_spec::from_dafny(value) + ), + _ => None + }) + .set_grant_tokens(match &**dafny_value.GrantTokens() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) @@ -900,17 +900,17 @@ index 00000000..e49a3e41 + _ => None + }) + .set_recipient(match &**dafny_value.Recipient() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + crate::conversions::recipient_info::from_dafny(value.clone()) + ), + _ => None + }) -+ .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) ++ .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs new file mode 100644 -index 00000000..d406550d +index 00000000..474f6be2 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs @@ -0,0 +1,16 @@ @@ -919,13 +919,13 @@ index 00000000..d406550d +pub fn to_dafny( + value: &aws_sdk_kms::operation::generate_data_key::GenerateDataKeyOutput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyResponse, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyResponse, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyResponse::GenerateDataKeyResponse { -+ CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob), -+ Plaintext: dafny_standard_library::conversion::oblob_to_dafny(&value.plaintext), -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), -+ CiphertextForRecipient: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_for_recipient), ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyResponse::GenerateDataKeyResponse { ++ CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob), ++ Plaintext: crate::standard_library_conversions::oblob_to_dafny(&value.plaintext), ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), ++ CiphertextForRecipient: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_for_recipient), + }) +} + @@ -933,7 +933,7 @@ index 00000000..d406550d \ No newline at end of file diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs new file mode 100644 -index 00000000..e9ea4318 +index 00000000..7a940fd8 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs @@ -0,0 +1,41 @@ @@ -942,7 +942,7 @@ index 00000000..e9ea4318 +pub mod _generate_data_key_without_plaintext_response; + +use aws_sdk_kms::error::SdkError; -+use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; ++use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; + +#[allow(dead_code)] +pub fn to_dafny_error( @@ -980,7 +980,7 @@ index 00000000..e9ea4318 +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs new file mode 100644 -index 00000000..6bda4aa0 +index 00000000..4e400f6f --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs @@ -0,0 +1,87 @@ @@ -989,51 +989,51 @@ index 00000000..6bda4aa0 +pub fn to_dafny( + value: aws_sdk_kms::operation::generate_data_key_without_plaintext::GenerateDataKeyWithoutPlaintextInput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextRequest, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest { -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id).Extract(), ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest { ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id).Extract(), + EncryptionContext: + ::std::rc::Rc::new(match value.encryption_context() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : + ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, + |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), + |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ None => crate::r#_Wrappers_Compile::Option::None {} + }), -+ NumberOfBytes: dafny_standard_library::conversion::oint_to_dafny(value.number_of_bytes), ++ NumberOfBytes: crate::standard_library_conversions::oint_to_dafny(value.number_of_bytes), + KeySpec: + ::std::rc::Rc::new(match value.key_spec() { -+ Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ Some(x) => crate::r#_Wrappers_Compile::Option::Some { + value: crate::conversions::data_key_spec::to_dafny(x.clone()) + }, -+ _ => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} ++ _ => crate::r#_Wrappers_Compile::Option::None {} + }), + GrantTokens: + ::std::rc::Rc::new( + // Have to clone or else this becomes a borrow that can interfere with other branches + match value.grant_tokens.clone() { + Some(val) => -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { ++ crate::r#_Wrappers_Compile::Option::Some { + value : ::dafny_runtime::Sequence::from_array( + &val.iter().map(|x| + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) + .collect() + ) + }, -+ None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} ++ None => crate::r#_Wrappers_Compile::Option::None{} + } + ), -+ DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), ++ DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), + }) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextRequest, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextRequest, + >, + client: aws_sdk_kms::Client +) -> aws_sdk_kms::operation::generate_data_key_without_plaintext::builders::GenerateDataKeyWithoutPlaintextFluentBuilder{ @@ -1044,7 +1044,7 @@ index 00000000..6bda4aa0 + ), + )) + .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -1053,27 +1053,27 @@ index 00000000..6bda4aa0 + ), + _ => None + }) -+ .set_number_of_bytes(dafny_standard_library::conversion::oint_from_dafny(dafny_value.NumberOfBytes().clone())) ++ .set_number_of_bytes(crate::standard_library_conversions::oint_from_dafny(dafny_value.NumberOfBytes().clone())) + .set_key_spec(match &**dafny_value.KeySpec() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + crate::conversions::data_key_spec::from_dafny(value) + ), + _ => None + }) + .set_grant_tokens(match &**dafny_value.GrantTokens() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => ++ crate::r#_Wrappers_Compile::Option::Some { value } => + Some( + ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, + dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) + ), + _ => None + }) -+ .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) ++ .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs new file mode 100644 -index 00000000..ed879b5c +index 00000000..6073f99a --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs @@ -0,0 +1,14 @@ @@ -1082,18 +1082,18 @@ index 00000000..ed879b5c +pub fn to_dafny( + value: &aws_sdk_kms::operation::generate_data_key_without_plaintext::GenerateDataKeyWithoutPlaintextOutput +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextResponse, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextResponse, +>{ -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse { -+ CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob), -+ KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), ++ ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse { ++ CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob), ++ KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), + }) +} + +// from_dafny ommitted to save time until we get to actual code generation diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs new file mode 100644 -index 00000000..220034fd +index 00000000..9191dc4c --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs @@ -0,0 +1,25 @@ @@ -1102,9 +1102,9 @@ index 00000000..220034fd + +pub fn to_dafny( + value: aws_sdk_kms::types::KeyEncryptionMechanism, -+) -> ::std::rc::Rc{ ++) -> ::std::rc::Rc{ + match value { -+ aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256 => ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {}), ++ aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256 => ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {}), + // TODO: This should not be a panic, but the Dafny image of the enum shape doesn't have an Unknown variant of any kind, + // so there's no way to succeed. + // See https://github.com/smithy-lang/smithy-dafny/issues/476. @@ -1116,15 +1116,15 @@ index 00000000..220034fd + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::KeyEncryptionMechanism, ++ dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::KeyEncryptionMechanism, +) -> aws_sdk_kms::types::KeyEncryptionMechanism { + match dafny_value { -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} => aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} => aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256, + } +} diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs new file mode 100644 -index 00000000..0b6d290b +index 00000000..45c18a6d --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs @@ -0,0 +1,89 @@ @@ -1135,17 +1135,17 @@ index 00000000..0b6d290b +pub fn to_dafny( + value: aws_sdk_kms::types::RecipientInfo, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, +>{ + ::std::rc::Rc::new(to_dafny_plain(&value)) +} + +pub fn to_dafny_plain( + value: &aws_sdk_kms::types::RecipientInfo, -+) -> crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo { -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo::RecipientInfo { -+ AttestationDocument: dafny_standard_library::conversion::oblob_to_dafny(&value.attestation_document), -+ KeyEncryptionAlgorithm: dafny_standard_library::conversion::option_to_dafny(&value.key_encryption_algorithm, ++) -> crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo { ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo::RecipientInfo { ++ AttestationDocument: crate::standard_library_conversions::oblob_to_dafny(&value.attestation_document), ++ KeyEncryptionAlgorithm: crate::standard_library_conversions::option_to_dafny(&value.key_encryption_algorithm, + |x| crate::conversions::key_encryption_mechanism::to_dafny(x.clone())) + } +} @@ -1153,15 +1153,15 @@ index 00000000..0b6d290b +pub fn option_to_dafny( + value: Option<&aws_sdk_kms::types::RecipientInfo>, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_Wrappers_Compile::Option< ++ crate::_Wrappers_Compile::Option< + ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, + >, + >, +>{ + let inner = match value { -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, -+ Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { ++ None => crate::_Wrappers_Compile::Option::None {}, ++ Some(x) => crate::_Wrappers_Compile::Option::Some { + value: ::std::rc::Rc::new(to_dafny_plain(x)), + }, + }; @@ -1171,15 +1171,15 @@ index 00000000..0b6d290b +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, ++ crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, + >, +) -> aws_sdk_kms::types::RecipientInfo { + aws_sdk_kms::types::RecipientInfo::builder() -+ .set_attestation_document(dafny_standard_library::conversion::oblob_from_dafny( ++ .set_attestation_document(crate::standard_library_conversions::oblob_from_dafny( + dafny_value.AttestationDocument().clone(), + )) + .set_key_encryption_algorithm(match &**dafny_value.KeyEncryptionAlgorithm() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => Some( ++ crate::r#_Wrappers_Compile::Option::Some { value } => Some( + crate::conversions::key_encryption_mechanism::from_dafny(value), + ), + _ => None, @@ -1189,14 +1189,14 @@ index 00000000..0b6d290b + +#[allow(dead_code)] +pub fn plain_from_dafny( -+ dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, ++ dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, +) -> aws_sdk_kms::types::RecipientInfo { + aws_sdk_kms::types::RecipientInfo::builder() -+ .set_attestation_document(dafny_standard_library::conversion::oblob_from_dafny( ++ .set_attestation_document(crate::standard_library_conversions::oblob_from_dafny( + dafny_value.AttestationDocument().clone(), + )) + .set_key_encryption_algorithm(match &**dafny_value.KeyEncryptionAlgorithm() { -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => Some( ++ crate::r#_Wrappers_Compile::Option::Some { value } => Some( + crate::conversions::key_encryption_mechanism::from_dafny(value), + ), + _ => None, @@ -1206,34 +1206,292 @@ index 00000000..0b6d290b + +#[allow(dead_code)] +pub fn option_from_dafny( -+ dafny_value: ::std::rc::Rc>>, +) -> Option { + match &*dafny_value { -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { ++ crate::_Wrappers_Compile::Option::Some { value } => { + Some(plain_from_dafny(value)) + } + _ => None, + } +} +diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs +index affa2a86..41f6c6fe 100644 +--- b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,10 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++mod client; ++mod conversions; ++mod standard_library_conversions; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..b5e77f9a +index 00000000..3c941cd5 --- /dev/null +++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs -@@ -0,0 +1,3 @@ +@@ -0,0 +1,4 @@ +mod client; +mod conversions; ++mod standard_library_conversions; +pub mod implementation_from_dafny; -diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs -index 1864a86b..f061a809 100644 ---- b/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs -+++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs -@@ -1,5 +1,6 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] -+use ::kms_lite::implementation_from_dafny::*; - - pub mod r#_TestComAmazonawsKms_Compile { - pub struct _default {} +diff --git b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/standard_library_conversions.rs a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/standard_library_conversions.rs +new file mode 100644 +index 00000000..2fec0ffb +--- /dev/null ++++ a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/standard_library_conversions.rs +@@ -0,0 +1,246 @@ ++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::Sequence::from_array(&input.clone().into_inner()) ++} ++ ++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>> { ++ 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>>, ++) -> 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) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/Cargo.toml b/TestModels/aws-sdks/kms-lite/runtimes/rust/Cargo.toml index e951448b3..1afbb21a9 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/Cargo.toml +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/Cargo.toml @@ -10,11 +10,13 @@ aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} aws-sdk-kms = "1.35.0" aws-config = "1.5.4" [dependencies.tokio] version = "1.26.0" -features = ["full"] \ No newline at end of file +features = ["full"] + +[lib] +path = "src/implementation_from_dafny.rs" diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs index b0091d983..762b58c73 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/client.rs @@ -10,65 +10,65 @@ impl dafny_runtime::UpcastObject for Client { ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); } -impl dafny_runtime::UpcastObject for Client { - ::dafny_runtime::UpcastObjectFn!(dyn crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient); +impl dafny_runtime::UpcastObject for Client { + ::dafny_runtime::UpcastObjectFn!(dyn crate::r#software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient); } -impl crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient +impl crate::r#software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient for Client { - fn Decrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn Decrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { let native_result = self.rt.block_on(conversions::decrypt::_decrypt_request::from_dafny(input.clone(), self.inner.clone()).send()); - dafny_standard_library::conversion::result_to_dafny(&native_result, + crate::standard_library_conversions::result_to_dafny(&native_result, conversions::decrypt::_decrypt_response::to_dafny, conversions::decrypt::to_dafny_error) } - fn Encrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn Encrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { let native_result = self.rt.block_on(conversions::encrypt::_encrypt_request::from_dafny(input.clone(), self.inner.clone()).send()); - dafny_standard_library::conversion::result_to_dafny(&native_result, + crate::standard_library_conversions::result_to_dafny(&native_result, conversions::encrypt::_encrypt_response::to_dafny, conversions::encrypt::to_dafny_error) } - fn GenerateDataKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn GenerateDataKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { let native_result = self.rt.block_on(conversions::generate_data_key::_generate_data_key_request::from_dafny(input.clone(), self.inner.clone()).send()); - dafny_standard_library::conversion::result_to_dafny(&native_result, + crate::standard_library_conversions::result_to_dafny(&native_result, conversions::generate_data_key::_generate_data_key_response::to_dafny, conversions::generate_data_key::to_dafny_error) } - fn GenerateDataKeyWithoutPlaintext(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn GenerateDataKeyWithoutPlaintext(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { let native_result = self.rt.block_on(conversions::generate_data_key_without_plaintext::_generate_data_key_without_plaintext_request::from_dafny(input.clone(), self.inner.clone()).send()); - dafny_standard_library::conversion::result_to_dafny(&native_result, + crate::standard_library_conversions::result_to_dafny(&native_result, conversions::generate_data_key_without_plaintext::_generate_data_key_without_plaintext_response::to_dafny, conversions::generate_data_key_without_plaintext::to_dafny_error) } // Leaving untested operations out for now - fn DeriveSharedSecret(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn DeriveSharedSecret(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { todo!() } - fn GetPublicKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn GetPublicKey(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { todo!() } - fn ReEncrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { + fn ReEncrypt(&mut self, input: &std::rc::Rc) -> std::rc::Rc, std::rc::Rc>> { todo!() } } #[allow(non_snake_case)] -impl crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny::_default { +impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_default { pub fn KMSClient() -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object, - ::std::rc::Rc + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object, + ::std::rc::Rc > > { let rt_result = tokio::runtime::Builder::new_current_thread() @@ -83,6 +83,6 @@ impl crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservic let inner = aws_sdk_kms::Client::new(&shared_config); let client = Client { inner, rt }; let dafny_client = ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(client)); - std::rc::Rc::new(crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { value: dafny_client }) + std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::Success { value: dafny_client }) } } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs index 249050328..deadcdda5 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/data_key_spec.rs @@ -3,20 +3,20 @@ pub fn to_dafny( value: aws_sdk_kms::types::DataKeySpec, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new(match value { - aws_sdk_kms::types::DataKeySpec::Aes128 => crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_128 {}, - aws_sdk_kms::types::DataKeySpec::Aes256 => crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_256 {}, + aws_sdk_kms::types::DataKeySpec::Aes128 => crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_128 {}, + aws_sdk_kms::types::DataKeySpec::Aes256 => crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_256 {}, _ => panic!() }) } #[allow(dead_code)] pub fn from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec, + dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec, ) -> aws_sdk_kms::types::DataKeySpec { match dafny_value { - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_128 {} => aws_sdk_kms::types::DataKeySpec::Aes128, - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DataKeySpec::AES_256 {} => aws_sdk_kms::types::DataKeySpec::Aes256, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_128 {} => aws_sdk_kms::types::DataKeySpec::Aes128, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DataKeySpec::AES_256 {} => aws_sdk_kms::types::DataKeySpec::Aes256, } } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs index 68c7b13f8..fe0708d26 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt.rs @@ -3,7 +3,7 @@ pub mod _decrypt_request; pub mod _decrypt_response; use aws_sdk_kms::error::SdkError; -use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; +use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; #[allow(dead_code)] pub fn to_dafny_error( diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs index 7bf5704df..0fbf835cd 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_request.rs @@ -3,41 +3,41 @@ pub fn to_dafny( value: aws_sdk_kms::operation::decrypt::DecryptInput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest::DecryptRequest { - CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob).Extract(), - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest::DecryptRequest { + CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob).Extract(), + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), EncryptionContext: ::std::rc::Rc::new(match value.encryption_context() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), GrantTokens: ::std::rc::Rc::new( // Have to clone or else this becomes a borrow that can interfere with other branches match value.grant_tokens.clone() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), Recipient: crate::conversions::recipient_info::option_to_dafny(value.recipient()), - DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), + DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), EncryptionAlgorithm: ::std::rc::Rc::new(match value.encryption_algorithm { - Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None { } + Some(x) => crate::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, + None => crate::_Wrappers_Compile::Option::None { } }) }) } @@ -45,18 +45,18 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest, >, client: aws_sdk_kms::Client, ) -> aws_sdk_kms::operation::decrypt::builders::DecryptFluentBuilder { client.decrypt() .set_ciphertext_blob(Some( - dafny_standard_library::conversion::blob_from_dafny(dafny_value.CiphertextBlob().clone()))) + crate::standard_library_conversions::blob_from_dafny(dafny_value.CiphertextBlob().clone()))) .set_key_id( - dafny_standard_library::conversion::ostring_from_dafny(dafny_value.KeyId().clone()), + crate::standard_library_conversions::ostring_from_dafny(dafny_value.KeyId().clone()), ) .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -66,7 +66,7 @@ pub fn from_dafny( _ => None }) .set_grant_tokens(match &**dafny_value.GrantTokens() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) @@ -74,15 +74,15 @@ pub fn from_dafny( _ => None }) .set_recipient(match &**dafny_value.Recipient() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( crate::conversions::recipient_info::from_dafny(value.clone()) ), _ => None }) - .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) + .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) .set_encryption_algorithm( - dafny_standard_library::conversion::option_from_dafny( + crate::standard_library_conversions::option_from_dafny( dafny_value.EncryptionAlgorithm().clone(), |x| crate::conversions::encryption_algorithm_spec::from_dafny(x))) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs index bc89ab27c..b185a5900 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/decrypt/_decrypt_response.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: &aws_sdk_kms::operation::decrypt::DecryptOutput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptResponse, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptResponse, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptResponse::DecryptResponse { - Plaintext: dafny_standard_library::conversion::oblob_to_dafny(&value.plaintext), - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), - CiphertextForRecipient: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_for_recipient), - EncryptionAlgorithm: dafny_standard_library::conversion::option_to_dafny(&value.encryption_algorithm, + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::DecryptResponse::DecryptResponse { + Plaintext: crate::standard_library_conversions::oblob_to_dafny(&value.plaintext), + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), + CiphertextForRecipient: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_for_recipient), + EncryptionAlgorithm: crate::standard_library_conversions::option_to_dafny(&value.encryption_algorithm, |x| crate::conversions::encryption_algorithm_spec::to_dafny(x.clone())), }) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs index 3620a36fb..1dffbe0bf 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt.rs @@ -3,7 +3,7 @@ pub mod _encrypt_request; pub mod _encrypt_response; use aws_sdk_kms::error::SdkError; -use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; +use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; #[allow(dead_code)] pub fn to_dafny_error( diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs index 936569ca9..42cdae131 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_request.rs @@ -3,40 +3,40 @@ pub fn to_dafny( value: aws_sdk_kms::operation::encrypt::EncryptInput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest::EncryptRequest { - Plaintext: dafny_standard_library::conversion::oblob_to_dafny(&value.plaintext).Extract(), - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id).Extract(), + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest::EncryptRequest { + Plaintext: crate::standard_library_conversions::oblob_to_dafny(&value.plaintext).Extract(), + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id).Extract(), EncryptionContext: ::std::rc::Rc::new(match value.encryption_context() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), GrantTokens: ::std::rc::Rc::new( // Have to clone or else this becomes a borrow that can interfere with other branches match value.grant_tokens.clone() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), - DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), + DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), EncryptionAlgorithm: ::std::rc::Rc::new(match value.encryption_algorithm { - Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None { } + Some(x) => crate::_Wrappers_Compile::Option::Some { value: crate::conversions::encryption_algorithm_spec::to_dafny(x) }, + None => crate::_Wrappers_Compile::Option::None { } }) }) } @@ -44,17 +44,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest, >, client: aws_sdk_kms::Client, ) -> aws_sdk_kms::operation::encrypt::builders::EncryptFluentBuilder { client.encrypt() - .set_plaintext(Some(dafny_standard_library::conversion::blob_from_dafny(dafny_value.Plaintext().clone()))) + .set_plaintext(Some(crate::standard_library_conversions::blob_from_dafny(dafny_value.Plaintext().clone()))) .set_key_id(Some( dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(dafny_value.KeyId())), ) .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -64,16 +64,16 @@ pub fn from_dafny( _ => None }) .set_grant_tokens(match &**dafny_value.GrantTokens() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) ), _ => None }) - .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) + .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) .set_encryption_algorithm( - dafny_standard_library::conversion::option_from_dafny( + crate::standard_library_conversions::option_from_dafny( dafny_value.EncryptionAlgorithm().clone(), |x| crate::conversions::encryption_algorithm_spec::from_dafny(x))) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs index 9a5c55dc6..b8e0f5863 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encrypt/_encrypt_response.rs @@ -3,12 +3,12 @@ pub fn to_dafny( value: &aws_sdk_kms::operation::encrypt::EncryptOutput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptResponse, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptResponse, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptResponse::EncryptResponse { - CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob), - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), - EncryptionAlgorithm: dafny_standard_library::conversion::option_to_dafny(&value.encryption_algorithm, + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptResponse::EncryptResponse { + CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob), + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), + EncryptionAlgorithm: crate::standard_library_conversions::option_to_dafny(&value.encryption_algorithm, |x| crate::conversions::encryption_algorithm_spec::to_dafny(x.clone())), }) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs index 304f1ac01..0328c46b3 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/encryption_algorithm_spec.rs @@ -3,14 +3,14 @@ pub fn to_dafny( value: aws_sdk_kms::types::EncryptionAlgorithmSpec, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new(match value { aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha1 => - crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { }, + crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { }, aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256 => - crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { }, + crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { }, aws_sdk_kms::types::EncryptionAlgorithmSpec::SymmetricDefault => - crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { }, + crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { }, // TODO: This should not be a panic, but the Dafny image of the enum shape doesn't have an Unknown variant of any kind, // so there's no way to succeed. // See https://github.com/smithy-lang/smithy-dafny/issues/476. @@ -22,11 +22,11 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec, + dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec, ) -> aws_sdk_kms::types::EncryptionAlgorithmSpec { match dafny_value { - crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::SymmetricDefault, - crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha1, - crate::implementation_from_dafny::_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256, + crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::SymmetricDefault, + crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha1, + crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 { } => aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256, } } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs index d844a1c71..d59e6fed5 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error.rs @@ -22,13 +22,13 @@ pub mod not_found_exception; /// Wraps up an arbitrary Rust Error value as a Dafny Error pub fn to_opaque_error(value: E) -> - ::std::rc::Rc + ::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::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::Opaque { + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::Opaque { obj: error_obj, }, ) @@ -37,14 +37,14 @@ pub fn to_opaque_error(value: E) -> /// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure pub fn to_opaque_error_result(value: E) -> ::std::rc::Rc< - dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result< + crate::_Wrappers_Compile::Result< T, - ::std::rc::Rc + ::std::rc::Rc > > { ::std::rc::Rc::new( - dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + crate::_Wrappers_Compile::Result::Failure { error: to_opaque_error(value), }, ) diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs index b2d7d133c..4576a6d63 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dependency_timeout_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::DependencyTimeoutException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::DependencyTimeoutException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::DependencyTimeoutException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs index 14c5e6a70..9cfcd3a72 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/disabled_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::DisabledException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::DisabledException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::DisabledException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs index 99206d5b8..487cb1458 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/dry_run_operation_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::DryRunOperationException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::DryRunOperationException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::DryRunOperationException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs index 42175b791..6a2c6c501 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/incorrect_key_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::IncorrectKeyException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::IncorrectKeyException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::IncorrectKeyException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs index 67a392ec9..8de0704e8 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_ciphertext_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::InvalidCiphertextException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::InvalidCiphertextException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::InvalidCiphertextException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs index 7f3ca6f0d..2e4061526 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_grant_token_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::InvalidGrantTokenException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::InvalidGrantTokenException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::InvalidGrantTokenException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs index b0f2bf08e..36bc12926 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/invalid_key_usage_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::InvalidKeyUsageException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::InvalidKeyUsageException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::InvalidKeyUsageException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs index e38fa034c..20466e966 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/key_unavailable_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::KeyUnavailableException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::KeyUnavailableException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::KeyUnavailableException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs index 239389320..1a2395496 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_internal_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::KmsInternalException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::KMSInternalException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::KMSInternalException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs index 1f9c64046..ec20b94f4 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/kms_invalid_state_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::KmsInvalidStateException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::KMSInvalidStateException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::KMSInvalidStateException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs index 2956e9dc4..e847930e0 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/error/not_found_exception.rs @@ -3,10 +3,10 @@ #[allow(dead_code)] pub fn to_dafny( value: aws_sdk_kms::types::error::NotFoundException, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ ::std::rc::Rc::new( - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::Error::NotFoundException { - message: dafny_standard_library::conversion::ostring_to_dafny(&value.message) + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::Error::NotFoundException { + message: crate::standard_library_conversions::ostring_to_dafny(&value.message) } ) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs index e0fd2ad05..061c384a4 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key.rs @@ -3,7 +3,7 @@ pub mod _generate_data_key_request; pub mod _generate_data_key_response; use aws_sdk_kms::error::SdkError; -use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; +use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; #[allow(dead_code)] pub fn to_dafny_error( diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs index e49a3e415..6a7ffe06e 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_request.rs @@ -3,52 +3,52 @@ pub fn to_dafny( value: aws_sdk_kms::operation::generate_data_key::GenerateDataKeyInput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest::GenerateDataKeyRequest { - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id).Extract(), + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id).Extract(), EncryptionContext: ::std::rc::Rc::new(match value.encryption_context() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), - NumberOfBytes: dafny_standard_library::conversion::oint_to_dafny(value.number_of_bytes), + NumberOfBytes: crate::standard_library_conversions::oint_to_dafny(value.number_of_bytes), KeySpec: ::std::rc::Rc::new(match value.key_spec() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value: crate::conversions::data_key_spec::to_dafny(x.clone()) }, - _ => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + _ => crate::r#_Wrappers_Compile::Option::None {} }), GrantTokens: ::std::rc::Rc::new( // Have to clone or else this becomes a borrow that can interfere with other branches match value.grant_tokens.clone() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), Recipient: crate::conversions::recipient_info::option_to_dafny(value.recipient()), - DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), + DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), }) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest, >, client: aws_sdk_kms::Client, ) -> aws_sdk_kms::operation::generate_data_key::builders::GenerateDataKeyFluentBuilder { @@ -59,7 +59,7 @@ pub fn from_dafny( ), )) .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -68,16 +68,16 @@ pub fn from_dafny( ), _ => None }) - .set_number_of_bytes(dafny_standard_library::conversion::oint_from_dafny(dafny_value.NumberOfBytes().clone())) + .set_number_of_bytes(crate::standard_library_conversions::oint_from_dafny(dafny_value.NumberOfBytes().clone())) .set_key_spec(match &**dafny_value.KeySpec() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( crate::conversions::data_key_spec::from_dafny(value) ), _ => None }) .set_grant_tokens(match &**dafny_value.GrantTokens() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) @@ -85,11 +85,11 @@ pub fn from_dafny( _ => None }) .set_recipient(match &**dafny_value.Recipient() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( crate::conversions::recipient_info::from_dafny(value.clone()) ), _ => None }) - .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) + .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs index d406550db..474f6be24 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key/_generate_data_key_response.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: &aws_sdk_kms::operation::generate_data_key::GenerateDataKeyOutput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyResponse, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyResponse, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyResponse::GenerateDataKeyResponse { - CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob), - Plaintext: dafny_standard_library::conversion::oblob_to_dafny(&value.plaintext), - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), - CiphertextForRecipient: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_for_recipient), + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob), + Plaintext: crate::standard_library_conversions::oblob_to_dafny(&value.plaintext), + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), + CiphertextForRecipient: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_for_recipient), }) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs index e9ea4318b..7a940fd8d 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext.rs @@ -3,7 +3,7 @@ pub mod _generate_data_key_without_plaintext_request; pub mod _generate_data_key_without_plaintext_response; use aws_sdk_kms::error::SdkError; -use crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::*; +use crate::r#software::amazon::cryptography::services::kms::internaldafny::types::*; #[allow(dead_code)] pub fn to_dafny_error( diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs index 6bda4aa02..4e400f6f2 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_request.rs @@ -3,51 +3,51 @@ pub fn to_dafny( value: aws_sdk_kms::operation::generate_data_key_without_plaintext::GenerateDataKeyWithoutPlaintextInput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextRequest, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest { - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id).Extract(), + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest { + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id).Extract(), EncryptionContext: ::std::rc::Rc::new(match value.encryption_context() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value : + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, |k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(k), |v| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(v), ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + None => crate::r#_Wrappers_Compile::Option::None {} }), - NumberOfBytes: dafny_standard_library::conversion::oint_to_dafny(value.number_of_bytes), + NumberOfBytes: crate::standard_library_conversions::oint_to_dafny(value.number_of_bytes), KeySpec: ::std::rc::Rc::new(match value.key_spec() { - Some(x) => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + Some(x) => crate::r#_Wrappers_Compile::Option::Some { value: crate::conversions::data_key_spec::to_dafny(x.clone()) }, - _ => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None {} + _ => crate::r#_Wrappers_Compile::Option::None {} }), GrantTokens: ::std::rc::Rc::new( // Have to clone or else this becomes a borrow that can interfere with other branches match value.grant_tokens.clone() { Some(val) => - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { + crate::r#_Wrappers_Compile::Option::Some { value : ::dafny_runtime::Sequence::from_array( &val.iter().map(|x| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(x)) .collect() ) }, - None => crate::implementation_from_dafny::r#_Wrappers_Compile::Option::None{} + None => crate::r#_Wrappers_Compile::Option::None{} } ), - DryRun: dafny_standard_library::conversion::obool_to_dafny(value.dry_run), + DryRun: crate::standard_library_conversions::obool_to_dafny(value.dry_run), }) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextRequest, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextRequest, >, client: aws_sdk_kms::Client ) -> aws_sdk_kms::operation::generate_data_key_without_plaintext::builders::GenerateDataKeyWithoutPlaintextFluentBuilder{ @@ -58,7 +58,7 @@ pub fn from_dafny( ), )) .set_encryption_context( match (*dafny_value.EncryptionContext()).as_ref() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, @@ -67,21 +67,21 @@ pub fn from_dafny( ), _ => None }) - .set_number_of_bytes(dafny_standard_library::conversion::oint_from_dafny(dafny_value.NumberOfBytes().clone())) + .set_number_of_bytes(crate::standard_library_conversions::oint_from_dafny(dafny_value.NumberOfBytes().clone())) .set_key_spec(match &**dafny_value.KeySpec() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( crate::conversions::data_key_spec::from_dafny(value) ), _ => None }) .set_grant_tokens(match &**dafny_value.GrantTokens() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => + crate::r#_Wrappers_Compile::Option::Some { value } => Some( ::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(value, dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) ), _ => None }) - .set_dry_run(dafny_standard_library::conversion::obool_from_dafny(dafny_value.DryRun().clone())) + .set_dry_run(crate::standard_library_conversions::obool_from_dafny(dafny_value.DryRun().clone())) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs index ed879b5c7..6073f99ae 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/generate_data_key_without_plaintext/_generate_data_key_without_plaintext_response.rs @@ -3,11 +3,11 @@ pub fn to_dafny( value: &aws_sdk_kms::operation::generate_data_key_without_plaintext::GenerateDataKeyWithoutPlaintextOutput ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextResponse, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextResponse, >{ - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse { - CiphertextBlob: dafny_standard_library::conversion::oblob_to_dafny(&value.ciphertext_blob), - KeyId: dafny_standard_library::conversion::ostring_to_dafny(&value.key_id), + ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse { + CiphertextBlob: crate::standard_library_conversions::oblob_to_dafny(&value.ciphertext_blob), + KeyId: crate::standard_library_conversions::ostring_to_dafny(&value.key_id), }) } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs index 220034fdd..9191dc4ce 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/key_encryption_mechanism.rs @@ -3,9 +3,9 @@ pub fn to_dafny( value: aws_sdk_kms::types::KeyEncryptionMechanism, -) -> ::std::rc::Rc{ +) -> ::std::rc::Rc{ match value { - aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256 => ::std::rc::Rc::new(crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {}), + aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256 => ::std::rc::Rc::new(crate::r#software::amazon::cryptography::services::kms::internaldafny::types::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {}), // TODO: This should not be a panic, but the Dafny image of the enum shape doesn't have an Unknown variant of any kind, // so there's no way to succeed. // See https://github.com/smithy-lang/smithy-dafny/issues/476. @@ -17,9 +17,9 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::KeyEncryptionMechanism, + dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::KeyEncryptionMechanism, ) -> aws_sdk_kms::types::KeyEncryptionMechanism { match dafny_value { - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} => aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} => aws_sdk_kms::types::KeyEncryptionMechanism::RsaesOaepSha256, } } diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs index 0b6d290b6..45c18a6d9 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/conversions/recipient_info.rs @@ -5,17 +5,17 @@ use aws_sdk_kms::types::KeyEncryptionMechanism; pub fn to_dafny( value: aws_sdk_kms::types::RecipientInfo, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, >{ ::std::rc::Rc::new(to_dafny_plain(&value)) } pub fn to_dafny_plain( value: &aws_sdk_kms::types::RecipientInfo, -) -> crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo { - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo::RecipientInfo { - AttestationDocument: dafny_standard_library::conversion::oblob_to_dafny(&value.attestation_document), - KeyEncryptionAlgorithm: dafny_standard_library::conversion::option_to_dafny(&value.key_encryption_algorithm, +) -> crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo { + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo::RecipientInfo { + AttestationDocument: crate::standard_library_conversions::oblob_to_dafny(&value.attestation_document), + KeyEncryptionAlgorithm: crate::standard_library_conversions::option_to_dafny(&value.key_encryption_algorithm, |x| crate::conversions::key_encryption_mechanism::to_dafny(x.clone())) } } @@ -23,15 +23,15 @@ pub fn to_dafny_plain( pub fn option_to_dafny( value: Option<&aws_sdk_kms::types::RecipientInfo>, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_Wrappers_Compile::Option< + crate::_Wrappers_Compile::Option< ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, >, >, >{ let inner = match value { - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, - Some(x) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { + None => crate::_Wrappers_Compile::Option::None {}, + Some(x) => crate::_Wrappers_Compile::Option::Some { value: ::std::rc::Rc::new(to_dafny_plain(x)), }, }; @@ -41,15 +41,15 @@ pub fn option_to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, + crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, >, ) -> aws_sdk_kms::types::RecipientInfo { aws_sdk_kms::types::RecipientInfo::builder() - .set_attestation_document(dafny_standard_library::conversion::oblob_from_dafny( + .set_attestation_document(crate::standard_library_conversions::oblob_from_dafny( dafny_value.AttestationDocument().clone(), )) .set_key_encryption_algorithm(match &**dafny_value.KeyEncryptionAlgorithm() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => Some( + crate::r#_Wrappers_Compile::Option::Some { value } => Some( crate::conversions::key_encryption_mechanism::from_dafny(value), ), _ => None, @@ -59,14 +59,14 @@ pub fn from_dafny( #[allow(dead_code)] pub fn plain_from_dafny( - dafny_value: &crate::implementation_from_dafny::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::RecipientInfo, + dafny_value: &crate::r#software::amazon::cryptography::services::kms::internaldafny::types::RecipientInfo, ) -> aws_sdk_kms::types::RecipientInfo { aws_sdk_kms::types::RecipientInfo::builder() - .set_attestation_document(dafny_standard_library::conversion::oblob_from_dafny( + .set_attestation_document(crate::standard_library_conversions::oblob_from_dafny( dafny_value.AttestationDocument().clone(), )) .set_key_encryption_algorithm(match &**dafny_value.KeyEncryptionAlgorithm() { - crate::implementation_from_dafny::r#_Wrappers_Compile::Option::Some { value } => Some( + crate::r#_Wrappers_Compile::Option::Some { value } => Some( crate::conversions::key_encryption_mechanism::from_dafny(value), ), _ => None, @@ -76,12 +76,12 @@ pub fn plain_from_dafny( #[allow(dead_code)] pub fn option_from_dafny( - dafny_value: ::std::rc::Rc>>, ) -> Option { match &*dafny_value { - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value } => { + crate::_Wrappers_Compile::Option::Some { value } => { Some(plain_from_dafny(value)) } _ => None, diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..41f6c6fe4 --- /dev/null +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,5718 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +mod client; +mod conversions; +mod standard_library_conversions; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod software { + pub mod amazon { + pub mod cryptography { + pub mod services { + pub mod kms { + pub mod internaldafny { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn DefaultKMSClientConfigType() -> ::std::rc::Rc{ + ::std::rc::Rc::new(crate::software::amazon::cryptography::services::kms::internaldafny::KMSClientConfigType::KMSClientConfigType {}) + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + #[derive(PartialEq, Clone)] + pub enum KMSClientConfigType { + KMSClientConfigType {}, + } + + impl KMSClientConfigType {} + + impl Debug for KMSClientConfigType { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for KMSClientConfigType { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + KMSClientConfigType::KMSClientConfigType {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.KMSClientConfigType.KMSClientConfigType")?; + Ok(()) + } + } + } + } + + impl Eq for KMSClientConfigType {} + + impl Hash for KMSClientConfigType { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + KMSClientConfigType::KMSClientConfigType {} => {} + } + } + } + + impl Default for KMSClientConfigType { + fn default() -> KMSClientConfigType { + KMSClientConfigType::KMSClientConfigType {} + } + } + + impl AsRef for &KMSClientConfigType { + fn as_ref(&self) -> Self { + self + } + } + + pub mod types { + pub use dafny_runtime::DafnyPrint; + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn IsValid_AttestationDocumentType( + x: &::dafny_runtime::Sequence, + ) -> bool { + ::dafny_runtime::int!(1) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(b"262144") + } + pub fn IsValid_CiphertextType( + x: &::dafny_runtime::Sequence, + ) -> bool { + ::dafny_runtime::int!(1) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(6144) + } + pub fn IsValid_GrantTokenList( + x: &::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + ) -> bool { + ::dafny_runtime::int!(0) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(10) + } + pub fn IsValid_GrantTokenType( + x: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + ::dafny_runtime::int!(1) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(8192) + } + pub fn IsValid_KeyIdType( + x: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + ::dafny_runtime::int!(1) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(2048) + } + pub fn IsValid_NumberOfBytesType(x: i32) -> bool { + 1 <= x && x <= 1024 + } + pub fn IsValid_PlaintextType( + x: &::dafny_runtime::Sequence, + ) -> bool { + ::dafny_runtime::int!(1) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(4096) + } + pub fn IsValid_PublicKeyType( + x: &::dafny_runtime::Sequence, + ) -> bool { + ::dafny_runtime::int!(1) <= x.cardinality() + && x.cardinality() <= ::dafny_runtime::int!(8192) + } + } + + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent< + I: ::dafny_runtime::DafnyType, + O: ::dafny_runtime::DafnyType, + > { + DafnyCallEvent { input: I, output: O }, + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + } + } + } + + impl Debug for DafnyCallEvent { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl + DafnyPrint for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + input, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + output, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Eq, + O: ::dafny_runtime::DafnyType + Eq, + > Eq for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + Hash, + O: ::dafny_runtime::DafnyType + Hash, + > Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + ::std::hash::Hash::hash(input, _state); + ::std::hash::Hash::hash(output, _state) + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + Default, + O: ::dafny_runtime::DafnyType + Default, + > Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + pub type AttestationDocumentType = ::dafny_runtime::Sequence; + + pub type CiphertextType = ::dafny_runtime::Sequence; + + #[derive(PartialEq, Clone)] + pub enum CustomerMasterKeySpec { + RSA_2048 {}, + RSA_3072 {}, + RSA_4096 {}, + ECC_NIST_P256 {}, + ECC_NIST_P384 {}, + ECC_NIST_P521 {}, + ECC_SECG_P256K1 {}, + SYMMETRIC_DEFAULT {}, + HMAC_224 {}, + HMAC_256 {}, + HMAC_384 {}, + HMAC_512 {}, + SM2 {}, + } + + impl CustomerMasterKeySpec {} + + impl Debug for CustomerMasterKeySpec { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for CustomerMasterKeySpec { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + CustomerMasterKeySpec::RSA_2048 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.RSA__2048")?; + Ok(()) + } + CustomerMasterKeySpec::RSA_3072 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.RSA__3072")?; + Ok(()) + } + CustomerMasterKeySpec::RSA_4096 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.RSA__4096")?; + Ok(()) + } + CustomerMasterKeySpec::ECC_NIST_P256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.ECC__NIST__P256")?; + Ok(()) + } + CustomerMasterKeySpec::ECC_NIST_P384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.ECC__NIST__P384")?; + Ok(()) + } + CustomerMasterKeySpec::ECC_NIST_P521 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.ECC__NIST__P521")?; + Ok(()) + } + CustomerMasterKeySpec::ECC_SECG_P256K1 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.ECC__SECG__P256K1")?; + Ok(()) + } + CustomerMasterKeySpec::SYMMETRIC_DEFAULT {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.SYMMETRIC__DEFAULT")?; + Ok(()) + } + CustomerMasterKeySpec::HMAC_224 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.HMAC__224")?; + Ok(()) + } + CustomerMasterKeySpec::HMAC_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.HMAC__256")?; + Ok(()) + } + CustomerMasterKeySpec::HMAC_384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.HMAC__384")?; + Ok(()) + } + CustomerMasterKeySpec::HMAC_512 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.HMAC__512")?; + Ok(()) + } + CustomerMasterKeySpec::SM2 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.CustomerMasterKeySpec.SM2")?; + Ok(()) + } + } + } + } + + impl Eq for CustomerMasterKeySpec {} + + impl Hash for CustomerMasterKeySpec { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + CustomerMasterKeySpec::RSA_2048 {} => {} + CustomerMasterKeySpec::RSA_3072 {} => {} + CustomerMasterKeySpec::RSA_4096 {} => {} + CustomerMasterKeySpec::ECC_NIST_P256 {} => {} + CustomerMasterKeySpec::ECC_NIST_P384 {} => {} + CustomerMasterKeySpec::ECC_NIST_P521 {} => {} + CustomerMasterKeySpec::ECC_SECG_P256K1 {} => {} + CustomerMasterKeySpec::SYMMETRIC_DEFAULT {} => {} + CustomerMasterKeySpec::HMAC_224 {} => {} + CustomerMasterKeySpec::HMAC_256 {} => {} + CustomerMasterKeySpec::HMAC_384 {} => {} + CustomerMasterKeySpec::HMAC_512 {} => {} + CustomerMasterKeySpec::SM2 {} => {} + } + } + } + + impl Default for CustomerMasterKeySpec { + fn default() -> CustomerMasterKeySpec { + CustomerMasterKeySpec::RSA_2048 {} + } + } + + impl AsRef for &CustomerMasterKeySpec { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum DataKeySpec { + AES_256 {}, + AES_128 {}, + } + + impl DataKeySpec {} + + impl Debug for DataKeySpec { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for DataKeySpec { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DataKeySpec::AES_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DataKeySpec.AES__256")?; + Ok(()) + } + DataKeySpec::AES_128 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DataKeySpec.AES__128")?; + Ok(()) + } + } + } + } + + impl Eq for DataKeySpec {} + + impl Hash for DataKeySpec { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DataKeySpec::AES_256 {} => {} + DataKeySpec::AES_128 {} => {} + } + } + } + + impl Default for DataKeySpec { + fn default() -> DataKeySpec { + DataKeySpec::AES_256 {} + } + } + + impl AsRef for &DataKeySpec { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum DecryptRequest { + DecryptRequest { + CiphertextBlob: crate::software::amazon::cryptography::services::kms::internaldafny::types::CiphertextType, + EncryptionContext: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + GrantTokens: ::std::rc::Rc>, + KeyId: ::std::rc::Rc>>, + EncryptionAlgorithm: ::std::rc::Rc>>, + Recipient: ::std::rc::Rc>>, + DryRun: ::std::rc::Rc> + } + } + + impl DecryptRequest { + pub fn CiphertextBlob(&self) -> &crate::software::amazon::cryptography::services::kms::internaldafny::types::CiphertextType{ + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => CiphertextBlob, + } + } + pub fn EncryptionContext( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + > { + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => EncryptionContext, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => GrantTokens, + } + } + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => KeyId, + } + } + pub fn EncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => EncryptionAlgorithm, + } + } + pub fn Recipient(&self) -> &::std::rc::Rc>>{ + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => Recipient, + } + } + pub fn DryRun( + &self, + ) -> &::std::rc::Rc> + { + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => DryRun, + } + } + } + + impl Debug for DecryptRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for DecryptRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DecryptRequest.DecryptRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextBlob, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionContext, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + GrantTokens, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + Recipient, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DryRun, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for DecryptRequest {} + + impl Hash for DecryptRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DecryptRequest::DecryptRequest { + CiphertextBlob, + EncryptionContext, + GrantTokens, + KeyId, + EncryptionAlgorithm, + Recipient, + DryRun, + } => { + ::std::hash::Hash::hash(CiphertextBlob, _state); + ::std::hash::Hash::hash(EncryptionContext, _state); + ::std::hash::Hash::hash(GrantTokens, _state); + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(EncryptionAlgorithm, _state); + ::std::hash::Hash::hash(Recipient, _state); + ::std::hash::Hash::hash(DryRun, _state) + } + } + } + } + + impl Default for DecryptRequest { + fn default() -> DecryptRequest { + DecryptRequest::DecryptRequest { + CiphertextBlob: ::std::default::Default::default(), + EncryptionContext: ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + KeyId: ::std::default::Default::default(), + EncryptionAlgorithm: ::std::default::Default::default(), + Recipient: ::std::default::Default::default(), + DryRun: ::std::default::Default::default(), + } + } + } + + impl AsRef for &DecryptRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum DecryptResponse { + DecryptResponse { + KeyId: ::std::rc::Rc>>, + Plaintext: ::std::rc::Rc>, + EncryptionAlgorithm: ::std::rc::Rc>>, + CiphertextForRecipient: ::std::rc::Rc> + } + } + + impl DecryptResponse { + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + DecryptResponse::DecryptResponse { + KeyId, + Plaintext, + EncryptionAlgorithm, + CiphertextForRecipient, + } => KeyId, + } + } + pub fn Plaintext(&self) -> &::std::rc::Rc>{ + match self { + DecryptResponse::DecryptResponse { + KeyId, + Plaintext, + EncryptionAlgorithm, + CiphertextForRecipient, + } => Plaintext, + } + } + pub fn EncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + DecryptResponse::DecryptResponse { + KeyId, + Plaintext, + EncryptionAlgorithm, + CiphertextForRecipient, + } => EncryptionAlgorithm, + } + } + pub fn CiphertextForRecipient(&self) -> &::std::rc::Rc>{ + match self { + DecryptResponse::DecryptResponse { + KeyId, + Plaintext, + EncryptionAlgorithm, + CiphertextForRecipient, + } => CiphertextForRecipient, + } + } + } + + impl Debug for DecryptResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for DecryptResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DecryptResponse::DecryptResponse { + KeyId, + Plaintext, + EncryptionAlgorithm, + CiphertextForRecipient, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DecryptResponse.DecryptResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + Plaintext, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextForRecipient, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for DecryptResponse {} + + impl Hash for DecryptResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DecryptResponse::DecryptResponse { + KeyId, + Plaintext, + EncryptionAlgorithm, + CiphertextForRecipient, + } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(Plaintext, _state); + ::std::hash::Hash::hash(EncryptionAlgorithm, _state); + ::std::hash::Hash::hash(CiphertextForRecipient, _state) + } + } + } + } + + impl Default for DecryptResponse { + fn default() -> DecryptResponse { + DecryptResponse::DecryptResponse { + KeyId: ::std::default::Default::default(), + Plaintext: ::std::default::Default::default(), + EncryptionAlgorithm: ::std::default::Default::default(), + CiphertextForRecipient: ::std::default::Default::default(), + } + } + } + + impl AsRef for &DecryptResponse { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum DeriveSharedSecretRequest { + DeriveSharedSecretRequest { + KeyId: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + KeyAgreementAlgorithm: ::std::rc::Rc, + PublicKey: crate::software::amazon::cryptography::services::kms::internaldafny::types::PublicKeyType, + GrantTokens: ::std::rc::Rc>, + DryRun: ::std::rc::Rc>, + Recipient: ::std::rc::Rc>> + } + } + + impl DeriveSharedSecretRequest { + pub fn KeyId( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => KeyId, + } + } + pub fn KeyAgreementAlgorithm(&self) -> &::std::rc::Rc{ + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => KeyAgreementAlgorithm, + } + } + pub fn PublicKey(&self) -> &crate::software::amazon::cryptography::services::kms::internaldafny::types::PublicKeyType{ + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => PublicKey, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => GrantTokens, + } + } + pub fn DryRun( + &self, + ) -> &::std::rc::Rc> + { + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => DryRun, + } + } + pub fn Recipient(&self) -> &::std::rc::Rc>>{ + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => Recipient, + } + } + } + + impl Debug for DeriveSharedSecretRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for DeriveSharedSecretRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DeriveSharedSecretRequest.DeriveSharedSecretRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyAgreementAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + PublicKey, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + GrantTokens, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DryRun, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + Recipient, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for DeriveSharedSecretRequest {} + + impl Hash for DeriveSharedSecretRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId, + KeyAgreementAlgorithm, + PublicKey, + GrantTokens, + DryRun, + Recipient, + } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(KeyAgreementAlgorithm, _state); + ::std::hash::Hash::hash(PublicKey, _state); + ::std::hash::Hash::hash(GrantTokens, _state); + ::std::hash::Hash::hash(DryRun, _state); + ::std::hash::Hash::hash(Recipient, _state) + } + } + } + } + + impl Default for DeriveSharedSecretRequest { + fn default() -> DeriveSharedSecretRequest { + DeriveSharedSecretRequest::DeriveSharedSecretRequest { + KeyId: ::std::default::Default::default(), + KeyAgreementAlgorithm: ::std::default::Default::default(), + PublicKey: ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + DryRun: ::std::default::Default::default(), + Recipient: ::std::default::Default::default(), + } + } + } + + impl AsRef for &DeriveSharedSecretRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum DeriveSharedSecretResponse { + DeriveSharedSecretResponse { + KeyId: ::std::rc::Rc>>, + SharedSecret: ::std::rc::Rc>, + CiphertextForRecipient: ::std::rc::Rc>, + KeyAgreementAlgorithm: ::std::rc::Rc>>, + KeyOrigin: ::std::rc::Rc>> + } + } + + impl DeriveSharedSecretResponse { + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => KeyId, + } + } + pub fn SharedSecret(&self) -> &::std::rc::Rc>{ + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => SharedSecret, + } + } + pub fn CiphertextForRecipient(&self) -> &::std::rc::Rc>{ + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => CiphertextForRecipient, + } + } + pub fn KeyAgreementAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => KeyAgreementAlgorithm, + } + } + pub fn KeyOrigin(&self) -> &::std::rc::Rc>>{ + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => KeyOrigin, + } + } + } + + impl Debug for DeriveSharedSecretResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for DeriveSharedSecretResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.DeriveSharedSecretResponse.DeriveSharedSecretResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print(KeyId, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(SharedSecret, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(CiphertextForRecipient, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(KeyAgreementAlgorithm, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(KeyOrigin, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + } + } + } + + impl Eq for DeriveSharedSecretResponse {} + + impl Hash for DeriveSharedSecretResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DeriveSharedSecretResponse::DeriveSharedSecretResponse{KeyId, SharedSecret, CiphertextForRecipient, KeyAgreementAlgorithm, KeyOrigin, } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(SharedSecret, _state); + ::std::hash::Hash::hash(CiphertextForRecipient, _state); + ::std::hash::Hash::hash(KeyAgreementAlgorithm, _state); + ::std::hash::Hash::hash(KeyOrigin, _state) + }, + } + } + } + + impl Default for DeriveSharedSecretResponse { + fn default() -> DeriveSharedSecretResponse { + DeriveSharedSecretResponse::DeriveSharedSecretResponse { + KeyId: ::std::default::Default::default(), + SharedSecret: ::std::default::Default::default(), + CiphertextForRecipient: ::std::default::Default::default(), + KeyAgreementAlgorithm: ::std::default::Default::default(), + KeyOrigin: ::std::default::Default::default(), + } + } + } + + impl AsRef for &DeriveSharedSecretResponse { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum EncryptionAlgorithmSpec { + SYMMETRIC_DEFAULT {}, + RSAES_OAEP_SHA_1 {}, + RSAES_OAEP_SHA_256 {}, + } + + impl EncryptionAlgorithmSpec {} + + impl Debug for EncryptionAlgorithmSpec { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for EncryptionAlgorithmSpec { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.EncryptionAlgorithmSpec.SYMMETRIC__DEFAULT")?; + Ok(()) + } + EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.EncryptionAlgorithmSpec.RSAES__OAEP__SHA__1")?; + Ok(()) + } + EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.EncryptionAlgorithmSpec.RSAES__OAEP__SHA__256")?; + Ok(()) + } + } + } + } + + impl Eq for EncryptionAlgorithmSpec {} + + impl Hash for EncryptionAlgorithmSpec { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT {} => {} + EncryptionAlgorithmSpec::RSAES_OAEP_SHA_1 {} => {} + EncryptionAlgorithmSpec::RSAES_OAEP_SHA_256 {} => {} + } + } + } + + impl Default for EncryptionAlgorithmSpec { + fn default() -> EncryptionAlgorithmSpec { + EncryptionAlgorithmSpec::SYMMETRIC_DEFAULT {} + } + } + + impl AsRef for &EncryptionAlgorithmSpec { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum EncryptRequest { + EncryptRequest { + KeyId: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + Plaintext: crate::software::amazon::cryptography::services::kms::internaldafny::types::PlaintextType, + EncryptionContext: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + GrantTokens: ::std::rc::Rc>, + EncryptionAlgorithm: ::std::rc::Rc>>, + DryRun: ::std::rc::Rc> + } + } + + impl EncryptRequest { + pub fn KeyId( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => KeyId, + } + } + pub fn Plaintext(&self) -> &crate::software::amazon::cryptography::services::kms::internaldafny::types::PlaintextType{ + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => Plaintext, + } + } + pub fn EncryptionContext( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + > { + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => EncryptionContext, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => GrantTokens, + } + } + pub fn EncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => EncryptionAlgorithm, + } + } + pub fn DryRun( + &self, + ) -> &::std::rc::Rc> + { + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => DryRun, + } + } + } + + impl Debug for EncryptRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for EncryptRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.EncryptRequest.EncryptRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + Plaintext, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionContext, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + GrantTokens, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DryRun, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for EncryptRequest {} + + impl Hash for EncryptRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + EncryptRequest::EncryptRequest { + KeyId, + Plaintext, + EncryptionContext, + GrantTokens, + EncryptionAlgorithm, + DryRun, + } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(Plaintext, _state); + ::std::hash::Hash::hash(EncryptionContext, _state); + ::std::hash::Hash::hash(GrantTokens, _state); + ::std::hash::Hash::hash(EncryptionAlgorithm, _state); + ::std::hash::Hash::hash(DryRun, _state) + } + } + } + } + + impl Default for EncryptRequest { + fn default() -> EncryptRequest { + EncryptRequest::EncryptRequest { + KeyId: ::std::default::Default::default(), + Plaintext: ::std::default::Default::default(), + EncryptionContext: ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + EncryptionAlgorithm: ::std::default::Default::default(), + DryRun: ::std::default::Default::default(), + } + } + } + + impl AsRef for &EncryptRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum EncryptResponse { + EncryptResponse { + CiphertextBlob: ::std::rc::Rc>, + KeyId: ::std::rc::Rc>>, + EncryptionAlgorithm: ::std::rc::Rc>> + } + } + + impl EncryptResponse { + pub fn CiphertextBlob(&self) -> &::std::rc::Rc>{ + match self { + EncryptResponse::EncryptResponse { + CiphertextBlob, + KeyId, + EncryptionAlgorithm, + } => CiphertextBlob, + } + } + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + EncryptResponse::EncryptResponse { + CiphertextBlob, + KeyId, + EncryptionAlgorithm, + } => KeyId, + } + } + pub fn EncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + EncryptResponse::EncryptResponse { + CiphertextBlob, + KeyId, + EncryptionAlgorithm, + } => EncryptionAlgorithm, + } + } + } + + impl Debug for EncryptResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for EncryptResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + EncryptResponse::EncryptResponse { + CiphertextBlob, + KeyId, + EncryptionAlgorithm, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.EncryptResponse.EncryptResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextBlob, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for EncryptResponse {} + + impl Hash for EncryptResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + EncryptResponse::EncryptResponse { + CiphertextBlob, + KeyId, + EncryptionAlgorithm, + } => { + ::std::hash::Hash::hash(CiphertextBlob, _state); + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(EncryptionAlgorithm, _state) + } + } + } + } + + impl Default for EncryptResponse { + fn default() -> EncryptResponse { + EncryptResponse::EncryptResponse { + CiphertextBlob: ::std::default::Default::default(), + KeyId: ::std::default::Default::default(), + EncryptionAlgorithm: ::std::default::Default::default(), + } + } + } + + impl AsRef for &EncryptResponse { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GenerateDataKeyRequest { + GenerateDataKeyRequest { + KeyId: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + EncryptionContext: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + NumberOfBytes: ::std::rc::Rc>, + KeySpec: ::std::rc::Rc>>, + GrantTokens: ::std::rc::Rc>, + Recipient: ::std::rc::Rc>>, + DryRun: ::std::rc::Rc> + } + } + + impl GenerateDataKeyRequest { + pub fn KeyId( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => KeyId, + } + } + pub fn EncryptionContext( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + > { + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => EncryptionContext, + } + } + pub fn NumberOfBytes(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => NumberOfBytes, + } + } + pub fn KeySpec(&self) -> &::std::rc::Rc>>{ + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => KeySpec, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => GrantTokens, + } + } + pub fn Recipient(&self) -> &::std::rc::Rc>>{ + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => Recipient, + } + } + pub fn DryRun( + &self, + ) -> &::std::rc::Rc> + { + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => DryRun, + } + } + } + + impl Debug for GenerateDataKeyRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GenerateDataKeyRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyRequest.GenerateDataKeyRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionContext, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + NumberOfBytes, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeySpec, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + GrantTokens, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + Recipient, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DryRun, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GenerateDataKeyRequest {} + + impl Hash for GenerateDataKeyRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId, + EncryptionContext, + NumberOfBytes, + KeySpec, + GrantTokens, + Recipient, + DryRun, + } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(EncryptionContext, _state); + ::std::hash::Hash::hash(NumberOfBytes, _state); + ::std::hash::Hash::hash(KeySpec, _state); + ::std::hash::Hash::hash(GrantTokens, _state); + ::std::hash::Hash::hash(Recipient, _state); + ::std::hash::Hash::hash(DryRun, _state) + } + } + } + } + + impl Default for GenerateDataKeyRequest { + fn default() -> GenerateDataKeyRequest { + GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId: ::std::default::Default::default(), + EncryptionContext: ::std::default::Default::default(), + NumberOfBytes: ::std::default::Default::default(), + KeySpec: ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + Recipient: ::std::default::Default::default(), + DryRun: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GenerateDataKeyRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GenerateDataKeyResponse { + GenerateDataKeyResponse { + CiphertextBlob: ::std::rc::Rc>, + Plaintext: ::std::rc::Rc>, + KeyId: ::std::rc::Rc>>, + CiphertextForRecipient: ::std::rc::Rc> + } + } + + impl GenerateDataKeyResponse { + pub fn CiphertextBlob(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob, + Plaintext, + KeyId, + CiphertextForRecipient, + } => CiphertextBlob, + } + } + pub fn Plaintext(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob, + Plaintext, + KeyId, + CiphertextForRecipient, + } => Plaintext, + } + } + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob, + Plaintext, + KeyId, + CiphertextForRecipient, + } => KeyId, + } + } + pub fn CiphertextForRecipient(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob, + Plaintext, + KeyId, + CiphertextForRecipient, + } => CiphertextForRecipient, + } + } + } + + impl Debug for GenerateDataKeyResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GenerateDataKeyResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob, + Plaintext, + KeyId, + CiphertextForRecipient, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse.GenerateDataKeyResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextBlob, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + Plaintext, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextForRecipient, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GenerateDataKeyResponse {} + + impl Hash for GenerateDataKeyResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob, + Plaintext, + KeyId, + CiphertextForRecipient, + } => { + ::std::hash::Hash::hash(CiphertextBlob, _state); + ::std::hash::Hash::hash(Plaintext, _state); + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(CiphertextForRecipient, _state) + } + } + } + } + + impl Default for GenerateDataKeyResponse { + fn default() -> GenerateDataKeyResponse { + GenerateDataKeyResponse::GenerateDataKeyResponse { + CiphertextBlob: ::std::default::Default::default(), + Plaintext: ::std::default::Default::default(), + KeyId: ::std::default::Default::default(), + CiphertextForRecipient: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GenerateDataKeyResponse { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GenerateDataKeyWithoutPlaintextRequest { + GenerateDataKeyWithoutPlaintextRequest { + KeyId: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + EncryptionContext: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + KeySpec: ::std::rc::Rc>>, + NumberOfBytes: ::std::rc::Rc>, + GrantTokens: ::std::rc::Rc>, + DryRun: ::std::rc::Rc> + } + } + + impl GenerateDataKeyWithoutPlaintextRequest { + pub fn KeyId( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => KeyId, + } + } + pub fn EncryptionContext( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + > { + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => EncryptionContext, + } + } + pub fn KeySpec(&self) -> &::std::rc::Rc>>{ + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => KeySpec, + } + } + pub fn NumberOfBytes(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => NumberOfBytes, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => GrantTokens, + } + } + pub fn DryRun( + &self, + ) -> &::std::rc::Rc> + { + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => DryRun, + } + } + } + + impl Debug for GenerateDataKeyWithoutPlaintextRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GenerateDataKeyWithoutPlaintextRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyWithoutPlaintextRequest.GenerateDataKeyWithoutPlaintextRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print(KeyId, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(EncryptionContext, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(KeySpec, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(NumberOfBytes, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(GrantTokens, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(DryRun, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + } + } + } + + impl Eq for GenerateDataKeyWithoutPlaintextRequest {} + + impl Hash for GenerateDataKeyWithoutPlaintextRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest{KeyId, EncryptionContext, KeySpec, NumberOfBytes, GrantTokens, DryRun, } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(EncryptionContext, _state); + ::std::hash::Hash::hash(KeySpec, _state); + ::std::hash::Hash::hash(NumberOfBytes, _state); + ::std::hash::Hash::hash(GrantTokens, _state); + ::std::hash::Hash::hash(DryRun, _state) + }, + } + } + } + + impl Default for GenerateDataKeyWithoutPlaintextRequest { + fn default() -> GenerateDataKeyWithoutPlaintextRequest { + GenerateDataKeyWithoutPlaintextRequest::GenerateDataKeyWithoutPlaintextRequest { + KeyId: ::std::default::Default::default(), + EncryptionContext: ::std::default::Default::default(), + KeySpec: ::std::default::Default::default(), + NumberOfBytes: ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + DryRun: ::std::default::Default::default() + } + } + } + + impl AsRef for &GenerateDataKeyWithoutPlaintextRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GenerateDataKeyWithoutPlaintextResponse { + GenerateDataKeyWithoutPlaintextResponse { + CiphertextBlob: ::std::rc::Rc>, + KeyId: ::std::rc::Rc>> + } + } + + impl GenerateDataKeyWithoutPlaintextResponse { + pub fn CiphertextBlob(&self) -> &::std::rc::Rc>{ + match self { + GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse{CiphertextBlob, KeyId, } => CiphertextBlob, + } + } + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse{CiphertextBlob, KeyId, } => KeyId, + } + } + } + + impl Debug for GenerateDataKeyWithoutPlaintextResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GenerateDataKeyWithoutPlaintextResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse{CiphertextBlob, KeyId, } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyWithoutPlaintextResponse.GenerateDataKeyWithoutPlaintextResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print(CiphertextBlob, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(KeyId, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + } + } + } + + impl Eq for GenerateDataKeyWithoutPlaintextResponse {} + + impl Hash for GenerateDataKeyWithoutPlaintextResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse{CiphertextBlob, KeyId, } => { + ::std::hash::Hash::hash(CiphertextBlob, _state); + ::std::hash::Hash::hash(KeyId, _state) + }, + } + } + } + + impl Default for GenerateDataKeyWithoutPlaintextResponse { + fn default() -> GenerateDataKeyWithoutPlaintextResponse { + GenerateDataKeyWithoutPlaintextResponse::GenerateDataKeyWithoutPlaintextResponse { + CiphertextBlob: ::std::default::Default::default(), + KeyId: ::std::default::Default::default() + } + } + } + + impl AsRef for &GenerateDataKeyWithoutPlaintextResponse { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetPublicKeyRequest { + GetPublicKeyRequest { + KeyId: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + GrantTokens: ::std::rc::Rc> + } + } + + impl GetPublicKeyRequest { + pub fn KeyId( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + GetPublicKeyRequest::GetPublicKeyRequest { + KeyId, + GrantTokens, + } => KeyId, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + GetPublicKeyRequest::GetPublicKeyRequest { + KeyId, + GrantTokens, + } => GrantTokens, + } + } + } + + impl Debug for GetPublicKeyRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetPublicKeyRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetPublicKeyRequest::GetPublicKeyRequest { + KeyId, + GrantTokens, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.GetPublicKeyRequest.GetPublicKeyRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + GrantTokens, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetPublicKeyRequest {} + + impl Hash for GetPublicKeyRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetPublicKeyRequest::GetPublicKeyRequest { + KeyId, + GrantTokens, + } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(GrantTokens, _state) + } + } + } + } + + impl Default for GetPublicKeyRequest { + fn default() -> GetPublicKeyRequest { + GetPublicKeyRequest::GetPublicKeyRequest { + KeyId: ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetPublicKeyRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetPublicKeyResponse { + GetPublicKeyResponse { + KeyId: ::std::rc::Rc>>, + PublicKey: ::std::rc::Rc>, + CustomerMasterKeySpec: ::std::rc::Rc>>, + KeySpec: ::std::rc::Rc>>, + KeyUsage: ::std::rc::Rc>>, + EncryptionAlgorithms: ::std::rc::Rc>>>, + SigningAlgorithms: ::std::rc::Rc>>>, + KeyAgreementAlgorithms: ::std::rc::Rc>>> + } + } + + impl GetPublicKeyResponse { + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => KeyId, + } + } + pub fn PublicKey(&self) -> &::std::rc::Rc>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => PublicKey, + } + } + pub fn CustomerMasterKeySpec(&self) -> &::std::rc::Rc>>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => CustomerMasterKeySpec, + } + } + pub fn KeySpec(&self) -> &::std::rc::Rc>>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => KeySpec, + } + } + pub fn KeyUsage(&self) -> &::std::rc::Rc>>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => KeyUsage, + } + } + pub fn EncryptionAlgorithms(&self) -> &::std::rc::Rc>>>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => EncryptionAlgorithms, + } + } + pub fn SigningAlgorithms(&self) -> &::std::rc::Rc>>>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => SigningAlgorithms, + } + } + pub fn KeyAgreementAlgorithms(&self) -> &::std::rc::Rc>>>{ + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => KeyAgreementAlgorithms, + } + } + } + + impl Debug for GetPublicKeyResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for GetPublicKeyResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.GetPublicKeyResponse.GetPublicKeyResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + PublicKey, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CustomerMasterKeySpec, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeySpec, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyUsage, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + EncryptionAlgorithms, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + SigningAlgorithms, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyAgreementAlgorithms, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetPublicKeyResponse {} + + impl Hash for GetPublicKeyResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId, + PublicKey, + CustomerMasterKeySpec, + KeySpec, + KeyUsage, + EncryptionAlgorithms, + SigningAlgorithms, + KeyAgreementAlgorithms, + } => { + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash(PublicKey, _state); + ::std::hash::Hash::hash(CustomerMasterKeySpec, _state); + ::std::hash::Hash::hash(KeySpec, _state); + ::std::hash::Hash::hash(KeyUsage, _state); + ::std::hash::Hash::hash(EncryptionAlgorithms, _state); + ::std::hash::Hash::hash(SigningAlgorithms, _state); + ::std::hash::Hash::hash(KeyAgreementAlgorithms, _state) + } + } + } + } + + impl Default for GetPublicKeyResponse { + fn default() -> GetPublicKeyResponse { + GetPublicKeyResponse::GetPublicKeyResponse { + KeyId: ::std::default::Default::default(), + PublicKey: ::std::default::Default::default(), + CustomerMasterKeySpec: ::std::default::Default::default(), + KeySpec: ::std::default::Default::default(), + KeyUsage: ::std::default::Default::default(), + EncryptionAlgorithms: ::std::default::Default::default(), + SigningAlgorithms: ::std::default::Default::default(), + KeyAgreementAlgorithms: ::std::default::Default::default(), + } + } + } + + impl AsRef for &GetPublicKeyResponse { + fn as_ref(&self) -> Self { + self + } + } + + pub type GrantTokenList = ::dafny_runtime::Sequence< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >; + + pub type GrantTokenType = + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>; + + #[derive(PartialEq, Clone)] + pub enum KeyAgreementAlgorithmSpec { + ECDH {}, + } + + impl KeyAgreementAlgorithmSpec {} + + impl Debug for KeyAgreementAlgorithmSpec { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for KeyAgreementAlgorithmSpec { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + KeyAgreementAlgorithmSpec::ECDH {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeyAgreementAlgorithmSpec.ECDH")?; + Ok(()) + } + } + } + } + + impl Eq for KeyAgreementAlgorithmSpec {} + + impl Hash for KeyAgreementAlgorithmSpec { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + KeyAgreementAlgorithmSpec::ECDH {} => {} + } + } + } + + impl Default for KeyAgreementAlgorithmSpec { + fn default() -> KeyAgreementAlgorithmSpec { + KeyAgreementAlgorithmSpec::ECDH {} + } + } + + impl AsRef for &KeyAgreementAlgorithmSpec { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum KeyEncryptionMechanism { + RSAES_OAEP_SHA_256 {}, + } + + impl KeyEncryptionMechanism {} + + impl Debug for KeyEncryptionMechanism { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for KeyEncryptionMechanism { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeyEncryptionMechanism.RSAES__OAEP__SHA__256")?; + Ok(()) + } + } + } + } + + impl Eq for KeyEncryptionMechanism {} + + impl Hash for KeyEncryptionMechanism { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} => {} + } + } + } + + impl Default for KeyEncryptionMechanism { + fn default() -> KeyEncryptionMechanism { + KeyEncryptionMechanism::RSAES_OAEP_SHA_256 {} + } + } + + impl AsRef for &KeyEncryptionMechanism { + fn as_ref(&self) -> Self { + self + } + } + + pub type KeyIdType = + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>; + + #[derive(PartialEq, Clone)] + pub enum KeySpec { + RSA_2048 {}, + RSA_3072 {}, + RSA_4096 {}, + ECC_NIST_P256 {}, + ECC_NIST_P384 {}, + ECC_NIST_P521 {}, + ECC_SECG_P256K1 {}, + SYMMETRIC_DEFAULT {}, + HMAC_224 {}, + HMAC_256 {}, + HMAC_384 {}, + HMAC_512 {}, + SM2 {}, + } + + impl KeySpec {} + + impl Debug for KeySpec { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for KeySpec { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + KeySpec::RSA_2048 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.RSA__2048")?; + Ok(()) + } + KeySpec::RSA_3072 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.RSA__3072")?; + Ok(()) + } + KeySpec::RSA_4096 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.RSA__4096")?; + Ok(()) + } + KeySpec::ECC_NIST_P256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.ECC__NIST__P256")?; + Ok(()) + } + KeySpec::ECC_NIST_P384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.ECC__NIST__P384")?; + Ok(()) + } + KeySpec::ECC_NIST_P521 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.ECC__NIST__P521")?; + Ok(()) + } + KeySpec::ECC_SECG_P256K1 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.ECC__SECG__P256K1")?; + Ok(()) + } + KeySpec::SYMMETRIC_DEFAULT {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.SYMMETRIC__DEFAULT")?; + Ok(()) + } + KeySpec::HMAC_224 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.HMAC__224")?; + Ok(()) + } + KeySpec::HMAC_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.HMAC__256")?; + Ok(()) + } + KeySpec::HMAC_384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.HMAC__384")?; + Ok(()) + } + KeySpec::HMAC_512 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.HMAC__512")?; + Ok(()) + } + KeySpec::SM2 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeySpec.SM2")?; + Ok(()) + } + } + } + } + + impl Eq for KeySpec {} + + impl Hash for KeySpec { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + KeySpec::RSA_2048 {} => {} + KeySpec::RSA_3072 {} => {} + KeySpec::RSA_4096 {} => {} + KeySpec::ECC_NIST_P256 {} => {} + KeySpec::ECC_NIST_P384 {} => {} + KeySpec::ECC_NIST_P521 {} => {} + KeySpec::ECC_SECG_P256K1 {} => {} + KeySpec::SYMMETRIC_DEFAULT {} => {} + KeySpec::HMAC_224 {} => {} + KeySpec::HMAC_256 {} => {} + KeySpec::HMAC_384 {} => {} + KeySpec::HMAC_512 {} => {} + KeySpec::SM2 {} => {} + } + } + } + + impl Default for KeySpec { + fn default() -> KeySpec { + KeySpec::RSA_2048 {} + } + } + + impl AsRef for &KeySpec { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum KeyUsageType { + SIGN_VERIFY {}, + ENCRYPT_DECRYPT {}, + GENERATE_VERIFY_MAC {}, + KEY_AGREEMENT {}, + } + + impl KeyUsageType {} + + impl Debug for KeyUsageType { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for KeyUsageType { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + KeyUsageType::SIGN_VERIFY {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeyUsageType.SIGN__VERIFY")?; + Ok(()) + } + KeyUsageType::ENCRYPT_DECRYPT {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeyUsageType.ENCRYPT__DECRYPT")?; + Ok(()) + } + KeyUsageType::GENERATE_VERIFY_MAC {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeyUsageType.GENERATE__VERIFY__MAC")?; + Ok(()) + } + KeyUsageType::KEY_AGREEMENT {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.KeyUsageType.KEY__AGREEMENT")?; + Ok(()) + } + } + } + } + + impl Eq for KeyUsageType {} + + impl Hash for KeyUsageType { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + KeyUsageType::SIGN_VERIFY {} => {} + KeyUsageType::ENCRYPT_DECRYPT {} => {} + KeyUsageType::GENERATE_VERIFY_MAC {} => {} + KeyUsageType::KEY_AGREEMENT {} => {} + } + } + } + + impl Default for KeyUsageType { + fn default() -> KeyUsageType { + KeyUsageType::SIGN_VERIFY {} + } + } + + impl AsRef for &KeyUsageType { + fn as_ref(&self) -> Self { + self + } + } + + pub type NumberOfBytesType = i32; + + #[derive(PartialEq, Clone)] + pub enum OriginType { + AWS_KMS {}, + EXTERNAL {}, + AWS_CLOUDHSM {}, + EXTERNAL_KEY_STORE {}, + } + + impl OriginType {} + + impl Debug for OriginType { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for OriginType { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + OriginType::AWS_KMS {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.OriginType.AWS__KMS")?; + Ok(()) + } + OriginType::EXTERNAL {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.OriginType.EXTERNAL")?; + Ok(()) + } + OriginType::AWS_CLOUDHSM {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.OriginType.AWS__CLOUDHSM")?; + Ok(()) + } + OriginType::EXTERNAL_KEY_STORE {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.OriginType.EXTERNAL__KEY__STORE")?; + Ok(()) + } + } + } + } + + impl Eq for OriginType {} + + impl Hash for OriginType { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + OriginType::AWS_KMS {} => {} + OriginType::EXTERNAL {} => {} + OriginType::AWS_CLOUDHSM {} => {} + OriginType::EXTERNAL_KEY_STORE {} => {} + } + } + } + + impl Default for OriginType { + fn default() -> OriginType { + OriginType::AWS_KMS {} + } + } + + impl AsRef for &OriginType { + fn as_ref(&self) -> Self { + self + } + } + + pub type PlaintextType = ::dafny_runtime::Sequence; + + pub type PublicKeyType = ::dafny_runtime::Sequence; + + #[derive(PartialEq, Clone)] + pub enum RecipientInfo { + RecipientInfo { + KeyEncryptionAlgorithm: ::std::rc::Rc>>, + AttestationDocument: ::std::rc::Rc> + } + } + + impl RecipientInfo { + pub fn KeyEncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + RecipientInfo::RecipientInfo { + KeyEncryptionAlgorithm, + AttestationDocument, + } => KeyEncryptionAlgorithm, + } + } + pub fn AttestationDocument(&self) -> &::std::rc::Rc>{ + match self { + RecipientInfo::RecipientInfo { + KeyEncryptionAlgorithm, + AttestationDocument, + } => AttestationDocument, + } + } + } + + impl Debug for RecipientInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for RecipientInfo { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + RecipientInfo::RecipientInfo { + KeyEncryptionAlgorithm, + AttestationDocument, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.RecipientInfo.RecipientInfo(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyEncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + AttestationDocument, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for RecipientInfo {} + + impl Hash for RecipientInfo { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + RecipientInfo::RecipientInfo { + KeyEncryptionAlgorithm, + AttestationDocument, + } => { + ::std::hash::Hash::hash(KeyEncryptionAlgorithm, _state); + ::std::hash::Hash::hash(AttestationDocument, _state) + } + } + } + } + + impl Default for RecipientInfo { + fn default() -> RecipientInfo { + RecipientInfo::RecipientInfo { + KeyEncryptionAlgorithm: ::std::default::Default::default(), + AttestationDocument: ::std::default::Default::default(), + } + } + } + + impl AsRef for &RecipientInfo { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum ReEncryptRequest { + ReEncryptRequest { + CiphertextBlob: crate::software::amazon::cryptography::services::kms::internaldafny::types::CiphertextType, + SourceEncryptionContext: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + SourceKeyId: ::std::rc::Rc>>, + DestinationKeyId: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + DestinationEncryptionContext: ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>>, + SourceEncryptionAlgorithm: ::std::rc::Rc>>, + DestinationEncryptionAlgorithm: ::std::rc::Rc>>, + GrantTokens: ::std::rc::Rc>, + DryRun: ::std::rc::Rc> + } + } + + impl ReEncryptRequest { + pub fn CiphertextBlob(&self) -> &crate::software::amazon::cryptography::services::kms::internaldafny::types::CiphertextType{ + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => CiphertextBlob, + } + } + pub fn SourceEncryptionContext( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + > { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => SourceEncryptionContext, + } + } + pub fn SourceKeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => SourceKeyId, + } + } + pub fn DestinationKeyId( + &self, + ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> + { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => DestinationKeyId, + } + } + pub fn DestinationEncryptionContext( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Map< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + > { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => DestinationEncryptionContext, + } + } + pub fn SourceEncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => SourceEncryptionAlgorithm, + } + } + pub fn DestinationEncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => DestinationEncryptionAlgorithm, + } + } + pub fn GrantTokens(&self) -> &::std::rc::Rc>{ + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => GrantTokens, + } + } + pub fn DryRun( + &self, + ) -> &::std::rc::Rc> + { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => DryRun, + } + } + } + + impl Debug for ReEncryptRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for ReEncryptRequest { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.ReEncryptRequest.ReEncryptRequest(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextBlob, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + SourceEncryptionContext, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + SourceKeyId, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DestinationKeyId, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DestinationEncryptionContext, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + SourceEncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DestinationEncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + GrantTokens, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DryRun, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for ReEncryptRequest {} + + impl Hash for ReEncryptRequest { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob, + SourceEncryptionContext, + SourceKeyId, + DestinationKeyId, + DestinationEncryptionContext, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + GrantTokens, + DryRun, + } => { + ::std::hash::Hash::hash(CiphertextBlob, _state); + ::std::hash::Hash::hash( + SourceEncryptionContext, + _state, + ); + ::std::hash::Hash::hash(SourceKeyId, _state); + ::std::hash::Hash::hash(DestinationKeyId, _state); + ::std::hash::Hash::hash( + DestinationEncryptionContext, + _state, + ); + ::std::hash::Hash::hash( + SourceEncryptionAlgorithm, + _state, + ); + ::std::hash::Hash::hash( + DestinationEncryptionAlgorithm, + _state, + ); + ::std::hash::Hash::hash(GrantTokens, _state); + ::std::hash::Hash::hash(DryRun, _state) + } + } + } + } + + impl Default for ReEncryptRequest { + fn default() -> ReEncryptRequest { + ReEncryptRequest::ReEncryptRequest { + CiphertextBlob: ::std::default::Default::default(), + SourceEncryptionContext: ::std::default::Default::default(), + SourceKeyId: ::std::default::Default::default(), + DestinationKeyId: ::std::default::Default::default(), + DestinationEncryptionContext: + ::std::default::Default::default(), + SourceEncryptionAlgorithm: ::std::default::Default::default( + ), + DestinationEncryptionAlgorithm: + ::std::default::Default::default(), + GrantTokens: ::std::default::Default::default(), + DryRun: ::std::default::Default::default(), + } + } + } + + impl AsRef for &ReEncryptRequest { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum ReEncryptResponse { + ReEncryptResponse { + CiphertextBlob: ::std::rc::Rc>, + SourceKeyId: ::std::rc::Rc>>, + KeyId: ::std::rc::Rc>>, + SourceEncryptionAlgorithm: ::std::rc::Rc>>, + DestinationEncryptionAlgorithm: ::std::rc::Rc>> + } + } + + impl ReEncryptResponse { + pub fn CiphertextBlob(&self) -> &::std::rc::Rc>{ + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => CiphertextBlob, + } + } + pub fn SourceKeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => SourceKeyId, + } + } + pub fn KeyId( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => KeyId, + } + } + pub fn SourceEncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => SourceEncryptionAlgorithm, + } + } + pub fn DestinationEncryptionAlgorithm(&self) -> &::std::rc::Rc>>{ + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => DestinationEncryptionAlgorithm, + } + } + } + + impl Debug for ReEncryptResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for ReEncryptResponse { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.ReEncryptResponse.ReEncryptResponse(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + CiphertextBlob, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + SourceKeyId, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + KeyId, _formatter, false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + SourceEncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print( + DestinationEncryptionAlgorithm, + _formatter, + false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for ReEncryptResponse {} + + impl Hash for ReEncryptResponse { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob, + SourceKeyId, + KeyId, + SourceEncryptionAlgorithm, + DestinationEncryptionAlgorithm, + } => { + ::std::hash::Hash::hash(CiphertextBlob, _state); + ::std::hash::Hash::hash(SourceKeyId, _state); + ::std::hash::Hash::hash(KeyId, _state); + ::std::hash::Hash::hash( + SourceEncryptionAlgorithm, + _state, + ); + ::std::hash::Hash::hash( + DestinationEncryptionAlgorithm, + _state, + ) + } + } + } + } + + impl Default for ReEncryptResponse { + fn default() -> ReEncryptResponse { + ReEncryptResponse::ReEncryptResponse { + CiphertextBlob: ::std::default::Default::default(), + SourceKeyId: ::std::default::Default::default(), + KeyId: ::std::default::Default::default(), + SourceEncryptionAlgorithm: ::std::default::Default::default( + ), + DestinationEncryptionAlgorithm: + ::std::default::Default::default(), + } + } + } + + impl AsRef for &ReEncryptResponse { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SigningAlgorithmSpec { + RSASSA_PSS_SHA_256 {}, + RSASSA_PSS_SHA_384 {}, + RSASSA_PSS_SHA_512 {}, + RSASSA_PKCS1_V1_5_SHA_256 {}, + RSASSA_PKCS1_V1_5_SHA_384 {}, + RSASSA_PKCS1_V1_5_SHA_512 {}, + ECDSA_SHA_256 {}, + ECDSA_SHA_384 {}, + ECDSA_SHA_512 {}, + SM2DSA {}, + } + + impl SigningAlgorithmSpec {} + + impl Debug for SigningAlgorithmSpec { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for SigningAlgorithmSpec { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SigningAlgorithmSpec::RSASSA_PSS_SHA_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.RSASSA__PSS__SHA__256")?; + Ok(()) + } + SigningAlgorithmSpec::RSASSA_PSS_SHA_384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.RSASSA__PSS__SHA__384")?; + Ok(()) + } + SigningAlgorithmSpec::RSASSA_PSS_SHA_512 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.RSASSA__PSS__SHA__512")?; + Ok(()) + } + SigningAlgorithmSpec::RSASSA_PKCS1_V1_5_SHA_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.RSASSA__PKCS1__V1__5__SHA__256")?; + Ok(()) + } + SigningAlgorithmSpec::RSASSA_PKCS1_V1_5_SHA_384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.RSASSA__PKCS1__V1__5__SHA__384")?; + Ok(()) + } + SigningAlgorithmSpec::RSASSA_PKCS1_V1_5_SHA_512 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.RSASSA__PKCS1__V1__5__SHA__512")?; + Ok(()) + } + SigningAlgorithmSpec::ECDSA_SHA_256 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.ECDSA__SHA__256")?; + Ok(()) + } + SigningAlgorithmSpec::ECDSA_SHA_384 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.ECDSA__SHA__384")?; + Ok(()) + } + SigningAlgorithmSpec::ECDSA_SHA_512 {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.ECDSA__SHA__512")?; + Ok(()) + } + SigningAlgorithmSpec::SM2DSA {} => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.SigningAlgorithmSpec.SM2DSA")?; + Ok(()) + } + } + } + } + + impl Eq for SigningAlgorithmSpec {} + + impl Hash for SigningAlgorithmSpec { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SigningAlgorithmSpec::RSASSA_PSS_SHA_256 {} => {} + SigningAlgorithmSpec::RSASSA_PSS_SHA_384 {} => {} + SigningAlgorithmSpec::RSASSA_PSS_SHA_512 {} => {} + SigningAlgorithmSpec::RSASSA_PKCS1_V1_5_SHA_256 {} => {} + SigningAlgorithmSpec::RSASSA_PKCS1_V1_5_SHA_384 {} => {} + SigningAlgorithmSpec::RSASSA_PKCS1_V1_5_SHA_512 {} => {} + SigningAlgorithmSpec::ECDSA_SHA_256 {} => {} + SigningAlgorithmSpec::ECDSA_SHA_384 {} => {} + SigningAlgorithmSpec::ECDSA_SHA_512 {} => {} + SigningAlgorithmSpec::SM2DSA {} => {} + } + } + } + + impl Default for SigningAlgorithmSpec { + fn default() -> SigningAlgorithmSpec { + SigningAlgorithmSpec::RSASSA_PSS_SHA_256 {} + } + } + + impl AsRef for &SigningAlgorithmSpec { + fn as_ref(&self) -> Self { + self + } + } + + pub struct IKMSClientCallHistory {} + + impl IKMSClientCallHistory { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + } + + impl UpcastObject + for crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClientCallHistory { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); + } + + pub trait IKMSClient: + ::std::any::Any + + ::dafny_runtime::UpcastObject + { + fn Decrypt(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn DeriveSharedSecret(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn Encrypt(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GenerateDataKey(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GenerateDataKeyWithoutPlaintext(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn GetPublicKey(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + fn ReEncrypt(&mut self, input: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + DependencyTimeoutException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + DisabledException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + DryRunOperationException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + IncorrectKeyException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + InvalidArnException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + InvalidCiphertextException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + InvalidGrantTokenException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + InvalidKeyUsageException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + KeyUnavailableException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + KMSInternalException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + KMSInvalidStateException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + NotFoundException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + UnsupportedOperationException { + message: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence< + ::dafny_runtime::DafnyCharUTF16, + >, + >, + >, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn message( + &self, + ) -> &::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + match self { + Error::DependencyTimeoutException { message } => message, + Error::DisabledException { message } => message, + Error::DryRunOperationException { message } => message, + Error::IncorrectKeyException { message } => message, + Error::InvalidArnException { message } => message, + Error::InvalidCiphertextException { message } => message, + Error::InvalidGrantTokenException { message } => message, + Error::InvalidKeyUsageException { message } => message, + Error::KeyUnavailableException { message } => message, + Error::KMSInternalException { message } => message, + Error::KMSInvalidStateException { message } => message, + Error::NotFoundException { message } => message, + Error::UnsupportedOperationException { message } => message, + Error::Opaque { obj } => { + panic!("field does not exist on this variant") + } + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::DependencyTimeoutException { message } => { + panic!("field does not exist on this variant") + } + Error::DisabledException { message } => { + panic!("field does not exist on this variant") + } + Error::DryRunOperationException { message } => { + panic!("field does not exist on this variant") + } + Error::IncorrectKeyException { message } => { + panic!("field does not exist on this variant") + } + Error::InvalidArnException { message } => { + panic!("field does not exist on this variant") + } + Error::InvalidCiphertextException { message } => { + panic!("field does not exist on this variant") + } + Error::InvalidGrantTokenException { message } => { + panic!("field does not exist on this variant") + } + Error::InvalidKeyUsageException { message } => { + panic!("field does not exist on this variant") + } + Error::KeyUnavailableException { message } => { + panic!("field does not exist on this variant") + } + Error::KMSInternalException { message } => { + panic!("field does not exist on this variant") + } + Error::KMSInvalidStateException { message } => { + panic!("field does not exist on this variant") + } + Error::NotFoundException { message } => { + panic!("field does not exist on this variant") + } + Error::UnsupportedOperationException { message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::DependencyTimeoutException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.DependencyTimeoutException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::DisabledException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.DisabledException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::DryRunOperationException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.DryRunOperationException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::IncorrectKeyException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.IncorrectKeyException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::InvalidArnException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.InvalidArnException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::InvalidCiphertextException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.InvalidCiphertextException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::InvalidGrantTokenException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.InvalidGrantTokenException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::InvalidKeyUsageException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.InvalidKeyUsageException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::KeyUnavailableException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.KeyUnavailableException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::KMSInternalException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.KMSInternalException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::KMSInvalidStateException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.KMSInvalidStateException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::NotFoundException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.NotFoundException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::UnsupportedOperationException { message } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.UnsupportedOperationException(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + message, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!(_formatter, "software.amazon.cryptography.services.kms.internaldafny.types.Error.Opaque(")?; + ::dafny_runtime::DafnyPrint::fmt_print( + obj, _formatter, false, + )?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::DependencyTimeoutException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::DisabledException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::DryRunOperationException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::IncorrectKeyException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::InvalidArnException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::InvalidCiphertextException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::InvalidGrantTokenException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::InvalidKeyUsageException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::KeyUnavailableException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::KMSInternalException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::KMSInvalidStateException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::NotFoundException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::UnsupportedOperationException { message } => { + ::std::hash::Hash::hash(message, _state) + } + Error::Opaque { obj } => { + ::std::hash::Hash::hash(obj, _state) + } + } + } + } + + impl Default for Error { + fn default() -> Error { + Error::DependencyTimeoutException { + message: ::std::default::Default::default(), + } + } + } + + impl AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = ::std::rc::Rc; + } + } + } + } + } + } +} +pub mod r#_Com_Compile { + pub mod r#_Amazonaws_Compile {} +} +pub mod r#_TestComAmazonawsKms_Compile { + pub struct _default {} + + impl _default { + pub fn workAround(literal: &::dafny_runtime::Sequence) -> crate::software::amazon::cryptography::services::kms::internaldafny::types::CiphertextType{ + literal.clone() + } + pub fn BasicDecryptTests() -> () { + let mut CiphertextBlob: ::dafny_runtime::Sequence = ::dafny_runtime::seq![ + 1, 1, 1, 0, 120, 64, 243, 140, 39, 94, 49, 9, 116, 22, 193, 7, 41, 81, 80, 87, 25, + 100, 173, 163, 239, 28, 33, 233, 76, 139, 160, 189, 188, 157, 15, 180, 20, 0, 0, 0, + 98, 48, 96, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 6, 160, 83, 48, 81, 2, 1, 0, 48, + 76, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 48, 30, 6, 9, 96, 134, 72, 1, 101, 3, + 4, 1, 46, 48, 17, 4, 12, 196, 249, 60, 7, 21, 231, 87, 70, 216, 12, 31, 13, 2, 1, + 16, 128, 31, 222, 119, 162, 112, 88, 153, 39, 197, 21, 182, 116, 176, 120, 174, + 107, 82, 182, 223, 160, 201, 15, 29, 3, 254, 3, 208, 72, 171, 64, 207, 175 + ]; + crate::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTest(&::std::rc::Rc::new(crate::software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest::DecryptRequest { + CiphertextBlob: crate::r#_TestComAmazonawsKms_Compile::_default::workAround(&CiphertextBlob), + EncryptionContext: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>::None {}), + GrantTokens: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}), + KeyId: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: crate::r#_TestComAmazonawsKms_Compile::_default::keyId() + }), + EncryptionAlgorithm: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + Recipient: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + DryRun: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + }), &::dafny_runtime::seq![165, 191, 67, 62], &crate::r#_TestComAmazonawsKms_Compile::_default::keyId()); + return (); + } + pub fn BasicGenerateTests() -> () { + crate::r#_TestComAmazonawsKms_Compile::_default::BasicGenerateTest(&::std::rc::Rc::new(crate::software::amazon::cryptography::services::kms::internaldafny::types::GenerateDataKeyRequest::GenerateDataKeyRequest { + KeyId: crate::r#_TestComAmazonawsKms_Compile::_default::keyId(), + EncryptionContext: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>::None {}), + NumberOfBytes: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: 32 + }), + KeySpec: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + GrantTokens: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}), + Recipient: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + DryRun: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + })); + return (); + } + pub fn BasicEncryptTests() -> () { + crate::r#_TestComAmazonawsKms_Compile::_default::BasicEncryptTest(&::std::rc::Rc::new(crate::software::amazon::cryptography::services::kms::internaldafny::types::EncryptRequest::EncryptRequest { + KeyId: crate::r#_TestComAmazonawsKms_Compile::_default::keyId(), + Plaintext: ::dafny_runtime::seq![97, 115, 100, 102], + EncryptionContext: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>::None {}), + GrantTokens: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}), + EncryptionAlgorithm: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + DryRun: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + })); + return (); + } + pub fn BasicDecryptTest( + input: &::std::rc::Rc, + expectedPlaintext: &crate::software::amazon::cryptography::services::kms::internaldafny::types::PlaintextType, + expectedKeyId: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from(crate::software::amazon::cryptography::services::kms::internaldafny::_default::KMSClient()); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + let mut ret = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from(crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient::Decrypt(::dafny_runtime::md!(client.clone()), input)); + ret = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + if !matches!( + (&ret.read()).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + panic!("Halt") + }; + let mut r#__let_tmp_rhs0: ::std::rc::Rc = ret.read().value().clone(); + let mut KeyId: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > = r#__let_tmp_rhs0.KeyId().clone(); + let mut Plaintext: ::std::rc::Rc> = r#__let_tmp_rhs0.Plaintext().clone(); + let mut EncryptionAlgorithm: ::std::rc::Rc>> = r#__let_tmp_rhs0.EncryptionAlgorithm().clone(); + let mut CiphertextBlob: ::std::rc::Rc> = r#__let_tmp_rhs0.CiphertextForRecipient().clone(); + if !matches!( + (&Plaintext).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !matches!( + (&KeyId).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e00: crate::software::amazon::cryptography::services::kms::internaldafny::types::PlaintextType = Plaintext.value().clone(); + let mut _e10: crate::software::amazon::cryptography::services::kms::internaldafny::types::PlaintextType = expectedPlaintext.clone(); + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + let mut _e01: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + KeyId.value().clone(); + let mut _e11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + expectedKeyId.clone(); + if !(_e01.clone() == _e11.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + return (); + } + pub fn BasicGenerateTest( + input: &::std::rc::Rc, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from(crate::software::amazon::cryptography::services::kms::internaldafny::_default::KMSClient()); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + let mut ret = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out3 = ::dafny_runtime::MaybePlacebo::from(crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient::GenerateDataKey(::dafny_runtime::md!(client.clone()), input)); + ret = ::dafny_runtime::MaybePlacebo::from(_out3.read()); + if !matches!( + (&ret.read()).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + panic!("Halt") + }; + let mut r#__let_tmp_rhs1: ::std::rc::Rc = ret.read().value().clone(); + let mut CiphertextBlob: ::std::rc::Rc> = r#__let_tmp_rhs1.CiphertextBlob().clone(); + let mut Plaintext: ::std::rc::Rc> = r#__let_tmp_rhs1.Plaintext().clone(); + let mut KeyId: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > = r#__let_tmp_rhs1.KeyId().clone(); + let mut CiphertextForRecipient: ::std::rc::Rc> = r#__let_tmp_rhs1.CiphertextForRecipient().clone(); + if !matches!( + (&CiphertextBlob).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !matches!( + (&Plaintext).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !matches!( + (&KeyId).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut _e02: ::dafny_runtime::DafnyInt = Plaintext.value().cardinality(); + let mut _e12: ::dafny_runtime::_System::nat = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into( + input.NumberOfBytes().value().clone(), + ); + if !(_e02.clone() == _e12.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + let mut decryptInput: ::std::rc::Rc = ::std::rc::Rc::new(crate::software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest::DecryptRequest { + CiphertextBlob: CiphertextBlob.value().clone(), + EncryptionContext: input.EncryptionContext().clone(), + GrantTokens: input.GrantTokens().clone(), + KeyId: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: KeyId.value().clone() + }), + EncryptionAlgorithm: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + Recipient: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + DryRun: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + }); + crate::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTest( + &decryptInput, + Plaintext.value(), + input.KeyId(), + ); + return (); + } + pub fn BasicEncryptTest( + input: &::std::rc::Rc, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out4 = ::dafny_runtime::MaybePlacebo::from(crate::software::amazon::cryptography::services::kms::internaldafny::_default::KMSClient()); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + let mut ret = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out5 = ::dafny_runtime::MaybePlacebo::from(crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient::Encrypt(::dafny_runtime::md!(client.clone()), input)); + ret = ::dafny_runtime::MaybePlacebo::from(_out5.read()); + if !matches!( + (&ret.read()).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + panic!("Halt") + }; + let mut r#__let_tmp_rhs2: ::std::rc::Rc = ret.read().value().clone(); + let mut CiphertextBlob: ::std::rc::Rc> = r#__let_tmp_rhs2.CiphertextBlob().clone(); + let mut KeyId: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > = r#__let_tmp_rhs2.KeyId().clone(); + let mut EncryptionAlgorithm: ::std::rc::Rc>> = r#__let_tmp_rhs2.EncryptionAlgorithm().clone(); + if !matches!( + (&CiphertextBlob).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !matches!( + (&KeyId).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + let mut decryptInput: ::std::rc::Rc = ::std::rc::Rc::new(crate::software::amazon::cryptography::services::kms::internaldafny::types::DecryptRequest::DecryptRequest { + CiphertextBlob: CiphertextBlob.value().clone(), + EncryptionContext: input.EncryptionContext().clone(), + GrantTokens: input.GrantTokens().clone(), + KeyId: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { + value: KeyId.value().clone() + }), + EncryptionAlgorithm: input.EncryptionAlgorithm().clone(), + Recipient: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), + DryRun: ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + }); + crate::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTest( + &decryptInput, + input.Plaintext(), + input.KeyId(), + ); + return (); + } + pub fn keyId() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + ::dafny_runtime::string_utf16_of( + "arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f", + ) + } + pub fn TEST_REGION() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + ::dafny_runtime::string_utf16_of("us-west-2") + } + } + + #[test] + pub fn BasicDecryptTests() { + _default::BasicDecryptTests() + } + + #[test] + pub fn BasicGenerateTests() { + _default::BasicGenerateTests() + } + + #[test] + pub fn BasicEncryptTests() { + _default::BasicEncryptTests() + } +} +pub mod r#_StandardLibraryInterop_Compile { + pub use dafny_runtime::UpcastObject; + pub use std::any::Any; + + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + + impl UpcastObject for WrappersInterop { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module { + pub struct _default {} + + impl _default { + pub fn _Test__Main_() -> () { + let mut success: bool = true; + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestComAmazonawsKms.BasicDecryptTests: "# + )) + ); + crate::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTests(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestComAmazonawsKms.BasicGenerateTests: "# + )) + ); + crate::r#_TestComAmazonawsKms_Compile::_default::BasicGenerateTests(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestComAmazonawsKms.BasicEncryptTests: "# + )) + ); + crate::r#_TestComAmazonawsKms_Compile::_default::BasicEncryptTests(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + if !success { + panic!("Halt") + }; + return (); + } + } +} +fn main() { + _module::_default::_Test__Main_(); +} diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs index b5e77f9af..3c941cd5b 100644 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/lib.rs @@ -1,3 +1,4 @@ mod client; mod conversions; +mod standard_library_conversions; pub mod implementation_from_dafny; diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/src/standard_library_conversions.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/standard_library_conversions.rs new file mode 100644 index 000000000..2fec0ffb5 --- /dev/null +++ b/TestModels/aws-sdks/kms-lite/runtimes/rust/src/standard_library_conversions.rs @@ -0,0 +1,246 @@ +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::Sequence::from_array(&input.clone().into_inner()) +} + +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>> { + 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>>, +) -> 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) + } + ), + } +} \ No newline at end of file diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/kms_lite_tests.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/kms_lite_tests.rs deleted file mode 100644 index 02ab4070b..000000000 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/kms_lite_tests.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod tests_from_dafny; - -#[test] -fn dafny_tests() { - crate::tests_from_dafny::_module::_default::_Test__Main_() -} diff --git a/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs deleted file mode 100644 index f061a8096..000000000 --- a/TestModels/aws-sdks/kms-lite/runtimes/rust/tests/tests_from_dafny/mod.rs +++ /dev/null @@ -1,325 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -use ::kms_lite::implementation_from_dafny::*; - -pub mod r#_TestComAmazonawsKms_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn workAround(literal: &::dafny_runtime::Sequence) -> super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::CiphertextType{ - literal.clone() - } - pub fn BasicDecryptTests() -> () { - let mut CiphertextBlob: ::dafny_runtime::Sequence = ::dafny_runtime::seq![ - 1, 1, 1, 0, 120, 64, 243, 140, 39, 94, 49, 9, 116, 22, 193, 7, 41, 81, 80, 87, 25, - 100, 173, 163, 239, 28, 33, 233, 76, 139, 160, 189, 188, 157, 15, 180, 20, 0, 0, 0, - 98, 48, 96, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 6, 160, 83, 48, 81, 2, 1, 0, 48, - 76, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 48, 30, 6, 9, 96, 134, 72, 1, 101, 3, - 4, 1, 46, 48, 17, 4, 12, 196, 249, 60, 7, 21, 231, 87, 70, 216, 12, 31, 13, 2, 1, - 16, 128, 31, 222, 119, 162, 112, 88, 153, 39, 197, 21, 182, 116, 176, 120, 174, - 107, 82, 182, 223, 160, 201, 15, 29, 3, 254, 3, 208, 72, 171, 64, 207, 175 - ]; - super::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTest(&::std::rc::Rc::new(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest::DecryptRequest { - CiphertextBlob: super::r#_TestComAmazonawsKms_Compile::_default::workAround(&CiphertextBlob), - EncryptionContext: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>::None {}), - GrantTokens: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}), - KeyId: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: super::r#_TestComAmazonawsKms_Compile::_default::keyId() - }), - EncryptionAlgorithm: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - Recipient: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - DryRun: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - }), &::dafny_runtime::seq![165, 191, 67, 62], &super::r#_TestComAmazonawsKms_Compile::_default::keyId()); - return (); - } - pub fn BasicGenerateTests() -> () { - super::r#_TestComAmazonawsKms_Compile::_default::BasicGenerateTest(&::std::rc::Rc::new(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::GenerateDataKeyRequest::GenerateDataKeyRequest { - KeyId: super::r#_TestComAmazonawsKms_Compile::_default::keyId(), - EncryptionContext: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>::None {}), - NumberOfBytes: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 32 - }), - KeySpec: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - GrantTokens: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}), - Recipient: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - DryRun: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - })); - return (); - } - pub fn BasicEncryptTests() -> () { - super::r#_TestComAmazonawsKms_Compile::_default::BasicEncryptTest(&::std::rc::Rc::new(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::EncryptRequest::EncryptRequest { - KeyId: super::r#_TestComAmazonawsKms_Compile::_default::keyId(), - Plaintext: ::dafny_runtime::seq![97, 115, 100, 102], - EncryptionContext: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>>::None {}), - GrantTokens: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}), - EncryptionAlgorithm: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - DryRun: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - })); - return (); - } - pub fn BasicDecryptTest( - input: &::std::rc::Rc, - expectedPlaintext: &super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::PlaintextType, - expectedKeyId: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny::_default::KMSClient()); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - let mut ret = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient::Decrypt(::dafny_runtime::md!(client.clone()), input)); - ret = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - if !matches!( - (&ret.read()).as_ref(), - super::r#_Wrappers_Compile::Result::Success { .. } - ) { - panic!("Halt") - }; - let mut r#__let_tmp_rhs0: ::std::rc::Rc = ret.read().value().clone(); - let mut KeyId: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > = r#__let_tmp_rhs0.KeyId().clone(); - let mut Plaintext: ::std::rc::Rc> = r#__let_tmp_rhs0.Plaintext().clone(); - let mut EncryptionAlgorithm: ::std::rc::Rc>> = r#__let_tmp_rhs0.EncryptionAlgorithm().clone(); - let mut CiphertextBlob: ::std::rc::Rc> = r#__let_tmp_rhs0.CiphertextForRecipient().clone(); - if !matches!( - (&Plaintext).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !matches!( - (&KeyId).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(Plaintext.value().clone() == expectedPlaintext.clone()) { - panic!("Halt") - }; - if !(KeyId.value().clone() == expectedKeyId.clone()) { - panic!("Halt") - }; - return (); - } - pub fn BasicGenerateTest( - input: &::std::rc::Rc, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny::_default::KMSClient()); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - let mut ret = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient::GenerateDataKey(::dafny_runtime::md!(client.clone()), input)); - ret = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - if !matches!( - (&ret.read()).as_ref(), - super::r#_Wrappers_Compile::Result::Success { .. } - ) { - panic!("Halt") - }; - let mut r#__let_tmp_rhs1: ::std::rc::Rc = ret.read().value().clone(); - let mut CiphertextBlob: ::std::rc::Rc> = r#__let_tmp_rhs1.CiphertextBlob().clone(); - let mut Plaintext: ::std::rc::Rc> = r#__let_tmp_rhs1.Plaintext().clone(); - let mut KeyId: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > = r#__let_tmp_rhs1.KeyId().clone(); - let mut CiphertextForRecipient: ::std::rc::Rc> = r#__let_tmp_rhs1.CiphertextForRecipient().clone(); - if !matches!( - (&CiphertextBlob).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !matches!( - (&Plaintext).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !matches!( - (&KeyId).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(Plaintext.value().cardinality() - == Into::<::dafny_runtime::DafnyInt>::into(input.NumberOfBytes().value().clone())) - { - panic!("Halt") - }; - let mut decryptInput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest::DecryptRequest { - CiphertextBlob: CiphertextBlob.value().clone(), - EncryptionContext: input.EncryptionContext().clone(), - GrantTokens: input.GrantTokens().clone(), - KeyId: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: KeyId.value().clone() - }), - EncryptionAlgorithm: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - Recipient: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - DryRun: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - }); - super::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTest( - &decryptInput, - Plaintext.value(), - input.KeyId(), - ); - return (); - } - pub fn BasicEncryptTest( - input: &::std::rc::Rc, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny::_default::KMSClient()); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - let mut ret = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::IKMSClient::Encrypt(::dafny_runtime::md!(client.clone()), input)); - ret = ::dafny_runtime::MaybePlacebo::from(_out5.read()); - if !matches!( - (&ret.read()).as_ref(), - super::r#_Wrappers_Compile::Result::Success { .. } - ) { - panic!("Halt") - }; - let mut r#__let_tmp_rhs2: ::std::rc::Rc = ret.read().value().clone(); - let mut CiphertextBlob: ::std::rc::Rc> = r#__let_tmp_rhs2.CiphertextBlob().clone(); - let mut KeyId: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > = r#__let_tmp_rhs2.KeyId().clone(); - let mut EncryptionAlgorithm: ::std::rc::Rc>> = r#__let_tmp_rhs2.EncryptionAlgorithm().clone(); - if !matches!( - (&CiphertextBlob).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !matches!( - (&KeyId).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - let mut decryptInput: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_software_damazon_dcryptography_dservices_dkms_dinternaldafny_dtypes::DecryptRequest::DecryptRequest { - CiphertextBlob: CiphertextBlob.value().clone(), - EncryptionContext: input.EncryptionContext().clone(), - GrantTokens: input.GrantTokens().clone(), - KeyId: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: KeyId.value().clone() - }), - EncryptionAlgorithm: input.EncryptionAlgorithm().clone(), - Recipient: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::None {}), - DryRun: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - }); - super::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTest( - &decryptInput, - input.Plaintext(), - input.KeyId(), - ); - return (); - } - pub fn keyId() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - ::dafny_runtime::string_utf16_of( - "arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f", - ) - } - pub fn TEST_REGION() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - ::dafny_runtime::string_utf16_of("us-west-2") - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_TestComAmazonawsKms_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod _module { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _Test__Main_() -> () { - let mut success: bool = true; - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestComAmazonawsKms.BasicDecryptTests: "# - )) - ); - super::r#_TestComAmazonawsKms_Compile::_default::BasicDecryptTests(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestComAmazonawsKms.BasicGenerateTests: "# - )) - ); - super::r#_TestComAmazonawsKms_Compile::_default::BasicGenerateTests(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestComAmazonawsKms.BasicEncryptTests: "# - )) - ); - super::r#_TestComAmazonawsKms_Compile::_default::BasicEncryptTests(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - if !success { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::_module::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -fn main() { - _module::_default::_Test__Main_(); -} diff --git a/TestModels/dafny-dependencies/StandardLibrary/Makefile b/TestModels/dafny-dependencies/StandardLibrary/Makefile index d65992e4a..0eabc8d42 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/Makefile +++ b/TestModels/dafny-dependencies/StandardLibrary/Makefile @@ -3,6 +3,8 @@ CORES=2 +TRANSPILE_TESTS_IN_RUST=true + include ../../SharedMakefile.mk MAX_RESOURCE_COUNT=500000000 @@ -65,7 +67,7 @@ transpile_java: | transpile_implementation_java transpile_test_java # Override SharedMakefile's transpile_java to not transpile # StandardLibrary as a dependency -transpile_rust: | transpile_implementation_rust transpile_test_rust +transpile_rust: | transpile_implementation_rust # Override this target to not insert a dependency on the standard library. _mv_implementation_rust: diff --git a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch index a8b1819f9..63265865e 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch @@ -1,72 +1,69 @@ -diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs +diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8_externs.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8_externs.rs new file mode 100644 -index 00000000..fb5e7bf9 +index 00000000..4de5cb4e --- /dev/null -+++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs -@@ -0,0 +1,67 @@ ++++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8_externs.rs +@@ -0,0 +1,64 @@ + +// Annotation to ignore the case of this module -+#[allow(non_snake_case)] -+pub mod UTF8 { -+ use crate::implementation_from_dafny::r#_Wrappers_Compile; -+ use crate::implementation_from_dafny::UTF8; ++use crate::r#_Wrappers_Compile; ++use crate::UTF8; ++ + -+ -+ impl crate::implementation_from_dafny::UTF8::_default { -+ pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { -+ 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()); ++impl crate::UTF8::_default { ++ pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { ++ 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; -+ }, -+ 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()) -+ }); -+ } ++ } ++ 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::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) + } -+ pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::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) ++ 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::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) ++ } ++ pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::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()) + }) -+ }, -+ 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()) -+ }) -+ } + } + } + } @@ -74,11 +71,11 @@ index 00000000..fb5e7bf9 \ No newline at end of file diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs new file mode 100644 -index 00000000..8b20a995 +index 00000000..c4bdc057 --- /dev/null +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs -@@ -0,0 +1,175 @@ -+use crate::implementation_from_dafny::*; +@@ -0,0 +1,173 @@ ++use crate::*; + +pub fn ostring_to_dafny( + input: &Option, @@ -203,7 +200,6 @@ index 00000000..8b20a995 + match &*input { + _Wrappers_Compile::Option::Some { value } => Some(converter(value)), + _Wrappers_Compile::Option::None { } => None, -+ _Wrappers_Compile::Option::_PhantomVariant(_) => panic!(), + } +} + @@ -231,7 +227,6 @@ index 00000000..8b20a995 + match &*input { + _Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), + _Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), -+ _Wrappers_Compile::Result::_PhantomVariant(_, _) => panic!(), + } +} + @@ -254,6 +249,20 @@ index 00000000..8b20a995 + } +} \ No newline at end of file +diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs +index 7c054901..3e6599ec 100644 +--- b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs ++++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs +@@ -1,6 +1,9 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] + ++pub mod conversion; ++mod UTF8_externs; ++ + pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..12cdf221 @@ -265,14 +274,3 @@ index 00000000..12cdf221 +pub mod conversion; +pub mod implementation_from_dafny; \ No newline at end of file -diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs -index 20caf2dd..c4a1c20f 100644 ---- b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs -+++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs -@@ -1,5 +1,6 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] -+use ::dafny_standard_library::implementation_from_dafny::*; - - pub mod r#_TestUTF8_Compile { - pub struct _default {} diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/Cargo.toml b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/Cargo.toml index a682821e8..159ade2f0 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/Cargo.toml +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/Cargo.toml @@ -8,3 +8,6 @@ edition = "2021" [dependencies] dafny_runtime = { path = "../../../dafny_runtime_rust"} aws-smithy-types = "1.2.0" + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs deleted file mode 100644 index fb5e7bf90..000000000 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs +++ /dev/null @@ -1,67 +0,0 @@ - -// Annotation to ignore the case of this module -#[allow(non_snake_case)] -pub mod UTF8 { - use crate::implementation_from_dafny::r#_Wrappers_Compile; - use crate::implementation_from_dafny::UTF8; - - - impl crate::implementation_from_dafny::UTF8::_default { - pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { - 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::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) - } - pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::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()) - }) - } - } - } - } -} \ No newline at end of file diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8_externs.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8_externs.rs new file mode 100644 index 000000000..4de5cb4e5 --- /dev/null +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8_externs.rs @@ -0,0 +1,64 @@ + +// 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>> { + 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::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) + } + pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::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()) + }) + } + } + } +} \ No newline at end of file diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs index 8b20a9950..c4bdc0578 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs @@ -1,4 +1,4 @@ -use crate::implementation_from_dafny::*; +use crate::*; pub fn ostring_to_dafny( input: &Option, @@ -123,7 +123,6 @@ pub fn option_from_dafny( match &*input { _Wrappers_Compile::Option::Some { value } => Some(converter(value)), _Wrappers_Compile::Option::None { } => None, - _Wrappers_Compile::Option::_PhantomVariant(_) => panic!(), } } @@ -151,7 +150,6 @@ pub fn result_from_dafny Ok(converter_t(value)), _Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), - _Wrappers_Compile::Result::_PhantomVariant(_, _) => panic!(), } } diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 000000000..3e6599ece --- /dev/null +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,2898 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +pub mod conversion; +mod UTF8_externs; + +pub mod r#_Wrappers_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::cmp::Eq; + pub use std::convert::AsRef; + pub use std::default::Default; + pub use std::fmt::Debug; + pub use std::hash::Hash; + + pub struct _default {} + + impl _default { + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } + } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + } + } + } + + impl Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Option { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + ) -> ::std::rc::Rc) -> Option> { + ::std::rc::Rc::new(move |this: Self| -> Option { + match this { + Option::None {} => Option::None {}, + Option::Some { value } => Option::Some { + value: f_0.clone()(value), + }, + } + }) + } + } + + impl Eq for Option {} + + impl Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => ::std::hash::Hash::hash(value, _state), + } + } + } + + impl Default for Option { + fn default() -> Option { + Option::None {} + } + } + + impl AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + } + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + crate::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + } + } + } + + impl Debug for Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Result { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Result { + pub fn coerce( + f_0: ::std::rc::Rc r#__T0 + 'static>, + f_1: ::std::rc::Rc r#__T1 + 'static>, + ) -> ::std::rc::Rc) -> Result> { + ::std::rc::Rc::new(move |this: Self| -> Result { + match this { + Result::Success { value } => Result::Success { + value: f_0.clone()(value), + }, + Result::Failure { error } => Result::Failure { + error: f_1.clone()(error), + }, + } + }) + } + } + + impl Eq for Result {} + + impl Hash + for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => ::std::hash::Hash::hash(value, _state), + Result::Failure { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default + for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } + } + + impl AsRef> + for &Result + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + crate::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + } + } + } + + impl Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Outcome {} + + impl Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => ::std::hash::Hash::hash(error, _state), + } + } + } + + impl Default for Outcome { + fn default() -> Outcome { + Outcome::Pass {} + } + } + + impl AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_StandardLibrary_Compile { + pub struct _default {} + + impl _default { + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + crate::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = crate::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract(); + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + crate::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_object::<_T>( + ::dafny_runtime::DafnyUsize::into_usize(s.cardinality()), + ); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = ::dafny_runtime::DafnyUsize::into_usize(r#__i0_0.clone()); + ::dafny_runtime::md!(_nw0)[__idx0] = ::std::mem::MaybeUninit::new((&_init0)( + &::dafny_runtime::int!(r#__i0_0.clone()), + )); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_object( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool{ + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>{ + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { + for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && crate::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } + } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&crate::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool{ + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || crate::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) + } + } + + pub mod r#_UInt_Compile { + pub use dafny_runtime::DafnyPrint; + pub use std::default::Default; + + pub struct _default {} + + impl _default { + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < crate::r#_StandardLibrary_Compile::r#_UInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl uint8 { + pub fn is(_source: u8) -> bool { + return true; + } + } + + impl Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl uint16 { + pub fn is(_source: u16) -> bool { + return true; + } + } + + impl Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl uint32 { + pub fn is(_source: u32) -> bool { + return true; + } + } + + impl Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl uint64 { + pub fn is(_source: u64) -> bool { + return true; + } + } + + impl Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } + } + + impl DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl int32 { + pub fn is(_source: i32) -> bool { + return true; + } + } + + impl Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } + } + + impl DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl int64 { + pub fn is(_source: i64) -> bool { + return true; + } + } + + impl Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } + } + + impl DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl posInt64 { + pub fn is(_source: u64) -> bool { + let mut x: ::dafny_runtime::DafnyInt = + ::std::convert::Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); + return ::dafny_runtime::int!(0) < x.clone() + && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); + } + } + + impl Default for posInt64 { + fn default() -> Self { + posInt64(1) + } + } + + impl DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } + } + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; + } +} +pub mod UTF8 { + pub struct _default {} + + impl _default { + pub fn CreateEncodeSuccess( + bytes: &crate::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> crate::UTF8::ValidUTF8Bytes { + let mut _accumulator: crate::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if crate::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && crate::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && crate::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && crate::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + crate::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } + } + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } +} +pub mod r#_TestUTF8_Compile { + pub struct _default {} + + impl _default { + pub fn TestEncodeHappyCase() -> () { + let mut unicodeString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(97 as u16), + ::dafny_runtime::DafnyCharUTF16(98 as u16), + ::dafny_runtime::DafnyCharUTF16(99 as u16), + ::dafny_runtime::DafnyCharUTF16(774 as u16), + ::dafny_runtime::DafnyCharUTF16(509 as u16), + ::dafny_runtime::DafnyCharUTF16(946 as u16) + ]; + let mut expectedBytes: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![97, 98, 99, 204, 134, 199, 189, 206, 178]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&unicodeString)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: crate::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + let mut _e00: ::dafny_runtime::Sequence = expectedBytes.clone(); + let mut _e10: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e00.clone() == _e10.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e00)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e10)); + panic!("Halt") + }; + return (); + } + pub fn TestEncodeInvalidUnicode() -> () { + let mut invalidUnicode: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(97 as u16), + ::dafny_runtime::DafnyCharUTF16(98 as u16), + ::dafny_runtime::DafnyCharUTF16(99 as u16), + ::dafny_runtime::DafnyCharUTF16(55296 as u16) + ]; + let mut encoded: ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > = crate::UTF8::_default::Encode(&invalidUnicode); + if !matches!( + (&encoded).as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) { + panic!("Halt") + }; + return (); + } + pub fn TestDecodeHappyCase() -> () { + let mut unicodeBytes: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![97, 98, 99, 204, 134, 199, 189, 206, 178]; + let mut expectedString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(97 as u16), + ::dafny_runtime::DafnyCharUTF16(98 as u16), + ::dafny_runtime::DafnyCharUTF16(99 as u16), + ::dafny_runtime::DafnyCharUTF16(774 as u16), + ::dafny_runtime::DafnyCharUTF16(509 as u16), + ::dafny_runtime::DafnyCharUTF16(946 as u16) + ]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&unicodeBytes)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError0.read().Extract(); + let mut _e01: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + expectedString.clone(); + let mut _e11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + if !(_e01.clone() == _e11.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e01)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e11)); + panic!("Halt") + }; + return (); + } + pub fn TestDecodeInvalidUnicode() -> () { + let mut invalidUnicode: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![97, 98, 99, 237, 160, 128]; + if !(!crate::UTF8::_default::ValidUTF8Seq(&invalidUnicode)) { + panic!("Halt") + }; + if !matches!( + (&crate::UTF8::_default::Decode(&invalidUnicode)).as_ref(), + crate::r#_Wrappers_Compile::Result::Failure { .. } + ) { + panic!("Halt") + }; + return (); + } + pub fn Test1Byte() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(0 as u16)]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: crate::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + let mut _e02: ::dafny_runtime::Sequence = ::dafny_runtime::seq![0]; + let mut _e12: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e02.clone() == _e12.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e02)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e12)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + let mut _e03: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e13: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e03.clone() == _e13.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e03)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e13)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(32 as u16)]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + let mut _e04: ::dafny_runtime::Sequence = ::dafny_runtime::seq![32]; + let mut _e14: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e04.clone() == _e14.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e04)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e14)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + let mut _e05: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e15: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e05.clone() == _e15.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e05)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e15)); + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("$"); + let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError4 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError4.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError4.read().Extract(); + let mut _e06: ::dafny_runtime::Sequence = ::dafny_runtime::seq![36]; + let mut _e16: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e06.clone() == _e16.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e06)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e16)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError5 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError5.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError5.read().Extract(); + let mut _e07: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e17: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e07.clone() == _e17.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e07)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e17)); + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("0"); + let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError6 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError6.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError6.read().Extract(); + let mut _e08: ::dafny_runtime::Sequence = ::dafny_runtime::seq![48]; + let mut _e18: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e08.clone() == _e18.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e08)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e18)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError7 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError7.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError7.read().Extract(); + let mut _e09: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e19: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e09.clone() == _e19.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e09)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e19)); + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("A"); + let mut valueOrError8 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError8 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError8.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError8.read().Extract(); + let mut _e010: ::dafny_runtime::Sequence = ::dafny_runtime::seq![65]; + let mut _e110: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e010.clone() == _e110.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e010)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e110)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError9 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError9 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError9.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError9.read().Extract(); + let mut _e011: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e111: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e011.clone() == _e111.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e011)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e111)); + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("a"); + let mut valueOrError10 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError10 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError10.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError10.read().Extract(); + let mut _e012: ::dafny_runtime::Sequence = ::dafny_runtime::seq![97]; + let mut _e112: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e012.clone() == _e112.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e012)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e112)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError11 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError11 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError11.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError11.read().Extract(); + let mut _e013: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e113: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e013.clone() == _e113.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e013)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e113)); + panic!("Halt") + }; + return (); + } + pub fn Test2Bytes() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(163 as u16)]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: crate::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + let mut _e014: ::dafny_runtime::Sequence = ::dafny_runtime::seq![194, 163]; + let mut _e114: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e014.clone() == _e114.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e014)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e114)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + let mut _e015: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e115: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e015.clone() == _e115.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e015)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e115)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(169 as u16)]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + let mut _e016: ::dafny_runtime::Sequence = ::dafny_runtime::seq![194, 169]; + let mut _e116: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e016.clone() == _e116.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e016)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e116)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + let mut _e017: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e117: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e017.clone() == _e117.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e017)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e117)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(174 as u16)]; + let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError4 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError4.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError4.read().Extract(); + let mut _e018: ::dafny_runtime::Sequence = ::dafny_runtime::seq![194, 174]; + let mut _e118: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e018.clone() == _e118.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e018)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e118)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError5 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError5.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError5.read().Extract(); + let mut _e019: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e119: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e019.clone() == _e119.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e019)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e119)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(960 as u16)]; + let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError6 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError6.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError6.read().Extract(); + let mut _e020: ::dafny_runtime::Sequence = ::dafny_runtime::seq![207, 128]; + let mut _e120: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e020.clone() == _e120.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e020)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e120)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError7 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError7.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError7.read().Extract(); + let mut _e021: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e121: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e021.clone() == _e121.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e021)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e121)); + panic!("Halt") + }; + return (); + } + pub fn Test3Bytes() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(9094 as u16)]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: crate::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + let mut _e022: ::dafny_runtime::Sequence = ::dafny_runtime::seq![226, 142, 134]; + let mut _e122: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e022.clone() == _e122.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e022)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e122)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + let mut _e023: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e123: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e023.clone() == _e123.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e023)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e123)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(9095 as u16)]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + let mut _e024: ::dafny_runtime::Sequence = ::dafny_runtime::seq![226, 142, 135]; + let mut _e124: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e024.clone() == _e124.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e024)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e124)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + let mut _e025: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e125: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e025.clone() == _e125.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e025)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e125)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(8987 as u16)]; + let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError4 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError4.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError4.read().Extract(); + let mut _e026: ::dafny_runtime::Sequence = ::dafny_runtime::seq![226, 140, 155]; + let mut _e126: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e026.clone() == _e126.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e026)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e126)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError5 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError5.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError5.read().Extract(); + let mut _e027: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e127: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e027.clone() == _e127.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e027)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e127)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(7544 as u16)]; + let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError6 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError6.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError6.read().Extract(); + let mut _e028: ::dafny_runtime::Sequence = ::dafny_runtime::seq![225, 181, 184]; + let mut _e128: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e028.clone() == _e128.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e028)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e128)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError7 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError7.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError7.read().Extract(); + let mut _e029: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e129: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e029.clone() == _e129.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e029)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e129)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(29483 as u16)]; + let mut valueOrError8 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError8 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError8.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError8.read().Extract(); + let mut _e030: ::dafny_runtime::Sequence = ::dafny_runtime::seq![231, 140, 171]; + let mut _e130: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e030.clone() == _e130.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e030)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e130)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError9 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError9 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError9.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError9.read().Extract(); + let mut _e031: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e131: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e031.clone() == _e131.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e031)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e131)); + panic!("Halt") + }; + return (); + } + pub fn Test4Bytes() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(55304 as u16), + ::dafny_runtime::DafnyCharUTF16(56320 as u16) + ]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: crate::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + let mut _e032: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![240, 146, 128, 128]; + let mut _e132: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e032.clone() == _e132.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e032)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e132)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses4Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + let mut _e033: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e133: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e033.clone() == _e133.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e033)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e133)); + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(55349 as u16), + ::dafny_runtime::DafnyCharUTF16(57281 as u16) + ]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + crate::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + let mut _e034: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![240, 157, 159, 129]; + let mut _e134: crate::UTF8::ValidUTF8Bytes = encoded.clone(); + if !(_e034.clone() == _e134.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e034)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e134)); + panic!("Halt") + }; + if !crate::UTF8::_default::Uses4Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + crate::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(crate::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + let mut _e035: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + decoded.clone(); + let mut _e135: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + redecoded.clone(); + if !(_e035.clone() == _e135.clone()) { + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Left:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e035)); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "Right:\n" + )) + ); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&_e135)); + panic!("Halt") + }; + return (); + } + } + + #[test] + pub fn TestEncodeHappyCase() { + _default::TestEncodeHappyCase() + } + + #[test] + pub fn TestEncodeInvalidUnicode() { + _default::TestEncodeInvalidUnicode() + } + + #[test] + pub fn TestDecodeHappyCase() { + _default::TestDecodeHappyCase() + } + + #[test] + pub fn TestDecodeInvalidUnicode() { + _default::TestDecodeInvalidUnicode() + } + + #[test] + pub fn Test1Byte() { + _default::Test1Byte() + } + + #[test] + pub fn Test2Bytes() { + _default::Test2Bytes() + } + + #[test] + pub fn Test3Bytes() { + _default::Test3Bytes() + } + + #[test] + pub fn Test4Bytes() { + _default::Test4Bytes() + } +} +pub mod _module { + pub struct _default {} + + impl _default { + pub fn _Test__Main_() -> () { + let mut success: bool = true; + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestEncodeHappyCase: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::TestEncodeHappyCase(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestEncodeInvalidUnicode: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::TestEncodeInvalidUnicode(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestDecodeHappyCase: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::TestDecodeHappyCase(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestDecodeInvalidUnicode: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::TestDecodeInvalidUnicode(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test1Byte: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::Test1Byte(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test2Bytes: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::Test2Bytes(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test3Bytes: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::Test3Bytes(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test4Bytes: "# + )) + ); + crate::r#_TestUTF8_Compile::_default::Test4Bytes(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + if !success { + panic!("Halt") + }; + return (); + } + } +} +fn main() { + _module::_default::_Test__Main_(); +} diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs deleted file mode 100644 index fe1c0f50e..000000000 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs +++ /dev/null @@ -1,7 +0,0 @@ - -mod tests_from_dafny; - -#[test] -fn dafny_tests() { - crate::tests_from_dafny::_module::_default::_Test__Main_() -} diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs deleted file mode 100644 index c4a1c20ff..000000000 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs +++ /dev/null @@ -1,919 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -use ::dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_TestUTF8_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn TestEncodeHappyCase() -> () { - let mut unicodeString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16(97 as u16), - ::dafny_runtime::DafnyCharUTF16(98 as u16), - ::dafny_runtime::DafnyCharUTF16(99 as u16), - ::dafny_runtime::DafnyCharUTF16(774 as u16), - ::dafny_runtime::DafnyCharUTF16(509 as u16), - ::dafny_runtime::DafnyCharUTF16(946 as u16) - ]; - let mut expectedBytes: ::dafny_runtime::Sequence = - ::dafny_runtime::seq![97, 98, 99, 204, 134, 199, 189, 206, 178]; - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError0 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&unicodeString)); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); - if !(expectedBytes.clone() == encoded.clone()) { - panic!("Halt") - }; - return (); - } - pub fn TestEncodeInvalidUnicode() -> () { - let mut invalidUnicode: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16(97 as u16), - ::dafny_runtime::DafnyCharUTF16(98 as u16), - ::dafny_runtime::DafnyCharUTF16(99 as u16), - ::dafny_runtime::DafnyCharUTF16(55296 as u16) - ]; - let mut encoded: ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > = super::UTF8::_default::Encode(&invalidUnicode); - if !matches!( - (&encoded).as_ref(), - super::r#_Wrappers_Compile::Result::Failure { .. } - ) { - panic!("Halt") - }; - return (); - } - pub fn TestDecodeHappyCase() -> () { - let mut unicodeBytes: ::dafny_runtime::Sequence = - ::dafny_runtime::seq![97, 98, 99, 204, 134, 199, 189, 206, 178]; - let mut expectedString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16(97 as u16), - ::dafny_runtime::DafnyCharUTF16(98 as u16), - ::dafny_runtime::DafnyCharUTF16(99 as u16), - ::dafny_runtime::DafnyCharUTF16(774 as u16), - ::dafny_runtime::DafnyCharUTF16(509 as u16), - ::dafny_runtime::DafnyCharUTF16(946 as u16) - ]; - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError0 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&unicodeBytes)); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - valueOrError0.read().Extract(); - if !(expectedString.clone() == decoded.clone()) { - panic!("Halt") - }; - return (); - } - pub fn TestDecodeInvalidUnicode() -> () { - let mut invalidUnicode: ::dafny_runtime::Sequence = - ::dafny_runtime::seq![97, 98, 99, 237, 160, 128]; - if !(!super::UTF8::_default::ValidUTF8Seq(&invalidUnicode)) { - panic!("Halt") - }; - if !matches!( - (&super::UTF8::_default::Decode(&invalidUnicode)).as_ref(), - super::r#_Wrappers_Compile::Result::Failure { .. } - ) { - panic!("Halt") - }; - return (); - } - pub fn Test1Byte() -> () { - let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(0 as u16)]; - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError0 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); - if !(::dafny_runtime::seq![0] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses1Byte(&encoded) { - panic!("Halt") - }; - let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError1 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError1.read().IsFailure()) { - panic!("Halt") - }; - let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - valueOrError1.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(32 as u16)]; - let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError2 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError2.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError2.read().Extract(); - if !(::dafny_runtime::seq![32] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses1Byte(&encoded) { - panic!("Halt") - }; - let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError3 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError3.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError3.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::string_utf16_of("$"); - let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError4 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError4.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError4.read().Extract(); - if !(::dafny_runtime::seq![36] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses1Byte(&encoded) { - panic!("Halt") - }; - let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError5 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError5.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError5.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::string_utf16_of("0"); - let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError6 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError6.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError6.read().Extract(); - if !(::dafny_runtime::seq![48] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses1Byte(&encoded) { - panic!("Halt") - }; - let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError7 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError7.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError7.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::string_utf16_of("A"); - let mut valueOrError8 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError8 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError8.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError8.read().Extract(); - if !(::dafny_runtime::seq![65] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses1Byte(&encoded) { - panic!("Halt") - }; - let mut valueOrError9 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError9 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError9.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError9.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::string_utf16_of("a"); - let mut valueOrError10 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError10 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError10.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError10.read().Extract(); - if !(::dafny_runtime::seq![97] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses1Byte(&encoded) { - panic!("Halt") - }; - let mut valueOrError11 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError11 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError11.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError11.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - return (); - } - pub fn Test2Bytes() -> () { - let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(163 as u16)]; - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError0 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); - if !(::dafny_runtime::seq![194, 163] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses2Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError1 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError1.read().IsFailure()) { - panic!("Halt") - }; - let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - valueOrError1.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(169 as u16)]; - let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError2 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError2.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError2.read().Extract(); - if !(::dafny_runtime::seq![194, 169] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses2Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError3 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError3.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError3.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(174 as u16)]; - let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError4 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError4.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError4.read().Extract(); - if !(::dafny_runtime::seq![194, 174] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses2Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError5 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError5.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError5.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(960 as u16)]; - let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError6 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError6.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError6.read().Extract(); - if !(::dafny_runtime::seq![207, 128] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses2Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError7 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError7.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError7.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - return (); - } - pub fn Test3Bytes() -> () { - let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(9094 as u16)]; - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError0 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); - if !(::dafny_runtime::seq![226, 142, 134] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses3Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError1 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError1.read().IsFailure()) { - panic!("Halt") - }; - let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - valueOrError1.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(9095 as u16)]; - let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError2 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError2.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError2.read().Extract(); - if !(::dafny_runtime::seq![226, 142, 135] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses3Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError3 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError3.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError3.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(8987 as u16)]; - let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError4 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError4.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError4.read().Extract(); - if !(::dafny_runtime::seq![226, 140, 155] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses3Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError5 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError5.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError5.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(7544 as u16)]; - let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError6 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError6.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError6.read().Extract(); - if !(::dafny_runtime::seq![225, 181, 184] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses3Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError7 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError7.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError7.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(29483 as u16)]; - let mut valueOrError8 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError8 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError8.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError8.read().Extract(); - if !(::dafny_runtime::seq![231, 140, 171] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses3Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError9 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError9 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError9.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError9.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - return (); - } - pub fn Test4Bytes() -> () { - let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16(55304 as u16), - ::dafny_runtime::DafnyCharUTF16(56320 as u16) - ]; - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError0 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); - if !(::dafny_runtime::seq![240, 146, 128, 128] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses4Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError1 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError1.read().IsFailure()) { - panic!("Halt") - }; - let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - valueOrError1.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - decoded = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16(55349 as u16), - ::dafny_runtime::DafnyCharUTF16(57281 as u16) - ]; - let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError2 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); - if !(!valueOrError2.read().IsFailure()) { - panic!("Halt") - }; - encoded = valueOrError2.read().Extract(); - if !(::dafny_runtime::seq![240, 157, 159, 129] == encoded.clone()) { - panic!("Halt") - }; - if !super::UTF8::_default::Uses4Bytes(&encoded) { - panic!("Halt") - }; - let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >::new(); - valueOrError3 = - ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); - if !(!valueOrError3.read().IsFailure()) { - panic!("Halt") - }; - redecoded = valueOrError3.read().Extract(); - if !(decoded.clone() == redecoded.clone()) { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::r#_TestUTF8_Compile::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod _module { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _Test__Main_() -> () { - let mut success: bool = true; - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.TestEncodeHappyCase: "# - )) - ); - super::r#_TestUTF8_Compile::_default::TestEncodeHappyCase(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.TestEncodeInvalidUnicode: "# - )) - ); - super::r#_TestUTF8_Compile::_default::TestEncodeInvalidUnicode(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.TestDecodeHappyCase: "# - )) - ); - super::r#_TestUTF8_Compile::_default::TestDecodeHappyCase(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.TestDecodeInvalidUnicode: "# - )) - ); - super::r#_TestUTF8_Compile::_default::TestDecodeInvalidUnicode(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.Test1Byte: "# - )) - ); - super::r#_TestUTF8_Compile::_default::Test1Byte(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.Test2Bytes: "# - )) - ); - super::r#_TestUTF8_Compile::_default::Test2Bytes(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.Test3Bytes: "# - )) - ); - super::r#_TestUTF8_Compile::_default::Test3Bytes(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"TestUTF8.Test4Bytes: "# - )) - ); - super::r#_TestUTF8_Compile::_default::Test4Bytes(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - if !success { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::_module::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -fn main() { - _module::_default::_Test__Main_(); -}