1
2use crate::write::ext_write::ExtWrite;
3
4use std::io;
5use std::io::Write;
6use std::fmt;
7
8pub type GuardEmptyWrite = EmptyWrite;
9
10#[derive(Debug)]
12pub struct EmptyWrite;
13
14impl EmptyWrite {
15 #[inline]
16 pub const fn new() -> Self {
17 EmptyWrite
18 }
19}
20
21impl From<()> for EmptyWrite {
22 #[inline(always)]
23 fn from(_a: ()) -> Self {
24 Self::new()
25 }
26}
27
28
29impl Write for EmptyWrite {
30 #[inline(always)]
31 fn write<'a>(&mut self, _buf: &'a [u8]) -> io::Result<usize> {
32 Ok( 0 )
33 }
34
35 #[inline(always)]
36 fn flush(&mut self) -> io::Result<()> {
37 Ok( () )
38 }
39
40 #[inline(always)]
41 fn write_all<'a>(&mut self, _buf: &'a [u8]) -> io::Result<()> {
42 Ok( () )
43 }
44
45 #[inline(always)]
46 fn write_fmt(&mut self, _fmt: fmt::Arguments) -> io::Result<()> {
47 Ok( () )
48 }
49}
50
51impl Clone for EmptyWrite {
52 #[inline(always)]
53 fn clone(&self) -> Self {
54 EmptyWrite
55 }
56}
57
58impl<'a> ExtWrite<'a> for EmptyWrite {
59 type LockWrite = GuardEmptyWrite;
60
61 #[inline]
62 fn lock(&self) -> Self::LockWrite {
63 GuardEmptyWrite::new()
64 }
65}
66
67
68impl Into<Box<Write>> for EmptyWrite {
69 #[inline]
70 fn into(self) -> Box<Write> {
71 Box::new(self) as Box<Write>
72 }
73}