Skip to content

Commit d6d6ecb

Browse files
epagerami3l
authored andcommitted
refactor: Remove unused traits
1 parent b1795f1 commit d6d6ecb

File tree

1 file changed

+2
-83
lines changed

1 file changed

+2
-83
lines changed

src/process/filesource.rs

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::io::{self, BufRead, Read, Write};
2-
3-
use super::terminalsource::ColorableTerminal;
4-
use crate::process::Process;
1+
use std::io::{self, BufRead, Read};
52

63
/// Stand-in for std::io::Stdin
74
pub trait Stdin {
@@ -21,75 +18,13 @@ impl Stdin for io::Stdin {
2118
}
2219
}
2320

24-
// -------------- stdout -------------------------------
25-
26-
/// This is a stand-in for [`std::io::StdoutLock`] and [`std::io::StderrLock`].
27-
pub trait WriterLock: Write {}
28-
29-
/// This is a stand-in for [`std::io::Stdout`] or [`std::io::Stderr`].
30-
/// TODO: remove Sync.
31-
pub trait Writer: Write + Send + Sync {
32-
/// This is a stand-in for [`std::io::Stdout::lock`] or [`std::io::Stderr::lock`].
33-
fn lock(&self) -> Box<dyn WriterLock + '_>;
34-
35-
/// Query whether a TTY is present. Used in download_tracker - we may want
36-
/// to remove this entirely with a better progress bar system (in favour of
37-
/// filtering in the Terminal layer?)
38-
fn is_a_tty(&self, process: &Process) -> bool;
39-
40-
/// Construct a terminal on this writer.
41-
fn terminal(&self, process: &Process) -> ColorableTerminal;
42-
}
43-
44-
// ----------------- OS support for writers -----------------
45-
46-
impl WriterLock for io::StdoutLock<'_> {}
47-
48-
impl Writer for io::Stdout {
49-
fn is_a_tty(&self, process: &Process) -> bool {
50-
match process {
51-
crate::process::Process::OsProcess(p) => p.stdout_is_a_tty,
52-
#[cfg(feature = "test")]
53-
crate::process::Process::TestProcess(_) => unreachable!(),
54-
}
55-
}
56-
57-
fn lock(&self) -> Box<dyn WriterLock + '_> {
58-
Box::new(io::Stdout::lock(self))
59-
}
60-
61-
fn terminal(&self, process: &Process) -> ColorableTerminal {
62-
ColorableTerminal::stdout(process)
63-
}
64-
}
65-
66-
impl WriterLock for io::StderrLock<'_> {}
67-
68-
impl Writer for io::Stderr {
69-
fn is_a_tty(&self, process: &Process) -> bool {
70-
match process {
71-
crate::process::Process::OsProcess(p) => p.stderr_is_a_tty,
72-
#[cfg(feature = "test")]
73-
crate::process::Process::TestProcess(_) => unreachable!(),
74-
}
75-
}
76-
77-
fn lock(&self) -> Box<dyn WriterLock + '_> {
78-
Box::new(io::Stderr::lock(self))
79-
}
80-
81-
fn terminal(&self, process: &Process) -> ColorableTerminal {
82-
ColorableTerminal::stderr(process)
83-
}
84-
}
85-
8621
#[cfg(feature = "test")]
8722
pub(crate) use self::test_support::*;
8823

8924
#[cfg(feature = "test")]
9025
mod test_support {
9126
use std::{
92-
io::Cursor,
27+
io::{Cursor, Write},
9328
sync::{Arc, Mutex, MutexGuard},
9429
};
9530

@@ -136,8 +71,6 @@ mod test_support {
13671
inner: MutexGuard<'a, Vec<u8>>,
13772
}
13873

139-
impl WriterLock for TestWriterLock<'_> {}
140-
14174
impl Write for TestWriterLock<'_> {
14275
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
14376
self.inner.write(buf)
@@ -164,20 +97,6 @@ mod test_support {
16497
}
16598
}
16699

167-
impl Writer for TestWriter {
168-
fn is_a_tty(&self, _: &Process) -> bool {
169-
false
170-
}
171-
172-
fn lock(&self) -> Box<dyn WriterLock + '_> {
173-
Box::new(self.lock())
174-
}
175-
176-
fn terminal(&self, process: &Process) -> ColorableTerminal {
177-
ColorableTerminal::test(self.clone(), process)
178-
}
179-
}
180-
181100
impl Write for TestWriter {
182101
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
183102
self.lock().write(buf)

0 commit comments

Comments
 (0)