hyper/lib.rs
1#![deny(missing_docs)]
2#![deny(missing_debug_implementations)]
3#![cfg_attr(test, deny(rust_2018_idioms))]
4#![cfg_attr(all(test, feature = "full"), deny(unreachable_pub))]
5#![cfg_attr(all(test, feature = "full"), deny(warnings))]
6#![cfg_attr(all(test, feature = "nightly"), feature(test))]
7#![cfg_attr(docsrs, feature(doc_cfg))]
8
9//! # hyper
10//!
11//! hyper is a **fast** and **correct** HTTP implementation written in and for Rust.
12//!
13//! ## Features
14//!
15//! - HTTP/1 and HTTP/2
16//! - Asynchronous design
17//! - Leading in performance
18//! - Tested and **correct**
19//! - Extensive production use
20//! - [Client](client/index.html) and [Server](server/index.html) APIs
21//!
22//! If just starting out, **check out the [Guides](https://hyper.rs/guides/1/)
23//! first.**
24//!
25//! ## "Low-level"
26//!
27//! hyper is a lower-level HTTP library, meant to be a building block
28//! for libraries and applications.
29//!
30//! If looking for just a convenient HTTP client, consider the
31//! [reqwest](https://crates.io/crates/reqwest) crate.
32//!
33//! # Cancel safety
34//!
35//! Futures returned by hyper are cancel safe: dropping a future before it
36//! completes is the supported way to cancel the operation. See the
37//! documentation on individual futures — for example `SendRequest::send_request`
38//! in `client::conn::http1` and `client::conn::http2` — for the protocol-
39//! specific behavior on cancellation.
40//!
41//! # Optional Features
42//!
43//! hyper uses a set of [feature flags] to reduce the amount of compiled code.
44//! It is possible to just enable certain features over others. By default,
45//! hyper does not enable any features but allows one to enable a subset for
46//! their use case. Below is a list of the available feature flags. You may
47//! also notice above each function, struct and trait there is listed one or
48//! more feature flags that are required for that item to be used.
49//!
50//! If you are new to hyper it is possible to enable the `full` feature flag
51//! which will enable all public APIs. Beware though that this will pull in
52//! many extra dependencies that you may not need.
53//!
54//! The following optional features are available:
55//!
56//! - `http1`: Enables HTTP/1 support.
57//! - `http2`: Enables HTTP/2 support.
58//! - `client`: Enables the HTTP `client`.
59//! - `server`: Enables the HTTP `server`.
60//!
61//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
62//!
63//! ## Unstable Features
64//!
65//! hyper includes a set of unstable optional features that can be enabled through the use of a
66//! feature flag and a [configuration flag].
67//!
68//! The following is a list of feature flags and their corresponding `RUSTFLAG`:
69//!
70//! - `ffi`: Enables C API for hyper `hyper_unstable_ffi`.
71//! - `tracing`: Enables debug logging with `hyper_unstable_tracing`.
72//!
73//! For example:
74//!
75//! ```notrust
76//! RUSTFLAGS="--cfg hyper_unstable_tracing" cargo build
77//! ```
78//!
79//! [configuration flag]: https://doc.rust-lang.org/reference/conditional-compilation.html
80//!
81//! # Stability
82//!
83//! It's worth talking a bit about the stability of hyper. hyper's API follows
84//! [SemVer](https://semver.org). Breaking changes will only be introduced in
85//! major versions, if ever. New additions to the API, such as new types,
86//! methods, or traits will only be added in minor versions.
87//!
88//! Some parts of hyper are documented as NOT being part of the stable API. The
89//! following is a brief list, you can read more about each one in the relevant
90//! part of the documentation.
91//!
92//! - Downcasting error types from `Error::source()` is not considered stable.
93//! - Private dependencies use of global variables is not considered stable.
94//! So, if a dependency uses `log` or `tracing`, hyper doesn't promise it
95//! will continue to do so.
96//! - Behavior from default options is not stable. hyper reserves the right to
97//! add new options that are enabled by default which might alter the
98//! behavior, for the purposes of protection. It is also possible to _change_
99//! what the default options are set to, also in efforts to protect the
100//! most people possible.
101#[doc(hidden)]
102pub use http;
103
104#[cfg(all(test, feature = "nightly"))]
105extern crate test;
106
107#[doc(no_inline)]
108pub use http::{header, HeaderMap, Method, Request, Response, StatusCode, Uri, Version};
109
110pub use crate::error::{Error, Result};
111
112#[macro_use]
113mod cfg;
114
115#[macro_use]
116mod trace;
117
118pub mod body;
119mod common;
120mod error;
121pub mod ext;
122#[cfg(test)]
123mod mock;
124pub mod rt;
125pub mod service;
126pub mod upgrade;
127
128#[cfg(feature = "ffi")]
129#[cfg_attr(docsrs, doc(cfg(all(feature = "ffi", hyper_unstable_ffi))))]
130pub mod ffi;
131
132cfg_proto! {
133 mod headers;
134 mod proto;
135}
136
137cfg_feature! {
138 #![feature = "client"]
139
140 pub mod client;
141}
142
143cfg_feature! {
144 #![feature = "server"]
145
146 pub mod server;
147}