1 | pub trait IsTerminal { |
2 | fn is_terminal(&self) -> bool; |
3 | } |
4 | |
5 | impl IsTerminal for std::io::Stdout { |
6 | #[inline ] |
7 | fn is_terminal(&self) -> bool { |
8 | std::io::IsTerminal::is_terminal(self) |
9 | } |
10 | } |
11 | |
12 | impl IsTerminal for std::io::StdoutLock<'static> { |
13 | #[inline ] |
14 | fn is_terminal(&self) -> bool { |
15 | std::io::IsTerminal::is_terminal(self) |
16 | } |
17 | } |
18 | |
19 | impl IsTerminal for std::io::Stderr { |
20 | #[inline ] |
21 | fn is_terminal(&self) -> bool { |
22 | std::io::IsTerminal::is_terminal(self) |
23 | } |
24 | } |
25 | |
26 | impl IsTerminal for std::io::StderrLock<'static> { |
27 | #[inline ] |
28 | fn is_terminal(&self) -> bool { |
29 | std::io::IsTerminal::is_terminal(self) |
30 | } |
31 | } |
32 | |
33 | #[cfg (all(windows, feature = "wincon" ))] |
34 | impl IsTerminal for anstyle_wincon::Console<std::io::Stdout> { |
35 | #[inline ] |
36 | fn is_terminal(&self) -> bool { |
37 | self.is_terminal() |
38 | } |
39 | } |
40 | |
41 | #[cfg (all(windows, feature = "wincon" ))] |
42 | impl IsTerminal for anstyle_wincon::Console<std::io::StdoutLock<'static>> { |
43 | #[inline ] |
44 | fn is_terminal(&self) -> bool { |
45 | self.is_terminal() |
46 | } |
47 | } |
48 | |
49 | #[cfg (all(windows, feature = "wincon" ))] |
50 | impl IsTerminal for anstyle_wincon::Console<std::io::Stderr> { |
51 | #[inline ] |
52 | fn is_terminal(&self) -> bool { |
53 | self.is_terminal() |
54 | } |
55 | } |
56 | |
57 | #[cfg (all(windows, feature = "wincon" ))] |
58 | impl IsTerminal for anstyle_wincon::Console<std::io::StderrLock<'static>> { |
59 | #[inline ] |
60 | fn is_terminal(&self) -> bool { |
61 | self.is_terminal() |
62 | } |
63 | } |
64 | |
65 | impl IsTerminal for std::fs::File { |
66 | #[inline ] |
67 | fn is_terminal(&self) -> bool { |
68 | std::io::IsTerminal::is_terminal(self) |
69 | } |
70 | } |
71 | |