csv_zip_maker/
csv_maker.rs

1use std::{fs::File, io::BufWriter, path::PathBuf};
2
3use csv::Writer;
4
5use crate::CsvZipError;
6
7/// This is a csv maker.
8pub struct CsvMaker {
9    pub(crate) writer: Writer<BufWriter<File>>,
10    pub(crate) file_name: String,
11    pub(crate) file_path: PathBuf,
12}
13
14impl CsvMaker {
15    pub fn write<I>(&mut self, line: I) -> Result<(), CsvZipError>
16    where
17        I: IntoIterator,
18        I::Item: AsRef<[u8]>,
19    {
20        self.writer.write_record(line).map_err(|e| e.into())
21    }
22
23    pub(crate) fn flush(&mut self) -> Result<(), CsvZipError> {
24        self.writer.flush().map_err(|e| e.into())
25    }
26}