pub(crate) struct CsvBuilder {
pub(crate) filtered: bool,
pub(crate) chunk_size: usize,
pub(crate) chunk: Vec<u8>,
pub(crate) rows: CsvRowWriter,
pub(crate) tx: Sender<Vec<u8>>,
}Expand description
Formats an export’s rows into CSV chunks on its CSV thread; see spawn_csv.
Fields§
§filtered: boolWhether the export has a filtered_value column.
chunk_size: usizeBuffer size in bytes at which a chunk is sent.
chunk: Vec<u8>CSV bytes not yet sent; starts with the header line.
rows: CsvRowWriterRow formatter.
tx: Sender<Vec<u8>>Where finished chunks go.
Implementations§
Source§impl CsvBuilder
impl CsvBuilder
Sourcepub(crate) fn new(
filtered: bool,
chunk_size: usize,
tx: Sender<Vec<u8>>,
) -> Self
pub(crate) fn new( filtered: bool, chunk_size: usize, tx: Sender<Vec<u8>>, ) -> Self
Creates a builder and writes the CSV header (with filtered_value when
filtered) into the first chunk.
Sourcepub(crate) fn run(self, items: Receiver<ReadItem>) -> Result<Vec<u8>>
pub(crate) fn run(self, items: Receiver<ReadItem>) -> Result<Vec<u8>>
Writes every row from the reader, sends the last chunk and returns the channels without rows.
Each row’s calibration is applied to its raw value. In a filtered export, a channel without filters gets its calibrated value as its filtered value.
§Errors
Returns the reader’s channel error, prefixed with channel NN:, an error if
the reader stopped early, or an error if the chunk receiver was dropped.
Sourcepub(crate) fn send_chunk(&mut self) -> Result<()>
pub(crate) fn send_chunk(&mut self) -> Result<()>
Sends the current buffer as one chunk, unless it is empty.
§Errors
Returns an error if the receiver was dropped.