Loading rust-runtime/aws-smithy-types/Cargo.toml +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ itoa = "1.0.0" num-integer = "0.1.44" ryu = "1.0.5" time = { version = "0.3.4", features = ["parsing"] } base64-simd = "0.7" base64-simd = "0.8" [dev-dependencies] base64 = "0.13.0" Loading rust-runtime/aws-smithy-types/src/base64.rs +5 −10 Original line number Diff line number Diff line Loading @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ //! A thin wrapper over `base64-simd` //! A thin wrapper over [`base64-simd`](https://docs.rs/base64-simd/) use base64_simd::Base64; use base64_simd::STANDARD; use std::error::Error; /// Failure to decode a base64 value. Loading @@ -28,20 +28,15 @@ impl std::fmt::Display for DecodeError { /// /// If input is not a valid base64 encoded string, this function will return `DecodeError`. pub fn decode(input: impl AsRef<str>) -> Result<Vec<u8>, DecodeError> { Base64::STANDARD .decode_to_boxed_bytes(input.as_ref().as_bytes()) .map(|bytes| bytes.into_vec()) .map_err(DecodeError) STANDARD.decode_to_vec(input.as_ref()).map_err(DecodeError) } /// Encode `input` into base64 using the standard base64 alphabet pub fn encode(input: impl AsRef<[u8]>) -> String { Base64::STANDARD .encode_to_boxed_str(input.as_ref()) .into_string() STANDARD.encode_to_string(input.as_ref()) } /// Returns the base64 representation's length for the given `length` of data pub fn encoded_length(length: usize) -> usize { Base64::STANDARD.encoded_length(length) STANDARD.encoded_length(length) } Loading
rust-runtime/aws-smithy-types/Cargo.toml +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ itoa = "1.0.0" num-integer = "0.1.44" ryu = "1.0.5" time = { version = "0.3.4", features = ["parsing"] } base64-simd = "0.7" base64-simd = "0.8" [dev-dependencies] base64 = "0.13.0" Loading
rust-runtime/aws-smithy-types/src/base64.rs +5 −10 Original line number Diff line number Diff line Loading @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ //! A thin wrapper over `base64-simd` //! A thin wrapper over [`base64-simd`](https://docs.rs/base64-simd/) use base64_simd::Base64; use base64_simd::STANDARD; use std::error::Error; /// Failure to decode a base64 value. Loading @@ -28,20 +28,15 @@ impl std::fmt::Display for DecodeError { /// /// If input is not a valid base64 encoded string, this function will return `DecodeError`. pub fn decode(input: impl AsRef<str>) -> Result<Vec<u8>, DecodeError> { Base64::STANDARD .decode_to_boxed_bytes(input.as_ref().as_bytes()) .map(|bytes| bytes.into_vec()) .map_err(DecodeError) STANDARD.decode_to_vec(input.as_ref()).map_err(DecodeError) } /// Encode `input` into base64 using the standard base64 alphabet pub fn encode(input: impl AsRef<[u8]>) -> String { Base64::STANDARD .encode_to_boxed_str(input.as_ref()) .into_string() STANDARD.encode_to_string(input.as_ref()) } /// Returns the base64 representation's length for the given `length` of data pub fn encoded_length(length: usize) -> usize { Base64::STANDARD.encoded_length(length) STANDARD.encoded_length(length) }