adder_codec_core/codec/empty/
stream.rs

1// #[cfg(feature = "compression")]
2// use crate::codec::compressed::adu::frame::Adu;
3use crate::codec::header::{Magic, MAGIC_RAW};
4use crate::codec::{CodecError, CodecMetadata, WriteCompression};
5use crate::Event;
6use std::io::{Sink, Write};
7
8/// Filler for when generated ADΔER events need not be captured
9pub struct EmptyOutput<W: Write> {
10    pub(crate) meta: CodecMetadata,
11    _phantom: std::marker::PhantomData<W>,
12}
13
14impl<W: Write> EmptyOutput<W> {
15    /// Create a new empty output stream.
16    pub fn new(meta: CodecMetadata, _writer: W) -> Self {
17        Self {
18            meta,
19            _phantom: std::marker::PhantomData,
20        }
21    }
22}
23
24impl<W: std::io::Write + std::marker::Send + std::marker::Sync + 'static> WriteCompression<W>
25    for EmptyOutput<Sink>
26{
27    fn magic(&self) -> Magic {
28        MAGIC_RAW
29    }
30
31    fn meta(&self) -> &CodecMetadata {
32        &self.meta
33    }
34
35    fn meta_mut(&mut self) -> &mut CodecMetadata {
36        &mut self.meta
37    }
38
39    fn write_bytes(&mut self, _bytes: &[u8]) -> Result<(), std::io::Error> {
40        Ok(())
41    }
42
43    fn byte_align(&mut self) -> std::io::Result<()> {
44        Ok(())
45    }
46
47    fn into_writer(&mut self) -> Option<W> {
48        None
49    }
50
51    fn flush_writer(&mut self) -> std::io::Result<()> {
52        Ok(())
53    }
54
55    fn ingest_event(&mut self, _event: Event) -> Result<(), CodecError> {
56        Ok(())
57    }
58
59    // #[cfg(feature = "compression")]
60    // fn ingest_event_debug(&mut self, event: Event) -> Result<Option<Adu>, CodecError> {
61    //     todo!()
62    // }
63}