html_minifier/
html_writer.rs

1use std::io::Write;
2
3use crate::HTMLMinifierError;
4
5/// Implement this trait to build a HTML writer.
6pub trait HTMLWriter {
7    fn push(&mut self, e: u8) -> Result<(), HTMLMinifierError>;
8    fn push_bytes(&mut self, bytes: &[u8]) -> Result<(), HTMLMinifierError>;
9}
10
11impl<W: Write> HTMLWriter for W {
12    #[inline]
13    fn push(&mut self, e: u8) -> Result<(), HTMLMinifierError> {
14        Ok(self.write_all(&[e])?)
15    }
16
17    #[inline]
18    fn push_bytes(&mut self, bytes: &[u8]) -> Result<(), HTMLMinifierError> {
19        Ok(self.write_all(bytes)?)
20    }
21}