From e6a3feb286ed68876a7c9fd9162266f741ca1a32 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 23 Feb 2021 01:22:49 -0500 Subject: add async implementations of the pty itself --- src/pty/std.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/pty/std.rs') diff --git a/src/pty/std.rs b/src/pty/std.rs index 84097f9..a68e3fc 100644 --- a/src/pty/std.rs +++ b/src/pty/std.rs @@ -1,6 +1,6 @@ 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, @@ -8,6 +8,8 @@ pub struct Pty { } impl super::Pty for Pty { + type Pt = std::fs::File; + fn new() -> Result { let (pt_fd, ptsname) = super::create_pt()?; @@ -21,7 +23,7 @@ impl super::Pty for Pty { Ok(Self { pt, ptsname }) } - fn pt(&self) -> &std::fs::File { + fn pt(&self) -> &Self::Pt { &self.pt } @@ -33,4 +35,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) + } } -- cgit v1.2.3-54-g00ecf