-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable full SDK test models in Rust (#584)
Enables the KMS and DDB test models in Rust, mainly by hooking up union support for SDK wrappers as well, plus some miscellaneous bug fixes and some special cases where I've given up on inferring the smithy-rs logic for now. Both test models needed an extern to implement client creation externs, which I borrowed from https://github.com/aws/aws-database-encryption-sdk-dynamodb/tree/ajewell/rust/releases/rust/db_esdk/src Also added top-level make <lang> Makefile targets for fully generating and building all code for a given language!
- Loading branch information
Showing
82 changed files
with
677 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
207 changes: 113 additions & 94 deletions
207
TestModels/aws-sdks/ddb-lite/runtimes/rust/src/conversions/attribute_value.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,129 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. | ||
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. | ||
|
||
#[allow(dead_code)] | ||
pub fn to_dafny( | ||
value: &aws_sdk_dynamodb::types::AttributeValue, | ||
) -> ::std::rc::Rc<crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue>{ | ||
::std::rc::Rc::new( | ||
match value { | ||
aws_sdk_dynamodb::types::AttributeValue::B(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::B { | ||
B: crate::standard_library_conversions::blob_to_dafny(x) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Bool(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BOOL { | ||
BOOL: *x | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Bs(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BS { | ||
BS: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(x, crate::standard_library_conversions::blob_to_dafny) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::L(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::L { | ||
L: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(x, to_dafny) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::M(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::M { | ||
M: dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(x, | ||
|s| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s), | ||
to_dafny) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::N(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::N { | ||
N: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Ns(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NS { | ||
NS: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(x, | ||
|s| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(s)) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Null(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NULL { | ||
NULL: *x | ||
}, | ||
) -> ::std::rc::Rc< | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue, | ||
> { | ||
::std::rc::Rc::new(match value { | ||
aws_sdk_dynamodb::types::AttributeValue::S(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::S { | ||
S: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x) | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Ss(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::SS { | ||
SS: dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(x, | ||
|s| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(s)) | ||
}, | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::S { | ||
S: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x), | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::N(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::N { | ||
N: dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&x), | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::B(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::B { | ||
B: crate::standard_library_conversions::blob_to_dafny(&x), | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Ss(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::SS { | ||
SS: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&x, | ||
|e| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&e), | ||
) | ||
, | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Ns(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NS { | ||
NS: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&x, | ||
|e| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&e), | ||
) | ||
, | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Bs(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BS { | ||
BS: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&x, | ||
|e| crate::standard_library_conversions::blob_to_dafny(&e), | ||
) | ||
, | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::M(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::M { | ||
M: ::dafny_runtime::dafny_runtime_conversions::hashmap_to_dafny_map(&x.clone(), | ||
|k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&k), | ||
|v| crate::conversions::attribute_value::to_dafny(&v) | ||
, | ||
) | ||
, | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::L(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::L { | ||
L: ::dafny_runtime::dafny_runtime_conversions::vec_to_dafny_sequence(&x, | ||
|e| crate::conversions::attribute_value::to_dafny(&e) | ||
, | ||
) | ||
, | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Null(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NULL { | ||
NULL: x.clone(), | ||
}, | ||
aws_sdk_dynamodb::types::AttributeValue::Bool(x) => | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BOOL { | ||
BOOL: x.clone(), | ||
}, | ||
_ => panic!("Unknown union variant: {:?}", value), | ||
} | ||
) | ||
}) | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn from_dafny( | ||
dafny_value: ::std::rc::Rc< | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue, | ||
>, | ||
) -> aws_sdk_dynamodb::types::AttributeValue { | ||
match &*dafny_value { | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::S { S } => | ||
aws_sdk_dynamodb::types::AttributeValue::S( | ||
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(S) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::N { N } => | ||
aws_sdk_dynamodb::types::AttributeValue::N( | ||
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(N) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::B { B } => | ||
aws_sdk_dynamodb::types::AttributeValue::B( | ||
crate::standard_library_conversions::blob_from_dafny(B.clone()) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::SS { SS } => | ||
aws_sdk_dynamodb::types::AttributeValue::Ss( | ||
dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(SS, | ||
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NS { NS } => | ||
aws_sdk_dynamodb::types::AttributeValue::Ss( | ||
dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(NS, | ||
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BS { BS } => | ||
aws_sdk_dynamodb::types::AttributeValue::Bs( | ||
dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(BS, | ||
|b| crate::standard_library_conversions::blob_from_dafny(b.clone())) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::M { M } => | ||
aws_sdk_dynamodb::types::AttributeValue::M( | ||
dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(M, | ||
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string, | ||
|v| from_dafny(v.clone())) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::L { L } => | ||
aws_sdk_dynamodb::types::AttributeValue::L( | ||
dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(L, | ||
|v| from_dafny(v.clone())) | ||
), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NULL { NULL } => | ||
aws_sdk_dynamodb::types::AttributeValue::Null(*NULL), | ||
crate::software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BOOL { BOOL } => | ||
aws_sdk_dynamodb::types::AttributeValue::Bool(*BOOL), | ||
} | ||
match &::std::rc::Rc::unwrap_or_clone(dafny_value) { | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::S { | ||
S: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::S(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(x)), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::N { | ||
N: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::N(dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(x)), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::B { | ||
B: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::B(crate::standard_library_conversions::blob_from_dafny(x.clone())), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::SS { | ||
SS: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::Ss(::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(x, | ||
|e| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(e), | ||
) | ||
), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NS { | ||
NS: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::Ns(::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(x, | ||
|e| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(e), | ||
) | ||
), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BS { | ||
BS: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::Bs(::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(x, | ||
|e| crate::standard_library_conversions::blob_from_dafny(e.clone()), | ||
) | ||
), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::M { | ||
M: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::M(::dafny_runtime::dafny_runtime_conversions::dafny_map_to_hashmap(&x, | ||
|k| dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(k), | ||
|v| crate::conversions::attribute_value::from_dafny(v.clone()) | ||
, | ||
) | ||
), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::L { | ||
L: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::L(::dafny_runtime::dafny_runtime_conversions::dafny_sequence_to_vec(x, | ||
|e| crate::conversions::attribute_value::from_dafny(e.clone()) | ||
, | ||
) | ||
), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::NULL { | ||
NULL: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::Null(x .clone()), | ||
crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::AttributeValue::BOOL { | ||
BOOL: x @ _, | ||
} => aws_sdk_dynamodb::types::AttributeValue::Bool(x .clone()), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.