(path: &Path)
| 160 | |
| 161 | impl<R: TelemetryRow> TelemetryWriter<R> { |
| 162 | pub fn create(path: &Path) -> anyhow::Result<Self> { |
| 163 | if let Some(dir) = path.parent() { |
| 164 | std::fs::create_dir_all(dir) |
| 165 | .with_context(|| format!("Failed to create {}", dir.display()))?; |
| 166 | } |
| 167 | let file = |
| 168 | File::create(path).with_context(|| format!("Failed to create {}", path.display()))?; |
| 169 | let encoder = zstd::Encoder::new(BufWriter::new(file), ZSTD_LEVEL)?; |
| 170 | Ok(Self { |
| 171 | serializer: rmp_serde::Serializer::new(BufWriter::new(encoder)), |
| 172 | _rows: PhantomData, |
| 173 | }) |
| 174 | } |
| 175 | |
| 176 | pub fn write(&mut self, rows: impl IntoIterator<Item = R>) -> anyhow::Result<()> { |
| 177 | for row in rows { |
no outgoing calls
no test coverage detected