multistream-select: Update to 2018 edition. (#766)

This commit is contained in:
Toralf Wittner
2018-12-11 10:45:28 +01:00
committed by GitHub
parent d06eb67353
commit 2253c82b86
9 changed files with 33 additions and 52 deletions

View File

@ -7,6 +7,7 @@ license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
edition = "2018"
[dependencies]
bytes = "0.4"

View File

@ -23,10 +23,11 @@
use bytes::Bytes;
use futures::{future::Either, prelude::*, sink, stream::StreamFuture};
use protocol::{Dialer, DialerFuture, DialerToListenerMessage, ListenerToDialerMessage};
use crate::protocol::{Dialer, DialerFuture, DialerToListenerMessage, ListenerToDialerMessage};
use log::trace;
use std::mem;
use tokio_io::{AsyncRead, AsyncWrite};
use ProtocolChoiceError;
use crate::ProtocolChoiceError;
/// Future, returned by `dialer_select_proto`, which selects a protocol and dialer
/// either sequentially of by considering all protocols in parallel.

View File

@ -20,7 +20,7 @@
//! Main `ProtocolChoiceError` error.
use protocol::MultistreamSelectError;
use crate::protocol::MultistreamSelectError;
use std::error;
use std::fmt;
use std::io::Error as IoError;

View File

@ -237,7 +237,7 @@ fn decode_length_prefix(buf: &[u8]) -> u16 {
#[cfg(test)]
mod tests {
use futures::{Future, Stream};
use length_delimited::LengthDelimited;
use crate::length_delimited::LengthDelimited;
use std::io::Cursor;
use std::io::ErrorKind;

View File

@ -42,12 +42,6 @@
//! For a dialer:
//!
//! ```no_run
//! extern crate bytes;
//! extern crate futures;
//! extern crate multistream_select;
//! extern crate tokio;
//! extern crate tokio_tcp;
//!
//! # fn main() {
//! use bytes::Bytes;
//! use multistream_select::dialer_select_proto;
@ -77,16 +71,6 @@
//! ```
//!
extern crate bytes;
#[macro_use]
extern crate futures;
#[macro_use]
extern crate log;
extern crate smallvec;
extern crate tokio_codec;
extern crate tokio_io;
extern crate unsigned_varint;
mod dialer_select;
mod error;
mod length_delimited;

View File

@ -23,10 +23,11 @@
use bytes::Bytes;
use futures::{prelude::*, sink, stream::StreamFuture};
use protocol::{DialerToListenerMessage, Listener, ListenerFuture, ListenerToDialerMessage};
use crate::protocol::{DialerToListenerMessage, Listener, ListenerFuture, ListenerToDialerMessage};
use log::{debug, trace};
use std::mem;
use tokio_io::{AsyncRead, AsyncWrite};
use ProtocolChoiceError;
use crate::ProtocolChoiceError;
/// Helps selecting a protocol amongst the ones supported.
///

View File

@ -21,12 +21,12 @@
//! Contains the `Dialer` wrapper, which allows raw communications with a listener.
use bytes::Bytes;
use futures::{prelude::*, sink, Async, AsyncSink, StartSend};
use length_delimited::LengthDelimited;
use protocol::DialerToListenerMessage;
use protocol::ListenerToDialerMessage;
use protocol::MultistreamSelectError;
use protocol::MULTISTREAM_PROTOCOL_WITH_LF;
use futures::{prelude::*, sink, Async, AsyncSink, StartSend, try_ready};
use crate::length_delimited::LengthDelimited;
use crate::protocol::DialerToListenerMessage;
use crate::protocol::ListenerToDialerMessage;
use crate::protocol::MultistreamSelectError;
use crate::protocol::MULTISTREAM_PROTOCOL_WITH_LF;
use tokio_io::{AsyncRead, AsyncWrite};
use unsigned_varint::decode;
@ -183,14 +183,12 @@ impl<T: AsyncWrite> Future for DialerFuture<T> {
#[cfg(test)]
mod tests {
extern crate tokio;
extern crate tokio_tcp;
use self::tokio::runtime::current_thread::Runtime;
use self::tokio_tcp::{TcpListener, TcpStream};
use tokio::runtime::current_thread::Runtime;
use tokio_tcp::{TcpListener, TcpStream};
use bytes::Bytes;
use futures::Future;
use futures::{Sink, Stream};
use protocol::{Dialer, DialerToListenerMessage, MultistreamSelectError};
use crate::protocol::{Dialer, DialerToListenerMessage, MultistreamSelectError};
#[test]
fn wrong_proto_name() {

View File

@ -22,11 +22,12 @@
use bytes::Bytes;
use futures::{Async, AsyncSink, prelude::*, sink, stream::StreamFuture};
use length_delimited::LengthDelimited;
use protocol::DialerToListenerMessage;
use protocol::ListenerToDialerMessage;
use protocol::MultistreamSelectError;
use protocol::MULTISTREAM_PROTOCOL_WITH_LF;
use crate::length_delimited::LengthDelimited;
use crate::protocol::DialerToListenerMessage;
use crate::protocol::ListenerToDialerMessage;
use crate::protocol::MultistreamSelectError;
use crate::protocol::MULTISTREAM_PROTOCOL_WITH_LF;
use log::{debug, trace};
use std::mem;
use tokio_io::{AsyncRead, AsyncWrite};
use unsigned_varint::encode;
@ -225,14 +226,12 @@ impl<T: AsyncRead + AsyncWrite> Future for ListenerFuture<T> {
#[cfg(test)]
mod tests {
extern crate tokio;
extern crate tokio_tcp;
use self::tokio::runtime::current_thread::Runtime;
use self::tokio_tcp::{TcpListener, TcpStream};
use tokio::runtime::current_thread::Runtime;
use tokio_tcp::{TcpListener, TcpStream};
use bytes::Bytes;
use futures::Future;
use futures::{Sink, Stream};
use protocol::{Dialer, Listener, ListenerToDialerMessage, MultistreamSelectError};
use crate::protocol::{Dialer, Listener, ListenerToDialerMessage, MultistreamSelectError};
#[test]
fn wrong_proto_name() {

View File

@ -22,18 +22,15 @@
#![cfg(test)]
extern crate tokio;
extern crate tokio_tcp;
use self::tokio::runtime::current_thread::Runtime;
use self::tokio_tcp::{TcpListener, TcpStream};
use tokio::runtime::current_thread::Runtime;
use tokio_tcp::{TcpListener, TcpStream};
use bytes::Bytes;
use dialer_select::{dialer_select_proto_parallel, dialer_select_proto_serial};
use crate::dialer_select::{dialer_select_proto_parallel, dialer_select_proto_serial};
use futures::Future;
use futures::{Sink, Stream};
use protocol::{Dialer, DialerToListenerMessage, Listener, ListenerToDialerMessage};
use ProtocolChoiceError;
use {dialer_select_proto, listener_select_proto};
use crate::protocol::{Dialer, DialerToListenerMessage, Listener, ListenerToDialerMessage};
use crate::ProtocolChoiceError;
use crate::{dialer_select_proto, listener_select_proto};
/// Holds a `Vec` and satifies the iterator requirements of `listener_select_proto`.
struct VecRefIntoIter<T>(Vec<T>);