Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
add TcpStream from SocketAddr
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
  • Loading branch information
yoshuawuyts committed Mar 13, 2019
1 parent 451bd84 commit cf4cf3e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,15 @@ impl std::convert::TryFrom<std::net::TcpStream> for TcpStream {
}
}

impl std::convert::TryFrom<&std::net::SocketAddr> for TcpStream {
type Error = io::Error;

fn try_from(addr: &std::net::SocketAddr) -> Result<Self, Self::Error> {
let tcp = mio::net::TcpStream::connect(&addr)?;
Ok(TcpStream::new(tcp))
}
}

#[cfg(unix)]
mod sys {
use super::TcpStream;
Expand Down

0 comments on commit cf4cf3e

Please sign in to comment.