mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Rename DevNull -> NullTty
This commit is contained in:
@@ -121,7 +121,7 @@ impl Cli {
|
||||
Box::new(dev_tty)
|
||||
} else {
|
||||
println!("asciinema: TTY not available, recording in headless mode");
|
||||
Box::new(tty::DevNull::open()?)
|
||||
Box::new(tty::NullTty::open()?)
|
||||
};
|
||||
|
||||
pty::exec(
|
||||
|
||||
@@ -335,7 +335,7 @@ impl Drop for SignalFd {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::pty::ExtraEnv;
|
||||
use crate::tty::DevNull;
|
||||
use crate::tty::NullTty;
|
||||
|
||||
#[derive(Default)]
|
||||
struct TestRecorder {
|
||||
@@ -382,7 +382,7 @@ sys.stdout.write('bar');
|
||||
let result = super::exec(
|
||||
&["python3", "-c", code],
|
||||
&ExtraEnv::new(),
|
||||
Box::new(DevNull::open().unwrap()),
|
||||
Box::new(NullTty::open().unwrap()),
|
||||
(None, None),
|
||||
&mut recorder,
|
||||
);
|
||||
|
||||
12
src/tty.rs
12
src/tty.rs
@@ -65,12 +65,12 @@ impl AsFd for DevTty {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DevNull {
|
||||
pub struct NullTty {
|
||||
tx: i32,
|
||||
_rx: i32,
|
||||
}
|
||||
|
||||
impl DevNull {
|
||||
impl NullTty {
|
||||
pub fn open() -> Result<Self> {
|
||||
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 {
|
||||
pty::Winsize {
|
||||
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> {
|
||||
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> {
|
||||
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<'_> {
|
||||
unsafe { BorrowedFd::borrow_raw(self.tx.as_raw_fd()) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user