1
Fork 0

Add RawFd traits for net

This commit is contained in:
Jeremy Soller 2016-12-21 20:19:19 -07:00
parent 92c8e0f352
commit 7d3ae87453
3 changed files with 64 additions and 15 deletions

View file

@ -12,6 +12,7 @@ use io::{Error, ErrorKind, Result};
use net::{SocketAddr, Shutdown};
use path::Path;
use sys::fs::{File, OpenOptions};
use sys_common::{AsInner, FromInner, IntoInner};
use time::Duration;
use vec::Vec;
@ -112,6 +113,20 @@ impl TcpStream {
}
}
impl AsInner<File> for TcpStream {
fn as_inner(&self) -> &File { &self.0 }
}
impl FromInner<File> for TcpStream {
fn from_inner(file: File) -> TcpStream {
TcpStream(file)
}
}
impl IntoInner<File> for TcpStream {
fn into_inner(self) -> File { self.0 }
}
#[derive(Debug)]
pub struct TcpListener(File);
@ -168,3 +183,17 @@ impl TcpListener {
Err(Error::new(ErrorKind::Other, "TcpListener::set_ttl not implemented"))
}
}
impl AsInner<File> for TcpListener {
fn as_inner(&self) -> &File { &self.0 }
}
impl FromInner<File> for TcpListener {
fn from_inner(file: File) -> TcpListener {
TcpListener(file)
}
}
impl IntoInner<File> for TcpListener {
fn into_inner(self) -> File { self.0 }
}