diff --git a/rust-runtime/aws-smithy-types/Cargo.toml b/rust-runtime/aws-smithy-types/Cargo.toml index 7b52b8b6d8..3fd9186d0f 100644 --- a/rust-runtime/aws-smithy-types/Cargo.toml +++ b/rust-runtime/aws-smithy-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-smithy-types" -version = "1.2.7" +version = "1.2.8" authors = [ "AWS Rust SDK Team ", "Russell Cohen ", diff --git a/rust-runtime/aws-smithy-types/src/blob.rs b/rust-runtime/aws-smithy-types/src/blob.rs index 7f76a45df3..f6ba16fda4 100644 --- a/rust-runtime/aws-smithy-types/src/blob.rs +++ b/rust-runtime/aws-smithy-types/src/blob.rs @@ -31,6 +31,24 @@ impl AsRef<[u8]> for Blob { } } +impl From> for Blob { + fn from(value: Vec) -> Self { + Blob::new(value) + } +} + +impl From for Vec { + fn from(value: Blob) -> Self { + value.into_inner() + } +} + +impl From<&[u8]> for Blob { + fn from(value: &[u8]) -> Self { + Blob::new(value) + } +} + #[cfg(all(aws_sdk_unstable, feature = "serde-serialize"))] mod serde_serialize { use super::*; @@ -103,6 +121,25 @@ mod serde_deserialize { } #[cfg(test)] +mod test { + use crate::Blob; + + #[test] + fn blob_conversion() { + let my_bytes: &[u8] = &[1u8, 2u8, 3u8]; + let my_vec = vec![1u8, 2u8, 3u8]; + let orig_vec = my_vec.clone(); + + let blob1: Blob = my_bytes.into(); + let vec1: Vec = blob1.into(); + assert_eq!(orig_vec, vec1); + + let blob2: Blob = my_vec.into(); + let vec2: Vec = blob2.into(); + assert_eq!(orig_vec, vec2); + } +} + #[cfg(all( aws_sdk_unstable, feature = "serde-serialize",