mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-06 08:02:18 +00:00
Replace Dial with concrete type
This commit is contained in:
parent
64a62ff513
commit
c84a14ea49
@ -7,7 +7,7 @@ extern crate futures;
|
|||||||
use std::io::Error as IoError;
|
use std::io::Error as IoError;
|
||||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||||
use tokio_core::reactor::Core;
|
use tokio_core::reactor::Core;
|
||||||
use tokio_core::net::{TcpStream, TcpListener};
|
use tokio_core::net::{TcpStream, TcpListener, TcpStreamNew};
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use futures::stream::Stream;
|
use futures::stream::Stream;
|
||||||
use multiaddr::{Multiaddr, Protocol};
|
use multiaddr::{Multiaddr, Protocol};
|
||||||
@ -26,14 +26,14 @@ impl Tcp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Transport for Tcp {
|
impl Transport for Tcp {
|
||||||
/// The raw connection.
|
/// The raw connection.
|
||||||
type RawConn = TcpStream;
|
type RawConn = TcpStream;
|
||||||
|
|
||||||
/// The listener produces incoming connections.
|
/// The listener produces incoming connections.
|
||||||
type Listener = Box<Stream<Item=Self::RawConn, Error=IoError>>;
|
type Listener = Box<Stream<Item=Self::RawConn, Error=IoError>>;
|
||||||
|
|
||||||
/// A future which indicates currently dialing to a peer.
|
/// A future which indicates currently dialing to a peer.
|
||||||
type Dial = Box<Future<Item=Self::RawConn, Error=IoError>>;
|
type Dial = TcpStreamNew;
|
||||||
|
|
||||||
/// Listen on the given multi-addr.
|
/// Listen on the given multi-addr.
|
||||||
/// Returns the address back if it isn't supported.
|
/// Returns the address back if it isn't supported.
|
||||||
@ -53,7 +53,7 @@ impl Transport for Tcp {
|
|||||||
/// or gives back the multiaddress.
|
/// or gives back the multiaddress.
|
||||||
fn dial(&mut self, addr: Multiaddr) -> Result<Self::Dial, Multiaddr> {
|
fn dial(&mut self, addr: Multiaddr) -> Result<Self::Dial, Multiaddr> {
|
||||||
if let Ok(socket_addr) = multiaddr_to_socketaddr(&addr) {
|
if let Ok(socket_addr) = multiaddr_to_socketaddr(&addr) {
|
||||||
Ok(Box::new(TcpStream::connect(&socket_addr, &self.event_loop.handle())))
|
Ok(TcpStream::connect(&socket_addr, &self.event_loop.handle()))
|
||||||
} else {
|
} else {
|
||||||
Err(addr)
|
Err(addr)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user