Skip to content

Commit

Permalink
Merge pull request #8 from andfoy/performance_improvements
Browse files Browse the repository at this point in the history
PR: Improve read performance and rewrite iseof
  • Loading branch information
andfoy authored Jan 19, 2022
2 parents e9886c1 + 3f9bc28 commit d9cb207
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 96 deletions.
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ignore:
- build.rs
- examples/*.rs
- src/lib.rs
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ extern crate enum_primitive_derive;
extern crate num_traits;

pub mod pty;
// mod pty_spawn;
pub use pty::{PTY, PTYArgs, PTYBackend, MouseMode, AgentConfig};
10 changes: 8 additions & 2 deletions src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub struct PTYArgs {
/// use winptyrs::{PTY, PTYArgs, MouseMode, AgentConfig, PTYBackend};
///
/// let cmd = OsString::from("c:\\windows\\system32\\cmd.exe");
///
/// let pty_args = PTYArgs {
/// cols: 80,
/// rows: 25,
Expand All @@ -114,8 +115,8 @@ pub struct PTYArgs {
/// };
///
/// // Initialize a winpty and a conpty pseudoterminal.
/// let winpty = PTY::new_with_backend(&pty_args, PTYBackend::WinPTY).unwrap();
/// let conpty = PTY::new_with_backend(&pty_args, PTYBackend::ConPTY).unwrap();
/// let winpty = PTY::new_with_backend(&pty_args, PTYBackend::WinPTY).unwrap();
/// ```
pub struct PTY {
/// Backend used by the current pseudoterminal, must be one of [`self::PTYBackend`].
Expand Down Expand Up @@ -242,7 +243,7 @@ impl PTY {
///
/// * The bytes returned are represented using a [`OsString`] since Windows operates over
/// `u16` strings.
pub fn read(&self, length: u32, blocking: bool) -> Result<OsString, OsString> {
pub fn read(&mut self, length: u32, blocking: bool) -> Result<OsString, OsString> {
self.pty.read(length, blocking)
}

Expand Down Expand Up @@ -284,4 +285,9 @@ impl PTY {
pub fn get_pid(&self) -> u32 {
self.pty.get_pid()
}

/// Retrieve the process handle ID of the spawned program.
pub fn get_fd(&self) -> isize {
self.pty.get_fd()
}
}
Loading

0 comments on commit d9cb207

Please sign in to comment.