Rename DevNull -> NullTty

This commit is contained in:
Marcin Kulik
2024-01-08 10:12:47 +01:00
parent 826935fb36
commit 7edad07838
3 changed files with 9 additions and 9 deletions

View File

@@ -121,7 +121,7 @@ impl Cli {
Box::new(dev_tty) Box::new(dev_tty)
} else { } else {
println!("asciinema: TTY not available, recording in headless mode"); println!("asciinema: TTY not available, recording in headless mode");
Box::new(tty::DevNull::open()?) Box::new(tty::NullTty::open()?)
}; };
pty::exec( pty::exec(

View File

@@ -335,7 +335,7 @@ impl Drop for SignalFd {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::pty::ExtraEnv; use crate::pty::ExtraEnv;
use crate::tty::DevNull; use crate::tty::NullTty;
#[derive(Default)] #[derive(Default)]
struct TestRecorder { struct TestRecorder {
@@ -382,7 +382,7 @@ sys.stdout.write('bar');
let result = super::exec( let result = super::exec(
&["python3", "-c", code], &["python3", "-c", code],
&ExtraEnv::new(), &ExtraEnv::new(),
Box::new(DevNull::open().unwrap()), Box::new(NullTty::open().unwrap()),
(None, None), (None, None),
&mut recorder, &mut recorder,
); );

View File

@@ -65,12 +65,12 @@ impl AsFd for DevTty {
} }
} }
pub struct DevNull { pub struct NullTty {
tx: i32, tx: i32,
_rx: i32, _rx: i32,
} }
impl DevNull { impl NullTty {
pub fn open() -> Result<Self> { pub fn open() -> Result<Self> {
let (rx, tx) = unistd::pipe()?; let (rx, tx) = unistd::pipe()?;
@@ -78,7 +78,7 @@ impl DevNull {
} }
} }
impl Tty for DevNull { impl Tty for NullTty {
fn get_size(&self) -> pty::Winsize { fn get_size(&self) -> pty::Winsize {
pty::Winsize { pty::Winsize {
ws_row: 24, ws_row: 24,
@@ -89,13 +89,13 @@ impl Tty for DevNull {
} }
} }
impl io::Read for DevNull { impl io::Read for NullTty {
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
panic!("read attempt from DevNull impl of Tty"); panic!("read attempt from DevNull impl of Tty");
} }
} }
impl io::Write for DevNull { impl io::Write for NullTty {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
Ok(buf.len()) Ok(buf.len())
} }
@@ -105,7 +105,7 @@ impl io::Write for DevNull {
} }
} }
impl AsFd for DevNull { impl AsFd for NullTty {
fn as_fd(&self) -> BorrowedFd<'_> { fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.tx.as_raw_fd()) } unsafe { BorrowedFd::borrow_raw(self.tx.as_raw_fd()) }
} }