feat(lib): Export more things with Cargo features [server, !http1, !http2]

* server::Server
* server::conn::{AddrIncoming, AddrStream}

This allows higher-level libraries to use or re-export more parts of the
API without deciding for the end user which HTTP versions the hyper
server will support.
This commit is contained in:
Jonas Platte
2021-08-29 22:24:44 +02:00
committed by Sean McArthur
parent cf6f62c71e
commit 0a4b56acb8
7 changed files with 127 additions and 66 deletions

View File

@@ -38,11 +38,7 @@ pub(super) enum Kind {
#[allow(unused)]
Connect,
/// Error creating a TcpListener.
#[cfg(all(
any(feature = "http1", feature = "http2"),
feature = "tcp",
feature = "server"
))]
#[cfg(all(feature = "tcp", feature = "server"))]
Listen,
/// Error accepting on an Incoming stream.
#[cfg(any(feature = "http1", feature = "http2"))]
@@ -265,8 +261,7 @@ impl Error {
Error::new(Kind::Io).with(cause)
}
#[cfg(all(any(feature = "http1", feature = "http2"), feature = "tcp"))]
#[cfg(feature = "server")]
#[cfg(all(feature = "server", feature = "tcp"))]
pub(super) fn new_listen<E: Into<Cause>>(cause: E) -> Error {
Error::new(Kind::Listen).with(cause)
}
@@ -410,8 +405,7 @@ impl Error {
Kind::ChannelClosed => "channel closed",
Kind::Connect => "error trying to connect",
Kind::Canceled => "operation was canceled",
#[cfg(all(any(feature = "http1", feature = "http2"), feature = "tcp"))]
#[cfg(feature = "server")]
#[cfg(all(feature = "server", feature = "tcp"))]
Kind::Listen => "error creating server listener",
#[cfg(any(feature = "http1", feature = "http2"))]
#[cfg(feature = "server")]