Skip to content

Commit 6e61750

Browse files
committed
feat(server): remove the high-level Server API
This removes `hyper::Server`, and it's related parts: - `hyper::server::Builder` - `hyper::server::accept` - `hyper::service::make_service_fn` New utilities for managing servers will exist in `hyper-util`.
1 parent ca99e23 commit 6e61750

File tree

13 files changed

+6
-1276
lines changed

13 files changed

+6
-1276
lines changed

src/common/drain.rs

Lines changed: 0 additions & 217 deletions
This file was deleted.

src/common/exec.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,17 @@ use std::future::Future;
33
use std::pin::Pin;
44
use std::sync::Arc;
55

6-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
7-
use crate::body::Body;
86
#[cfg(feature = "server")]
97
use crate::body::HttpBody;
108
#[cfg(all(feature = "http2", feature = "server"))]
119
use crate::proto::h2::server::H2Stream;
1210
use crate::rt::Executor;
13-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
14-
use crate::server::server::{new_svc::NewSvcTask, Watcher};
15-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
16-
use crate::service::HttpService;
1711

1812
#[cfg(feature = "server")]
1913
pub trait ConnStreamExec<F, B: HttpBody>: Clone {
2014
fn execute_h2stream(&mut self, fut: H2Stream<F, B>);
2115
}
2216

23-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
24-
pub trait NewSvcExec<I, N, S: HttpService<Body>, E, W: Watcher<I, S, E>>: Clone {
25-
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>);
26-
}
27-
2817
pub(crate) type BoxSendFuture = Pin<Box<dyn Future<Output = ()> + Send>>;
2918

3019
// Either the user provides an executor for background tasks, or we use
@@ -78,18 +67,6 @@ where
7867
}
7968
}
8069

81-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
82-
impl<I, N, S, E, W> NewSvcExec<I, N, S, E, W> for Exec
83-
where
84-
NewSvcTask<I, N, S, E, W>: Future<Output = ()> + Send + 'static,
85-
S: HttpService<Body>,
86-
W: Watcher<I, S, E>,
87-
{
88-
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) {
89-
self.execute(fut)
90-
}
91-
}
92-
9370
// ==== impl Executor =====
9471

9572
#[cfg(feature = "server")]
@@ -104,19 +81,6 @@ where
10481
}
10582
}
10683

107-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
108-
impl<I, N, S, E, W> NewSvcExec<I, N, S, E, W> for E
109-
where
110-
E: Executor<NewSvcTask<I, N, S, E, W>> + Clone,
111-
NewSvcTask<I, N, S, E, W>: Future<Output = ()>,
112-
S: HttpService<Body>,
113-
W: Watcher<I, S, E>,
114-
{
115-
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) {
116-
self.execute(fut)
117-
}
118-
}
119-
12084
// If http2 is not enable, we just have a stub here, so that the trait bounds
12185
// that *would* have been needed are still checked. Why?
12286
//

src/common/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ macro_rules! ready {
1010
pub(crate) mod buf;
1111
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
1212
pub(crate) mod date;
13-
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
14-
pub(crate) mod drain;
1513
#[cfg(any(feature = "http1", feature = "http2", feature = "server"))]
1614
pub(crate) mod exec;
1715
pub(crate) mod io;

src/error.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ pub(super) enum Kind {
4040
/// Error creating a TcpListener.
4141
#[cfg(all(feature = "tcp", feature = "server"))]
4242
Listen,
43-
/// Error accepting on an Incoming stream.
44-
#[cfg(any(feature = "http1", feature = "http2"))]
45-
#[cfg(feature = "server")]
46-
Accept,
4743
/// User took too long to send headers
4844
#[cfg(all(feature = "http1", feature = "server", feature = "runtime"))]
4945
HeaderTimeout,
@@ -96,10 +92,6 @@ pub(super) enum User {
9692
Body,
9793
/// The user aborted writing of the outgoing body.
9894
BodyWriteAborted,
99-
/// Error calling user's MakeService.
100-
#[cfg(any(feature = "http1", feature = "http2"))]
101-
#[cfg(feature = "server")]
102-
MakeService,
10395
/// Error from future of user's Service.
10496
#[cfg(any(feature = "http1", feature = "http2"))]
10597
Service,
@@ -278,12 +270,6 @@ impl Error {
278270
Error::new(Kind::Listen).with(cause)
279271
}
280272

281-
#[cfg(any(feature = "http1", feature = "http2"))]
282-
#[cfg(feature = "server")]
283-
pub(super) fn new_accept<E: Into<Cause>>(cause: E) -> Error {
284-
Error::new(Kind::Accept).with(cause)
285-
}
286-
287273
#[cfg(any(feature = "http1", feature = "http2"))]
288274
#[cfg(feature = "client")]
289275
pub(super) fn new_connect<E: Into<Cause>>(cause: E) -> Error {
@@ -356,12 +342,6 @@ impl Error {
356342
Error::new_user(User::ManualUpgrade)
357343
}
358344

359-
#[cfg(any(feature = "http1", feature = "http2"))]
360-
#[cfg(feature = "server")]
361-
pub(super) fn new_user_make_service<E: Into<Cause>>(cause: E) -> Error {
362-
Error::new_user(User::MakeService).with(cause)
363-
}
364-
365345
#[cfg(any(feature = "http1", feature = "http2"))]
366346
pub(super) fn new_user_service<E: Into<Cause>>(cause: E) -> Error {
367347
Error::new_user(User::Service).with(cause)
@@ -435,9 +415,6 @@ impl Error {
435415
Kind::Canceled => "operation was canceled",
436416
#[cfg(all(feature = "server", feature = "tcp"))]
437417
Kind::Listen => "error creating server listener",
438-
#[cfg(any(feature = "http1", feature = "http2"))]
439-
#[cfg(feature = "server")]
440-
Kind::Accept => "error accepting connection",
441418
#[cfg(all(feature = "http1", feature = "server", feature = "runtime"))]
442419
Kind::HeaderTimeout => "read header from client timeout",
443420
#[cfg(any(feature = "http1", feature = "http2"))]
@@ -455,9 +432,6 @@ impl Error {
455432
Kind::User(User::Body) => "error from user's HttpBody stream",
456433
Kind::User(User::BodyWriteAborted) => "user body write aborted",
457434
#[cfg(any(feature = "http1", feature = "http2"))]
458-
#[cfg(feature = "server")]
459-
Kind::User(User::MakeService) => "error from user's MakeService",
460-
#[cfg(any(feature = "http1", feature = "http2"))]
461435
Kind::User(User::Service) => "error from user's Service",
462436
#[cfg(any(feature = "http1", feature = "http2"))]
463437
#[cfg(feature = "server")]

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,4 @@ cfg_feature! {
102102
#![feature = "server"]
103103

104104
pub mod server;
105-
#[doc(no_inline)]
106-
pub use crate::server::Server;
107105
}

0 commit comments

Comments
 (0)