summaryrefslogtreecommitdiff
path: root/src/pty.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-02-21 15:04:39 -0500
committerJesse Luehrs <doy@tozt.net>2022-02-22 13:08:54 -0500
commit22bb1056126cee98dcf747eb48fc5fb5736fe7d7 (patch)
treef208402f7ebddfbc4c33ea952de01b39fe0c141a /src/pty.rs
parentfc3a77b7fcf7da0d198c3c9ab9957c8c889a6fe0 (diff)
downloadnix-22bb1056126cee98dcf747eb48fc5fb5736fe7d7.zip
also implement Read and Write for &PtyMaster
Diffstat (limited to 'src/pty.rs')
-rw-r--r--src/pty.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pty.rs b/src/pty.rs
index ae304d83..bb266a65 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -95,6 +95,21 @@ impl io::Write for PtyMaster {
}
}
+impl io::Read for &PtyMaster {
+ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+ unistd::read(self.0, buf).map_err(io::Error::from)
+ }
+}
+
+impl io::Write for &PtyMaster {
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+ unistd::write(self.0, buf).map_err(io::Error::from)
+ }
+ fn flush(&mut self) -> io::Result<()> {
+ Ok(())
+ }
+}
+
/// Grant access to a slave pseudoterminal (see
/// [`grantpt(3)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/grantpt.html))
///