use std::io;
use crate::com::{send::{sendc, sendstr}, };
impl io::Write for crate::Console {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
let string = match String::from_utf8(buf.to_vec()) {
Ok(v) => v,
Err(_) => return Err(io::Error::from(io::ErrorKind::InvalidInput))
};
let written = self.print(string)?;
Ok(written)
}
fn flush(&mut self) -> io::Result<()> {
unsafe { sendc(self.pipe, 1)?; }
unsafe { sendstr(self.pipe, String::new())? };
Ok(())
}
}