aboutsummaryrefslogtreecommitdiffstats
path: root/src/pty/tokio.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-02-23 01:22:49 -0500
committerJesse Luehrs <doy@tozt.net>2021-02-23 01:52:03 -0500
commite6a3feb286ed68876a7c9fd9162266f741ca1a32 (patch)
tree5e1dfd36fe147190320cde9e49a1755e8446e543 /src/pty/tokio.rs
parentf3e8046eff473aa9bf940b7fbd156cf3dfbfa352 (diff)
downloadpty-process-e6a3feb286ed68876a7c9fd9162266f741ca1a32.tar.gz
pty-process-e6a3feb286ed68876a7c9fd9162266f741ca1a32.zip
add async implementations of the pty itself
Diffstat (limited to 'src/pty/tokio.rs')
-rw-r--r--src/pty/tokio.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pty/tokio.rs b/src/pty/tokio.rs
index 84097f9..995a154 100644
--- a/src/pty/tokio.rs
+++ b/src/pty/tokio.rs
@@ -1,13 +1,15 @@
use crate::error::*;
-use std::os::unix::io::FromRawFd as _;
+use std::os::unix::io::{AsRawFd as _, FromRawFd as _};
pub struct Pty {
- pt: std::fs::File,
+ pt: tokio::fs::File,
ptsname: std::path::PathBuf,
}
impl super::Pty for Pty {
+ type Pt = tokio::fs::File;
+
fn new() -> Result<Self> {
let (pt_fd, ptsname) = super::create_pt()?;
@@ -18,10 +20,12 @@ impl super::Pty for Pty {
// File object to take full ownership.
let pt = unsafe { std::fs::File::from_raw_fd(pt_fd) };
+ let pt = tokio::fs::File::from_std(pt);
+
Ok(Self { pt, ptsname })
}
- fn pt(&self) -> &std::fs::File {
+ fn pt(&self) -> &Self::Pt {
&self.pt
}
@@ -33,4 +37,9 @@ impl super::Pty for Pty {
.map_err(|e| Error::OpenPts(self.ptsname.clone(), e))?;
Ok(fh)
}
+
+ fn resize(&self, size: &super::Size) -> Result<()> {
+ super::set_term_size(self.pt().as_raw_fd(), size)
+ .map_err(Error::SetTermSize)
+ }
}