diff options
author | MarinPostma <postma.marin@protonmail.com> | 2020-03-23 06:25:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 22:25:49 -0700 |
commit | 2258de51477cb36d5b69becd6058b94e4a8fc641 (patch) | |
tree | cc4b84c62e1a52c5175e0bd26a3b43ea36f0adc5 /tokio/src/io | |
parent | dd27f1a259033cc6328ccad1f73f753e52976a65 (diff) |
io: impl as `RawFd` / `AsRawHandle` for stdio (#2335)
Fixes: #2311
Diffstat (limited to 'tokio/src/io')
-rw-r--r-- | tokio/src/io/stderr.rs | 14 | ||||
-rw-r--r-- | tokio/src/io/stdin.rs | 14 | ||||
-rw-r--r-- | tokio/src/io/stdout.rs | 14 |
3 files changed, 42 insertions, 0 deletions
diff --git a/tokio/src/io/stderr.rs b/tokio/src/io/stderr.rs index fa5d0fbd..99607dc6 100644 --- a/tokio/src/io/stderr.rs +++ b/tokio/src/io/stderr.rs @@ -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>, diff --git a/tokio/src/io/stdin.rs b/tokio/src/io/stdin.rs index 6c937447..634bd484 100644 --- a/tokio/src/io/stdin.rs +++ b/tokio/src/io/stdin.rs @@ -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>, diff --git a/tokio/src/io/stdout.rs b/tokio/src/io/stdout.rs index ff1bfd5d..5377993a 100644 --- a/tokio/src/io/stdout.rs +++ b/tokio/src/io/stdout.rs @@ -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>, |