Debian Codegraph @

crt/s2n/bindings/rust/standard/s2n-tls-hyper/src/lib.rs

raw symbols SCIP
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 #![warn(missing_docs)]
5
6 //! This crate provides compatibility structs for the [hyper](https://hyper.rs/) HTTP library,
7 //! allowing s2n-tls to be used as the underlying TLS implementation to negotiate HTTPS with hyper
8 //! clients.
9 //!
10 //! `s2n-tls-hyper` provides an `HttpsConnector` struct which is compatible with the
11 //! `hyper_util::client::legacy::Client` builder, allowing hyper clients to be constructed with
12 //! configurable s2n-tls connections. The following example demonstrates how to construct a hyper
13 //! client with s2n-tls:
14 //!
15 //! ```
16 //! use std::str::FromStr;
17 //! use hyper_util::{
18 //! client::legacy::Client,
19 //! rt::TokioExecutor,
20 //! };
21 //! use s2n_tls_hyper::connector::HttpsConnector;
22 //! use s2n_tls::config::Config;
23 //! use bytes::Bytes;
24 //! use http_body_util::Empty;
25 //! use http::uri::Uri;
26 //!
27 //! // An `HttpsConnector` is built with an `s2n_tls::connection::Builder`, such as an
28 //! // `s2n_tls::config::Config`, which allows for the underlying TLS connection to be configured.
29 //! let config = Config::default();
30 //!
31 //! // The `HttpsConnector` wraps hyper's `HttpConnector`. `HttpsConnector::new()` will create
32 //! // a new `HttpConnector` to wrap.
33 //! let connector = HttpsConnector::new(Config::default());
34 //!
35 //! // The `HttpsConnector` can then be provided to the hyper Client builder, which can be used to
36 //! // send HTTP requests over HTTPS by specifying the HTTPS scheme in the URL.
37 //! let client: Client<_, Empty<Bytes>> =
38 //! Client::builder(TokioExecutor::new()).build(connector);
39 //! ```
40
41 /// Provides the `HttpsConnector` struct.
42 pub mod connector;
43
44 /// Provides errors returned by s2n-tls-hyper.
45 pub mod error;
46
47 mod stream;