io: impl as RawFd / AsRawHandle for stdio (#2335)

Fixes: #2311
This commit is contained in:
MarinPostma 2020-03-23 06:25:49 +01:00 committed by GitHub
parent dd27f1a259
commit 2258de5147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -72,6 +72,20 @@ cfg_io_std! {
}
}
#[cfg(unix)]
impl std::os::unix::io::AsRawFd for Stderr {
fn as_raw_fd(&self) -> std::os::unix::io::RawFd {
std::io::stderr().as_raw_fd()
}
}
#[cfg(windows)]
impl std::os::windows::io::AsRawHandle for Stderr {
fn as_raw_handle(&self) -> std::os::windows::io::RawHandle {
std::io::stderr().as_raw_handle()
}
}
impl AsyncWrite for Stderr {
fn poll_write(
mut self: Pin<&mut Self>,

View File

@ -45,6 +45,20 @@ cfg_io_std! {
}
}
#[cfg(unix)]
impl std::os::unix::io::AsRawFd for Stdin {
fn as_raw_fd(&self) -> std::os::unix::io::RawFd {
std::io::stdin().as_raw_fd()
}
}
#[cfg(windows)]
impl std::os::windows::io::AsRawHandle for Stdin {
fn as_raw_handle(&self) -> std::os::windows::io::RawHandle {
std::io::stdin().as_raw_handle()
}
}
impl AsyncRead for Stdin {
fn poll_read(
mut self: Pin<&mut Self>,

View File

@ -72,6 +72,20 @@ cfg_io_std! {
}
}
#[cfg(unix)]
impl std::os::unix::io::AsRawFd for Stdout {
fn as_raw_fd(&self) -> std::os::unix::io::RawFd {
std::io::stdout().as_raw_fd()
}
}
#[cfg(windows)]
impl std::os::windows::io::AsRawHandle for Stdout {
fn as_raw_handle(&self) -> std::os::windows::io::RawHandle {
std::io::stdout().as_raw_handle()
}
}
impl AsyncWrite for Stdout {
fn poll_write(
mut self: Pin<&mut Self>,