aboutsummaryrefslogtreecommitdiffstats
path: root/src/pty.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.rs
parentf3e8046eff473aa9bf940b7fbd156cf3dfbfa352 (diff)
downloadpty-process-e6a3feb286ed68876a7c9fd9162266f741ca1a32.tar.gz
pty-process-e6a3feb286ed68876a7c9fd9162266f741ca1a32.zip
add async implementations of the pty itself
Diffstat (limited to 'src/pty.rs')
-rw-r--r--src/pty.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pty.rs b/src/pty.rs
index f192298..b017225 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -1,6 +1,6 @@
use crate::error::*;
-use ::std::os::unix::io::{AsRawFd as _, IntoRawFd as _};
+use ::std::os::unix::io::IntoRawFd as _;
pub mod std;
@@ -10,14 +10,14 @@ pub mod async_io;
pub mod tokio;
pub trait Pty {
+ type Pt;
+
fn new() -> Result<Self>
where
Self: Sized;
- fn pt(&self) -> &::std::fs::File;
+ fn pt(&self) -> &Self::Pt;
fn pts(&self) -> Result<::std::fs::File>;
- fn resize(&self, size: &super::Size) -> Result<()> {
- set_term_size(self.pt(), size).map_err(Error::SetTermSize)
- }
+ fn resize(&self, size: &super::Size) -> Result<()>;
}
pub struct Size {
@@ -84,9 +84,11 @@ nix::ioctl_write_ptr_bad!(
nix::pty::Winsize
);
-fn set_term_size(file: &::std::fs::File, size: &Size) -> nix::Result<()> {
+fn set_term_size(
+ fd: ::std::os::unix::io::RawFd,
+ size: &Size,
+) -> nix::Result<()> {
let size = size.into();
- let fd = file.as_raw_fd();
// safe because std::fs::File is required to contain a valid file
// descriptor and size is guaranteed to be initialized because it's a
// normal rust value, and nix::pty::Winsize is a repr(C) struct with the