Skip to content

Commit

Permalink
fix(lib): remove deprecated tokio-proto APIs
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Many of these APIs have been deprecated for a while,
  check the documentation for the recommended way to use hyper now.
  • Loading branch information
seanmonstar committed Mar 19, 2018
1 parent dbfc45b commit a37e6b5
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 553 deletions.
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ percent-encoding = "1.0"
relay = "0.1"
time = "0.1"
tokio-core = "0.1.11"
tokio-proto = { version = "0.1", optional = true }
tokio-service = "0.1"
tokio-io = "0.1"
unicase = "2.0"
Expand All @@ -47,8 +46,7 @@ spmc = "0.2"
url = "1.0"

[features]
default = ["server-proto"]
default = []
nightly = []
raw_status = []
compat = [ "http" ]
server-proto = ["tokio-proto"]
6 changes: 0 additions & 6 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,6 @@ impl<C, B> Config<C, B> {
self.set_host = val;
self
}

#[doc(hidden)]
#[deprecated(since="0.11.11", note="no_proto is always enabled")]
pub fn no_proto(self) -> Config<C, B> {
self
}
}

impl<C, B> Config<C, B>
Expand Down
15 changes: 0 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ extern crate relay;
extern crate time;
extern crate tokio_core as tokio;
#[macro_use] extern crate tokio_io;
#[cfg(feature = "tokio-proto")]
extern crate tokio_proto;
extern crate tokio_service;
extern crate unicase;

Expand All @@ -55,19 +53,6 @@ pub use version::HttpVersion;
#[cfg(feature = "raw_status")]
pub use proto::RawStatus;

macro_rules! feat_server_proto {
($($i:item)*) => ($(
#[cfg(feature = "server-proto")]
#[deprecated(
since="0.11.11",
note="All usage of the tokio-proto crate is going away."
)]
#[doc(hidden)]
#[allow(deprecated)]
$i
)*)
}

mod common;
#[cfg(test)]
mod mock;
Expand Down
14 changes: 6 additions & 8 deletions src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ impl<T> AsyncIo<T> {
self.park_tasks = enabled;
}

#[cfg(feature = "tokio-proto")]
//TODO: fix proto::conn::tests to not use tokio-proto API,
//and then this cfg flag go away
/*
pub fn flushed(&self) -> bool {
self.flushed
}
*/

pub fn blocked(&self) -> bool {
self.blocked
Expand All @@ -148,12 +147,11 @@ impl AsyncIo<MockCursor> {
AsyncIo::new(MockCursor::wrap(buf.into()), bytes)
}

#[cfg(feature = "tokio-proto")]
//TODO: fix proto::conn::tests to not use tokio-proto API,
//and then this cfg flag go away
pub fn new_eof() -> AsyncIo<MockCursor> {
AsyncIo::new(MockCursor::wrap(Vec::new().into()), 1)
/*
pub fn new_eof() -> AsyncIo<Buf> {
AsyncIo::new(Buf::wrap(Vec::new().into()), 1)
}
*/

fn close(&mut self) {
self.block_in(1);
Expand Down
44 changes: 0 additions & 44 deletions src/proto/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ use std::fmt;
use bytes::Bytes;
use futures::{Async, AsyncSink, Future, Poll, Sink, StartSend, Stream};
use futures::sync::{mpsc, oneshot};
#[cfg(feature = "tokio-proto")]
use tokio_proto;
use std::borrow::Cow;

use super::Chunk;

#[cfg(feature = "tokio-proto")]
pub type TokioBody = tokio_proto::streaming::Body<Chunk, ::Error>;
pub type BodySender = mpsc::Sender<Result<Chunk, ::Error>>;

/// A `Stream` for `Chunk`s used in requests and responses.
Expand All @@ -21,8 +17,6 @@ pub struct Body {

#[derive(Debug)]
enum Kind {
#[cfg(feature = "tokio-proto")]
Tokio(TokioBody),
Chan {
close_tx: oneshot::Sender<bool>,
rx: mpsc::Receiver<Result<Chunk, ::Error>>,
Expand Down Expand Up @@ -77,8 +71,6 @@ impl Body {

fn poll_inner(&mut self) -> Poll<Option<Chunk>, ::Error> {
match self.kind {
#[cfg(feature = "tokio-proto")]
Kind::Tokio(ref mut rx) => rx.poll(),
Kind::Chan { ref mut rx, .. } => match rx.poll().expect("mpsc cannot error") {
Async::Ready(Some(Ok(chunk))) => Ok(Async::Ready(Some(chunk))),
Async::Ready(Some(Err(err))) => Err(err),
Expand Down Expand Up @@ -160,42 +152,6 @@ impl ChunkSender {
}
}

feat_server_proto! {
impl From<Body> for tokio_proto::streaming::Body<Chunk, ::Error> {
fn from(b: Body) -> tokio_proto::streaming::Body<Chunk, ::Error> {
match b.kind {
Kind::Tokio(b) => b,
Kind::Chan { close_tx, rx } => {
// disable knowing if the Rx gets dropped, since we cannot
// pass this tx along.
let _ = close_tx.send(false);
rx.into()
},
Kind::Once(Some(chunk)) => TokioBody::from(chunk),
Kind::Once(None) |
Kind::Empty => TokioBody::empty(),
}
}
}

impl From<tokio_proto::streaming::Body<Chunk, ::Error>> for Body {
fn from(tokio_body: tokio_proto::streaming::Body<Chunk, ::Error>) -> Body {
Body::new(Kind::Tokio(tokio_body))
}
}
}

impl From<mpsc::Receiver<Result<Chunk, ::Error>>> for Body {
#[inline]
fn from(src: mpsc::Receiver<Result<Chunk, ::Error>>) -> Body {
let (tx, _) = oneshot::channel();
Body::new(Kind::Chan {
close_tx: tx,
rx: src,
})
}
}

impl From<Chunk> for Body {
#[inline]
fn from (chunk: Chunk) -> Body {
Expand Down
1 change: 0 additions & 1 deletion src/proto/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fmt;
//use std::mem;

use bytes::Bytes;

Expand Down
Loading

0 comments on commit a37e6b5

Please sign in to comment.