Skip to main content

RowEncoder

Trait RowEncoder 

Source
pub trait RowEncoder {
    // Required methods
    fn begin(&mut self, columns: &[String]) -> Result<(), Error>;
    fn write_row(&mut self, row: &Row) -> Result<(), Error>;
    fn write_named_row(
        &mut self,
        columns: &[(String, LoraValue)],
    ) -> Result<(), Error>;
    fn finish(&mut self) -> Result<(), Error>;
}
Expand description

Streaming row encoder. Implementors own the underlying writer and may flush at chunk boundaries.

Required Methods§

Source

fn begin(&mut self, columns: &[String]) -> Result<(), Error>

Emit any header bytes the format needs (CSV header row, opening [ for the JSON array). Must be called exactly once before any write_row.

Source

fn write_row(&mut self, row: &Row) -> Result<(), Error>

Write one row. The encoder pulls column names from the row’s Row::iter_named iterator — they must align with the columns passed to Self::begin, in the same order, for CSV.

Source

fn write_named_row( &mut self, columns: &[(String, LoraValue)], ) -> Result<(), Error>

Write the same shape as Self::write_row from a flat (name, value) slice. Used by encoders that consume rows from outside the engine (testing, replay).

Source

fn finish(&mut self) -> Result<(), Error>

Emit any trailer (closing ] for the JSON array) and flush the writer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<W> RowEncoder for CsvEncoder<W>
where W: Write,

Source§

impl<W> RowEncoder for JsonArrayEncoder<W>
where W: Write,

Source§

impl<W> RowEncoder for JsonlEncoder<W>
where W: Write,