tari_log4rs/encode/writer/
simple.rs

1//! The simple writer
2//!
3//! Requires the `simple_writer` feature.
4
5use crate::encode;
6use std::{fmt, io};
7
8/// An `encode::Write`r that simply delegates to an `io::Write`r and relies
9/// on the default implementations of `encode::Write`r methods.
10#[derive(Clone, Eq, PartialEq, Hash, Debug)]
11pub struct SimpleWriter<W>(pub W);
12
13impl<W: io::Write> io::Write for SimpleWriter<W> {
14    fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
15        self.0.write(buf)
16    }
17
18    fn flush(&mut self) -> io::Result<()> {
19        self.0.flush()
20    }
21
22    fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
23        self.0.write_all(buf)
24    }
25
26    fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
27        self.0.write_fmt(fmt)
28    }
29}
30
31impl<W: io::Write> encode::Write for SimpleWriter<W> {}