Add AsRawFd where possible

This commit is contained in:
Alex Crichton
2016-08-04 12:51:49 -07:00
parent 5f9185ef4c
commit 04bd33e390
2 changed files with 64 additions and 0 deletions
+38
View File
@@ -360,3 +360,41 @@ impl Stream for TcpStream {
self.ready.schedule(task)
}
}
#[cfg(unix)]
mod sys {
use std::os::unix::prelude::*;
use super::{TcpStream, TcpListener};
impl AsRawFd for TcpStream {
fn as_raw_fd(&self) -> RawFd {
self.source.io().as_raw_fd()
}
}
impl AsRawFd for TcpListener {
fn as_raw_fd(&self) -> RawFd {
self.listener.io().as_raw_fd()
}
}
}
#[cfg(windows)]
mod sys {
// TODO: let's land these upstream with mio and then we can add them here.
//
// use std::os::windows::prelude::*;
// use super::{TcpStream, TcpListener};
//
// impl AsRawHandle for TcpStream {
// fn as_raw_handle(&self) -> RawHandle {
// self.source.io().as_raw_handle()
// }
// }
//
// impl AsRawHandle for TcpListener {
// fn as_raw_handle(&self) -> RawHandle {
// self.listener.io().as_raw_handle()
// }
// }
}
+26
View File
@@ -249,3 +249,29 @@ impl Stream for UdpSocket {
self.ready.schedule(task)
}
}
#[cfg(unix)]
mod sys {
use std::os::unix::prelude::*;
use super::UdpSocket;
impl AsRawFd for UdpSocket {
fn as_raw_fd(&self) -> RawFd {
self.source.io().as_raw_fd()
}
}
}
#[cfg(windows)]
mod sys {
// TODO: let's land these upstream with mio and then we can add them here.
//
// use std::os::windows::prelude::*;
// use super::UdpSocket;
//
// impl AsRawHandle for UdpSocket {
// fn as_raw_handle(&self) -> RawHandle {
// self.source.io().as_raw_handle()
// }
// }
}