use crate::shared::error::Fail;
pub trait TextOut {
fn write_str(&mut self, s: &str) -> Result<(), Fail>;
fn flush(&mut self) -> Result<(), Fail>;
fn has_committed(&self) -> bool {
true
}
fn record_end(&mut self) -> Result<(), Fail> {
Ok(())
}
}
impl<O: TextOut + ?Sized> TextOut for &mut O {
fn write_str(&mut self, s: &str) -> Result<(), Fail> {
(**self).write_str(s)
}
fn flush(&mut self) -> Result<(), Fail> {
(**self).flush()
}
fn has_committed(&self) -> bool {
(**self).has_committed()
}
fn record_end(&mut self) -> Result<(), Fail> {
(**self).record_end()
}
}
impl<O: TextOut + ?Sized> TextOut for Box<O> {
fn write_str(&mut self, s: &str) -> Result<(), Fail> {
(**self).write_str(s)
}
fn flush(&mut self) -> Result<(), Fail> {
(**self).flush()
}
fn has_committed(&self) -> bool {
(**self).has_committed()
}
fn record_end(&mut self) -> Result<(), Fail> {
(**self).record_end()
}
}
pub trait JoinOut: TextOut {
fn item_start(&mut self) -> Result<(), Fail>;
fn item_end(&mut self) -> Result<(), Fail>;
}