use crossterm::tty::IsTty;
use std::io::Write;
pub trait OutputSink: Write + Send + Sync + 'static {
fn is_tty(&self) -> bool {
false
}
}
impl OutputSink for std::io::Stdout {
fn is_tty(&self) -> bool {
IsTty::is_tty(self)
}
}
impl OutputSink for std::io::Stderr {
fn is_tty(&self) -> bool {
IsTty::is_tty(self)
}
}
impl OutputSink for std::fs::File {
fn is_tty(&self) -> bool {
IsTty::is_tty(self)
}
}
impl OutputSink for Vec<u8> {
fn is_tty(&self) -> bool {
false
}
}
impl<T: AsRef<[u8]> + Send + Sync + 'static> OutputSink for std::io::Cursor<T>
where
Self: Write,
{
fn is_tty(&self) -> bool {
false
}
}
impl OutputSink for std::io::Sink {
fn is_tty(&self) -> bool {
false
}
}
impl<T: OutputSink + ?Sized> OutputSink for Box<T> {
fn is_tty(&self) -> bool {
(**self).is_tty()
}
}