Hyper 1.x
Note
The AWS SDK for Rust was developed before hyper
released a stable 1.0 version. The SDK currently defaults to using v0.14
version of hyper
.
hyper
is a lower-level HTTP library for Rust that can be used with the AWS SDK for Rust to make API service calls. For the
reference documentation on this crate, see hyper - Rusthyper
and a CryptoMode:Ring
provider.
Clients with hyper
1.0 support are located in the aws-smithy-experimental
Choose a crypto provider
You must choose a CryptoProvider
and enable the required feature in the aws-smithy-experimental
crate.
The following CryptoProvider
modes are available:
-
CryptoMode:AwsLc
- a cryptographic provider based onaws-lc-rs
. This is a general-purpose cryptographic library maintained by the AWS Cryptography team for AWS and their customers, based on code from the Google BoringSSL project and the OpenSSL project. -
Requires feature
crypto-aws-lc
.
-
-
CryptoMode:AwsLcFips
- a FIPS-compliant cryptographic provider based onaws-lc-rs
. -
Requires feature
crypto-aws-lc-fips
.Note
This might require additional build tools to be able to compile. For more information, reference the
aws-lc-rs
repository and build instructions.
-
-
CryptoMode:Ring
- a cryptographic provider based onring
. This is a "Safe, fast, small crypto using Rust". -
Requires feature
crypto-ring
.Note
This is the crypto provider that the SDK for Rust uses in the default
hyper
v0.14 client.
-
How to enable a feature for a crate
The following example shows how to add the crypto-aws-lc
feature to the aws-smithy-experimental
crate
in your project's Cargo.toml
:
[dependencies]
aws-smithy-experimental
= { version = "0.1.3", features = ["crypto-aws-lc
"] }
Alternatively, you can run the following command at a command prompt in your project's folder:
$
cargo addaws-smithy-experimental
-Fcrypto-aws-lc
For more information, see Features
Create a hyper
1.0 client and use it with the SDK
To create a hyper
1.0 client, in your project's Cargo.toml
, add the
aws-smithy-experimental
crate. The HyperClientBuilder
requires you to choose a
CryptoProvider
. The previous section covered the provider choices and how to enable one of the crypto-related features of
the aws-smithy-experimental
crate.
The following code uses CryptoMode::AwsLc
as the crypto provider for a hyper
1.0 HTTP client to use with
an Amazon Simple Storage Service (Amazon S3) service client. For this example, your project's Cargo.toml
also needs to include the
AWS service's crate, aws-sdk-s3
.
use aws-smithy-experimental::hyper_1_0::{ CryptoMode, HyperClientBuilder }; use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion; let http_client = HyperClientBuilder::new() .crypto_mode(CryptoMode::AwsLc) // Choose a crypto provider. .build_https(); let config = aws_config::defaults(BehaviorVersion::latest()) .http_client(http_client) // Set the http_client on the shared config struct. .load() .await; let s3 = aws_sdk_s3::Client::new(&config);
The HTTP client can be set on the shared config struct or on a specific service's config struct.