Skip to content

Commit e5ef5af

Browse files
committed
feat(server): deprecate server::conn http & parts
1 parent cee1bc3 commit e5ef5af

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/server/conn.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ pub use super::tcp::{AddrIncoming, AddrStream};
9898
#[derive(Clone, Debug)]
9999
#[cfg(any(feature = "http1", feature = "http2"))]
100100
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
101+
#[cfg_attr(
102+
feature = "deprecated",
103+
deprecated(
104+
note = "This struct will be replaced with `server::conn::http1::Builder` and `server::conn::http2::Builder` in 1.0, enable the \"backports\" feature to use them now."
105+
)
106+
)]
101107
pub struct Http<E = Exec> {
102108
pub(crate) exec: E,
103109
h1_half_close: bool,
@@ -213,6 +219,12 @@ impl<E> Unpin for Fallback<E> {}
213219
#[derive(Debug)]
214220
#[cfg(any(feature = "http1", feature = "http2"))]
215221
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
222+
#[cfg_attr(
223+
feature = "deprecated",
224+
deprecated(
225+
note = "This struct will be replaced with `server::conn::http1::Parts` in 1.0, enable the \"backports\" feature to use them now."
226+
)
227+
)]
216228
pub struct Parts<T, S> {
217229
/// The original IO object used in the handshake.
218230
pub io: T,
@@ -232,6 +244,7 @@ pub struct Parts<T, S> {
232244

233245
// ===== impl Http =====
234246

247+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
235248
#[cfg(any(feature = "http1", feature = "http2"))]
236249
impl Http {
237250
/// Creates a new instance of the HTTP protocol, ready to spawn a server or
@@ -255,6 +268,7 @@ impl Http {
255268
}
256269
}
257270

271+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
258272
#[cfg(any(feature = "http1", feature = "http2"))]
259273
impl<E> Http<E> {
260274
/// Sets whether HTTP1 is required.
@@ -738,6 +752,7 @@ where
738752
///
739753
/// # Panics
740754
/// This method will panic if this connection is using an h2 protocol.
755+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
741756
pub fn into_parts(self) -> Parts<I, S> {
742757
self.try_into_parts()
743758
.unwrap_or_else(|| panic!("h2 cannot into_inner"))
@@ -746,6 +761,7 @@ where
746761
/// Return the inner IO object, and additional information, if available.
747762
///
748763
/// This method will return a `None` if this connection is using an h2 protocol.
764+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
749765
pub fn try_into_parts(self) -> Option<Parts<I, S>> {
750766
match self.conn.unwrap() {
751767
#[cfg(feature = "http1")]
@@ -772,8 +788,7 @@ where
772788
/// upgrade. Once the upgrade is completed, the connection would be "done",
773789
/// but it is not desired to actually shutdown the IO object. Instead you
774790
/// would take it back using `into_parts`.
775-
pub fn poll_without_shutdown(&mut self, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>>
776-
{
791+
pub fn poll_without_shutdown(&mut self, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
777792
loop {
778793
match *self.conn.as_mut().unwrap() {
779794
#[cfg(feature = "http1")]
@@ -809,8 +824,8 @@ where
809824
/// # Error
810825
///
811826
/// This errors if the underlying connection protocol is not HTTP/1.
812-
pub fn without_shutdown(self) -> impl Future<Output = crate::Result<Parts<I, S>>>
813-
{
827+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
828+
pub fn without_shutdown(self) -> impl Future<Output = crate::Result<Parts<I, S>>> {
814829
let mut conn = Some(self);
815830
futures_util::future::poll_fn(move |cx| {
816831
ready!(conn.as_mut().unwrap().poll_without_shutdown(cx))?;

src/server/server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::common::exec::{ConnStreamExec, NewSvcExec};
2020
use crate::common::{task, Future, Pin, Poll, Unpin};
2121
// Renamed `Http` as `Http_` for now so that people upgrading don't see an
2222
// error that `hyper::server::Http` is private...
23+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
2324
use super::conn::{Connection, Http as Http_, UpgradeableConnection};
2425
use super::shutdown::{Graceful, GracefulWatcher};
2526
use crate::service::{HttpService, MakeServiceRef};
@@ -46,6 +47,7 @@ pin_project! {
4647
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
4748
pub struct Builder<I, E = Exec> {
4849
incoming: I,
50+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
4951
protocol: Http_<E>,
5052
}
5153

@@ -57,6 +59,7 @@ impl<I> Server<I, ()> {
5759
pub fn builder(incoming: I) -> Builder<I> {
5860
Builder {
5961
incoming,
62+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
6063
protocol: Http_::new(),
6164
}
6265
}
@@ -237,6 +240,7 @@ impl<I: fmt::Debug, S: fmt::Debug> fmt::Debug for Server<I, S> {
237240
// ===== impl Builder =====
238241

239242
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
243+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
240244
impl<I, E> Builder<I, E> {
241245
/// Start a new builder, wrapping an incoming stream and low-level options.
242246
///

tests/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,6 +2642,7 @@ async fn http2_keep_alive_count_server_pings() {
26422642
}
26432643

26442644
// Tests for backported 1.0 APIs
2645+
#[deny(deprecated)]
26452646
mod backports {
26462647
use super::*;
26472648
use hyper::server::conn::{http1, http2};

0 commit comments

Comments
 (0)