diff --git a/core/Cargo.toml b/core/Cargo.toml index 2bf1ae35cb1..77fecdc486c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -22,7 +22,7 @@ log = "0.4" multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../misc/multiaddr" } multihash = { package = "parity-multihash", version = "0.1.0", path = "../misc/multihash" } multistream-select = { version = "0.5.0", path = "../misc/multistream-select" } -futures-preview = { version = "= 0.3.0-alpha.18", features = ["compat", "io-compat"] } +futures-preview = { version = "0.3.0-alpha.18", features = ["compat", "io-compat"] } parking_lot = "0.8" protobuf = "2.8" quick-error = "1.2" diff --git a/core/src/either.rs b/core/src/either.rs index b81691a3143..f1b69e41bc6 100644 --- a/core/src/either.rs +++ b/core/src/either.rs @@ -19,7 +19,7 @@ // DEALINGS IN THE SOFTWARE. use crate::{muxing::StreamMuxer, ProtocolName, transport::ListenerEvent}; -use futures::{prelude::*, io::Initializer}; +use futures::prelude::*; use std::{fmt, io::{Error as IoError, Read, Write}, pin::Pin, task::Context, task::Poll}; #[derive(Debug, Copy, Clone)] @@ -67,13 +67,6 @@ where A: AsyncRead + Unpin, B: AsyncRead + Unpin, { - unsafe fn initializer(&self) -> Initializer { - match self { - EitherOutput::First(a) => a.initializer(), - EitherOutput::Second(b) => b.initializer(), - } - } - fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll> { match &mut *self { EitherOutput::First(a) => AsyncRead::poll_read(Pin::new(a), cx, buf), @@ -249,13 +242,6 @@ where } } - unsafe fn initializer(&self) -> Initializer { - match self { - EitherOutput::First(ref inner) => inner.initializer(), - EitherOutput::Second(ref inner) => inner.initializer(), - } - } - fn read_substream(&self, cx: &mut Context, sub: &mut Self::Substream, buf: &mut [u8]) -> Poll> { match (self, sub) { (EitherOutput::First(ref inner), EitherOutput::First(ref mut sub)) => { diff --git a/core/src/muxing.rs b/core/src/muxing.rs index 0ed2068a088..c6a8aa6862c 100644 --- a/core/src/muxing.rs +++ b/core/src/muxing.rs @@ -52,7 +52,7 @@ //! implementation of `StreamMuxer` to control everything that happens on the wire. use fnv::FnvHashMap; -use futures::{future, prelude::*, io::Initializer, task::Context, task::Poll}; +use futures::{future, prelude::*, task::Context, task::Poll}; use parking_lot::Mutex; use std::{io, ops::Deref, fmt, pin::Pin, sync::atomic::{AtomicUsize, Ordering}}; @@ -130,11 +130,6 @@ pub trait StreamMuxer { fn read_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &mut [u8]) -> Poll>; - /// Mimics the `initializer` method of the `AsyncRead` trait. - unsafe fn initializer(&self) -> Initializer { - Initializer::zeroing() - } - /// Write data to a substream. The behaviour is the same as `futures::AsyncWrite::poll_write`. /// /// If `Pending` is returned, then the current task will be notified once the substream @@ -381,10 +376,6 @@ where P: Deref, P::Target: StreamMuxer, { - unsafe fn initializer(&self) -> Initializer { - self.muxer.initializer() - } - fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll> { // We use a `this` because the compiler isn't smart enough to allow mutably borrowing // multiple different fields from the `Pin` at the same time. @@ -511,10 +502,6 @@ impl StreamMuxer for StreamMuxerBox { self.inner.destroy_outbound(substream) } - unsafe fn initializer(&self) -> Initializer { - self.inner.initializer() - } - #[inline] fn read_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &mut [u8]) -> Poll> { self.inner.read_substream(cx, s, buf) @@ -616,10 +603,6 @@ where self.inner.destroy_outbound(list.remove(&substream).unwrap()) } - unsafe fn initializer(&self) -> Initializer { - self.inner.initializer() - } - #[inline] fn read_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &mut [u8]) -> Poll> { let mut list = self.substreams.lock(); diff --git a/core/src/muxing/singleton.rs b/core/src/muxing/singleton.rs index f85e22fd69f..c2b56d0c131 100644 --- a/core/src/muxing/singleton.rs +++ b/core/src/muxing/singleton.rs @@ -19,7 +19,7 @@ // DEALINGS IN THE SOFTWARE. use crate::{Endpoint, muxing::StreamMuxer}; -use futures::{prelude::*, io::Initializer}; +use futures::prelude::*; use parking_lot::Mutex; use std::{io, pin::Pin, sync::atomic::{AtomicBool, Ordering}, task::Context, task::Poll}; @@ -100,10 +100,6 @@ where fn destroy_outbound(&self, _: Self::OutboundSubstream) { } - unsafe fn initializer(&self) -> Initializer { - self.inner.lock().initializer() - } - fn read_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &mut [u8]) -> Poll> { let res = AsyncRead::poll_read(Pin::new(&mut *self.inner.lock()), cx, buf); if let Poll::Ready(Ok(_)) = res { diff --git a/misc/rw-stream-sink/Cargo.toml b/misc/rw-stream-sink/Cargo.toml index a8c2d1008b1..0ed7701bda6 100644 --- a/misc/rw-stream-sink/Cargo.toml +++ b/misc/rw-stream-sink/Cargo.toml @@ -10,4 +10,4 @@ keywords = ["networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures-preview = "= 0.3.0-alpha.18" +futures-preview = "0.3.0-alpha.18" diff --git a/misc/rw-stream-sink/src/lib.rs b/misc/rw-stream-sink/src/lib.rs index f64510410b7..c4e6ec63eab 100644 --- a/misc/rw-stream-sink/src/lib.rs +++ b/misc/rw-stream-sink/src/lib.rs @@ -27,7 +27,7 @@ //! > **Note**: Although this crate is hosted in the libp2p repo, it is purely a utility crate and //! > not at all specific to libp2p. -use futures::{prelude::*, io::Initializer}; +use futures::prelude::*; use std::{cmp, io, pin::Pin, task::Context, task::Poll}; /// Wraps around a `Stream + Sink` whose items are buffers. Implements `AsyncRead` and `AsyncWrite`. @@ -74,10 +74,6 @@ where for _ in 0..to_copy { current_item.remove(0); } Poll::Ready(Ok(to_copy)) } - - unsafe fn initializer(&self) -> Initializer { - Initializer::nop() - } } impl AsyncWrite for RwStreamSink diff --git a/muxers/mplex/src/lib.rs b/muxers/mplex/src/lib.rs index e3a9ff06f6e..0c97cbe2047 100644 --- a/muxers/mplex/src/lib.rs +++ b/muxers/mplex/src/lib.rs @@ -33,7 +33,7 @@ use libp2p_core::{ use log::{debug, trace}; use parking_lot::Mutex; use fnv::FnvHashSet; -use futures::{prelude::*, future, io::Initializer, ready, stream::Fuse}; +use futures::{prelude::*, future, ready, stream::Fuse}; use futures::task::{ArcWake, waker_ref}; use futures_codec::Framed; @@ -470,10 +470,6 @@ where C: AsyncRead + AsyncWrite + Unpin // Nothing to do. } - unsafe fn initializer(&self) -> Initializer { - Initializer::nop() - } - fn read_substream(&self, cx: &mut Context, substream: &mut Self::Substream, buf: &mut [u8]) -> Poll> { loop { // First, transfer from `current_data`. diff --git a/muxers/yamux/src/lib.rs b/muxers/yamux/src/lib.rs index dd062a6daef..c19f12f0176 100644 --- a/muxers/yamux/src/lib.rs +++ b/muxers/yamux/src/lib.rs @@ -80,10 +80,6 @@ where fn destroy_outbound(&self, _: Self::OutboundSubstream) { } - unsafe fn prepare_uninitialized_buffer(&self, _: &mut [u8]) -> bool { - false - } - fn read_substream(&self, sub: &mut Self::Substream, buf: &mut [u8]) -> Poll { let result = sub.poll_read(buf); if let Ok(Async::Ready(_)) = result { diff --git a/protocols/deflate/src/lib.rs b/protocols/deflate/src/lib.rs index 74f33c691a6..0a2719683a4 100644 --- a/protocols/deflate/src/lib.rs +++ b/protocols/deflate/src/lib.rs @@ -135,7 +135,6 @@ impl AsyncRead for DeflateOutput unsafe { this.read_interm.reserve(256); this.read_interm.set_len(this.read_interm.capacity()); - this.inner.initializer().initialize(&mut this.read_interm); } match AsyncRead::poll_read(Pin::new(&mut this.inner), cx, &mut this.read_interm) { @@ -172,10 +171,6 @@ impl AsyncRead for DeflateOutput } } } - - unsafe fn initializer(&self) -> futures::io::Initializer { - futures::io::Initializer::nop() - } } impl AsyncWrite for DeflateOutput diff --git a/protocols/noise/src/io.rs b/protocols/noise/src/io.rs index 03964042c58..c1b6616cb55 100644 --- a/protocols/noise/src/io.rs +++ b/protocols/noise/src/io.rs @@ -252,10 +252,6 @@ impl AsyncRead for NoiseOutput { } } } - - unsafe fn initializer(&self) -> futures::io::Initializer { - futures::io::Initializer::nop() - } } impl AsyncWrite for NoiseOutput { diff --git a/protocols/secio/src/lib.rs b/protocols/secio/src/lib.rs index b9d43204702..9a0a103ab94 100644 --- a/protocols/secio/src/lib.rs +++ b/protocols/secio/src/lib.rs @@ -58,7 +58,7 @@ pub use self::error::SecioError; use futures::stream::MapErr as StreamMapErr; -use futures::{prelude::*, io::Initializer}; +use futures::prelude::*; use libp2p_core::{PeerId, PublicKey, identity, upgrade::{UpgradeInfo, InboundUpgrade, OutboundUpgrade, Negotiated}}; use log::debug; use rw_stream_sink::RwStreamSink; @@ -199,10 +199,6 @@ impl AsyncRead for SecioOutput { { AsyncRead::poll_read(Pin::new(&mut self.stream), cx, buf) } - - unsafe fn initializer(&self) -> Initializer { - self.stream.initializer() - } } impl AsyncWrite for SecioOutput { diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index ea90a5f865a..a9e7740e44d 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -39,7 +39,6 @@ use async_std::net::TcpStream; use futures::{ future::{self, Ready}, - io::Initializer, prelude::*, }; use futures_timer::Delay; @@ -420,10 +419,6 @@ impl AsyncRead for TcpTransStream { fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll> { AsyncRead::poll_read(Pin::new(&mut self.inner), cx, buf) } - - unsafe fn initializer(&self) -> Initializer { - self.inner.initializer() - } } impl AsyncWrite for TcpTransStream { diff --git a/transports/wasm-ext/src/lib.rs b/transports/wasm-ext/src/lib.rs index ffed6e59cc1..64026eef46c 100644 --- a/transports/wasm-ext/src/lib.rs +++ b/transports/wasm-ext/src/lib.rs @@ -32,7 +32,7 @@ //! module. //! -use futures::{prelude::*, future::Ready, io::Initializer}; +use futures::{prelude::*, future::Ready}; use libp2p_core::{transport::ListenerEvent, transport::TransportError, Multiaddr, Transport}; use parity_send_wrapper::SendWrapper; use std::{collections::VecDeque, error, fmt, io, mem, pin::Pin, task::Context, task::Poll}; @@ -356,10 +356,6 @@ impl fmt::Debug for Connection { } impl AsyncRead for Connection { - unsafe fn initializer(&self) -> Initializer { - Initializer::nop() - } - fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll> { loop { match mem::replace(&mut self.read_state, ConnectionReadState::Finished) { diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 30e7c8b589a..517a45bff23 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] bytes = "0.4.12" either = "1.5.3" -futures-preview = "= 0.3.0-alpha.18" +futures-preview = "0.3.0-alpha.18" #futures-rustls = "0.12.0-alpha" # TODO: https://github.com/quininer/tokio-rustls/issues/51 libp2p-core = { version = "0.12.0", path = "../../core" } log = "0.4.8"