refactor(lib): update to 2018 edition
This commit is contained in:
		| @@ -9,12 +9,12 @@ use tokio_buf::SizeHint; | ||||
| use h2; | ||||
| use http::HeaderMap; | ||||
|  | ||||
| use common::Never; | ||||
| use crate::common::Never; | ||||
| use super::internal::{FullDataArg, FullDataRet}; | ||||
| use super::{Chunk, Payload}; | ||||
| use upgrade::OnUpgrade; | ||||
| use crate::upgrade::OnUpgrade; | ||||
|  | ||||
| type BodySender = mpsc::Sender<Result<Chunk, ::Error>>; | ||||
| type BodySender = mpsc::Sender<Result<Chunk, crate::Error>>; | ||||
|  | ||||
| /// A stream of `Chunk`s, used when receiving bodies. | ||||
| /// | ||||
| @@ -34,7 +34,7 @@ enum Kind { | ||||
|     Chan { | ||||
|         content_length: Option<u64>, | ||||
|         abort_rx: oneshot::Receiver<()>, | ||||
|         rx: mpsc::Receiver<Result<Chunk, ::Error>>, | ||||
|         rx: mpsc::Receiver<Result<Chunk, crate::Error>>, | ||||
|     }, | ||||
|     H2 { | ||||
|         content_length: Option<u64>, | ||||
| @@ -200,7 +200,7 @@ impl Body { | ||||
|             })) | ||||
|     } | ||||
|  | ||||
|     fn poll_eof(&mut self) -> Poll<Option<Chunk>, ::Error> { | ||||
|     fn poll_eof(&mut self) -> Poll<Option<Chunk>, crate::Error> { | ||||
|         match self.take_delayed_eof() { | ||||
|             Some(DelayEof::NotEof(mut delay)) => { | ||||
|                 match self.poll_inner() { | ||||
| @@ -238,7 +238,7 @@ impl Body { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn poll_inner(&mut self) -> Poll<Option<Chunk>, ::Error> { | ||||
|     fn poll_inner(&mut self) -> Poll<Option<Chunk>, crate::Error> { | ||||
|         match self.kind { | ||||
|             Kind::Once(ref mut val) => Ok(Async::Ready(val.take())), | ||||
|             Kind::Chan { | ||||
| @@ -247,7 +247,7 @@ impl Body { | ||||
|                 ref mut abort_rx, | ||||
|             } => { | ||||
|                 if let Ok(Async::Ready(())) = abort_rx.poll() { | ||||
|                     return Err(::Error::new_body_write("body write aborted")); | ||||
|                     return Err(crate::Error::new_body_write("body write aborted")); | ||||
|                 } | ||||
|  | ||||
|                 match rx.poll().expect("mpsc cannot error") { | ||||
| @@ -267,16 +267,16 @@ impl Body { | ||||
|                 recv: ref mut h2, .. | ||||
|             } => h2 | ||||
|                 .poll() | ||||
|                 .map(|async| { | ||||
|                     async.map(|opt| { | ||||
|                 .map(|r#async| { | ||||
|                     r#async.map(|opt| { | ||||
|                         opt.map(|bytes| { | ||||
|                             let _ = h2.release_capacity().release_capacity(bytes.len()); | ||||
|                             Chunk::from(bytes) | ||||
|                         }) | ||||
|                     }) | ||||
|                 }) | ||||
|                 .map_err(::Error::new_body), | ||||
|             Kind::Wrapped(ref mut s) => s.poll().map_err(::Error::new_body), | ||||
|                 .map_err(crate::Error::new_body), | ||||
|             Kind::Wrapped(ref mut s) => s.poll().map_err(crate::Error::new_body), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -291,7 +291,7 @@ impl Default for Body { | ||||
|  | ||||
| impl Payload for Body { | ||||
|     type Data = Chunk; | ||||
|     type Error = ::Error; | ||||
|     type Error = crate::Error; | ||||
|  | ||||
|     fn poll_data(&mut self) -> Poll<Option<Self::Data>, Self::Error> { | ||||
|         self.poll_eof() | ||||
| @@ -301,7 +301,7 @@ impl Payload for Body { | ||||
|         match self.kind { | ||||
|             Kind::H2 { | ||||
|                 recv: ref mut h2, .. | ||||
|             } => h2.poll_trailers().map_err(::Error::new_h2), | ||||
|             } => h2.poll_trailers().map_err(crate::Error::new_h2), | ||||
|             _ => Ok(Async::Ready(None)), | ||||
|         } | ||||
|     } | ||||
| @@ -336,7 +336,7 @@ impl Payload for Body { | ||||
|  | ||||
| impl ::http_body::Body for Body { | ||||
|     type Data = Chunk; | ||||
|     type Error = ::Error; | ||||
|     type Error = crate::Error; | ||||
|  | ||||
|     fn poll_data(&mut self) -> Poll<Option<Self::Data>, Self::Error> { | ||||
|         <Self as Payload>::poll_data(self) | ||||
| @@ -366,7 +366,7 @@ impl ::http_body::Body for Body { | ||||
|  | ||||
| impl Stream for Body { | ||||
|     type Item = Chunk; | ||||
|     type Error = ::Error; | ||||
|     type Error = crate::Error; | ||||
|  | ||||
|     fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { | ||||
|         self.poll_data() | ||||
| @@ -395,13 +395,13 @@ impl fmt::Debug for Body { | ||||
|  | ||||
| impl Sender { | ||||
|     /// Check to see if this `Sender` can send more data. | ||||
|     pub fn poll_ready(&mut self) -> Poll<(), ::Error> { | ||||
|     pub fn poll_ready(&mut self) -> Poll<(), crate::Error> { | ||||
|         match self.abort_tx.poll_cancel() { | ||||
|             Ok(Async::Ready(())) | Err(_) => return Err(::Error::new_closed()), | ||||
|             Ok(Async::Ready(())) | Err(_) => return Err(crate::Error::new_closed()), | ||||
|             Ok(Async::NotReady) => (), | ||||
|         } | ||||
|  | ||||
|         self.tx.poll_ready().map_err(|_| ::Error::new_closed()) | ||||
|         self.tx.poll_ready().map_err(|_| crate::Error::new_closed()) | ||||
|     } | ||||
|  | ||||
|     /// Sends data on this channel. | ||||
| @@ -422,14 +422,14 @@ impl Sender { | ||||
|         let _ = self.abort_tx.send(()); | ||||
|     } | ||||
|  | ||||
|     pub(crate) fn send_error(&mut self, err: ::Error) { | ||||
|     pub(crate) fn send_error(&mut self, err: crate::Error) { | ||||
|         let _ = self.tx.try_send(Err(err)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Sink for Sender { | ||||
|     type SinkItem = Chunk; | ||||
|     type SinkError = ::Error; | ||||
|     type SinkError = crate::Error; | ||||
|  | ||||
|     fn poll_complete(&mut self) -> Poll<(), Self::SinkError> { | ||||
|         Ok(Async::Ready(())) | ||||
| @@ -438,7 +438,7 @@ impl Sink for Sender { | ||||
|     fn start_send(&mut self, msg: Chunk) -> StartSend<Self::SinkItem, Self::SinkError> { | ||||
|         match self.poll_ready()? { | ||||
|             Async::Ready(_) => { | ||||
|                 self.send_data(msg).map_err(|_| ::Error::new_closed())?; | ||||
|                 self.send_data(msg).map_err(|_| crate::Error::new_closed())?; | ||||
|                 Ok(AsyncSink::Ready) | ||||
|             } | ||||
|             Async::NotReady => Ok(AsyncSink::NotReady(msg)), | ||||
|   | ||||
| @@ -176,7 +176,7 @@ mod tests { | ||||
|         let mut dst = Vec::with_capacity(128); | ||||
|  | ||||
|         b.iter(|| { | ||||
|             let chunk = ::Chunk::from(s); | ||||
|             let chunk = crate::Chunk::from(s); | ||||
|             dst.put(chunk); | ||||
|             ::test::black_box(&dst); | ||||
|             dst.clear(); | ||||
|   | ||||
| @@ -65,7 +65,7 @@ pub trait Payload: Send + 'static { | ||||
|     // The only thing a user *could* do is reference the method, but DON'T | ||||
|     // DO THAT! :) | ||||
|     #[doc(hidden)] | ||||
|     fn __hyper_full_data(&mut self, FullDataArg) -> FullDataRet<Self::Data> { | ||||
|     fn __hyper_full_data(&mut self, _: FullDataArg) -> FullDataRet<Self::Data> { | ||||
|         FullDataRet(None) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user