salvo_rustls/
lib.rs

1//! # hyper-rustls
2//!
3//! A pure-Rust HTTPS connector for [hyper](https://hyper.rs), based on
4//! [Rustls](https://github.com/rustls/rustls).
5//!
6//! ## Example
7//!
8//! ```no_run
9//! # #[cfg(all(feature = "rustls-native-certs", feature = "tokio-runtime", feature = "http1"))]
10//! # fn main() {
11//! use hyper::{Body, Client, StatusCode, Uri};
12//!
13//! let mut rt = tokio::runtime::Runtime::new().unwrap();
14//! let url = ("https://hyper.rs").parse().unwrap();
15//! let https = hyper_rustls::HttpsConnectorBuilder::new()
16//!     .with_native_roots()
17//!     .https_only()
18//!     .enable_http1()
19//!     .build();
20//!
21//! let client: Client<_, hyper::Body> = Client::builder().build(https);
22//!
23//! let res = rt.block_on(client.get(url)).unwrap();
24//! assert_eq!(res.status(), StatusCode::OK);
25//! # }
26//! # #[cfg(not(all(feature = "rustls-native-certs", feature = "tokio-runtime", feature = "http1")))]
27//! # fn main() {}
28//! ```
29
30#![warn(missing_docs)]
31#![cfg_attr(docsrs, feature(doc_cfg))]
32
33mod config;
34mod connector;
35mod stream;
36
37#[cfg(feature = "logging")]
38mod log {
39    pub use log::{debug, trace};
40}
41
42#[cfg(not(feature = "logging"))]
43mod log {
44    macro_rules! trace    ( ($($tt:tt)*) => {{}} );
45    macro_rules! debug    ( ($($tt:tt)*) => {{}} );
46    pub(crate) use {debug, trace};
47}
48
49pub use crate::config::ConfigBuilderExt;
50pub use crate::connector::builder::ConnectorBuilder as HttpsConnectorBuilder;
51pub use crate::connector::HttpsConnector;
52pub use crate::stream::MaybeHttpsStream;
53
54/// The various states of the [`HttpsConnectorBuilder`]
55pub mod builderstates {
56    #[cfg(feature = "http2")]
57    pub use crate::connector::builder::WantsProtocols3;
58    pub use crate::connector::builder::{
59        WantsProtocols1, WantsProtocols2, WantsSchemes, WantsTlsConfig,
60    };
61}