(writer: W)
| 93 | |
| 94 | impl<W: Write> MemtrackWriter<W> { |
| 95 | pub fn new(writer: W) -> anyhow::Result<Self> { |
| 96 | // We're dealing with a lot of events, so we want to compress as much as possible |
| 97 | // while not taking too much time to compress. |
| 98 | const COMPRESSION_LEVEL: i32 = 1; |
| 99 | const BUFFER_SIZE: usize = 256 * 1024 /* 256 KB */; |
| 100 | |
| 101 | let writer = BufWriter::with_capacity(BUFFER_SIZE, writer); |
| 102 | let encoder = zstd::Encoder::new(writer, COMPRESSION_LEVEL)?; |
| 103 | Ok(Self { |
| 104 | serializer: rmp_serde::Serializer::new(encoder), |
| 105 | }) |
| 106 | } |
| 107 | |
| 108 | /// Write a single event to the stream |
| 109 | pub fn write_event(&mut self, event: &MemtrackEvent) -> anyhow::Result<()> { |
nothing calls this directly
no outgoing calls
no test coverage detected