1pub mod csv;
9pub mod jsonl;
10pub mod table;
11pub mod value;
12
13use std::io::Write;
14
15use arrow_array::RecordBatch;
16use arrow_schema::SchemaRef;
17
18use crate::Result;
19use crate::cli::{BinaryFormat, Format};
20use crate::output::table::TableStyle;
21
22pub trait RowWriter {
23 fn start(&mut self, schema: &SchemaRef) -> Result<()>;
24 fn write_batch(&mut self, batch: &RecordBatch) -> Result<()>;
25 fn finish(&mut self) -> Result<()>;
26}
27
28pub fn make_writer<'w, W: Write + 'w>(
31 format: Format,
32 binary_format: BinaryFormat,
33 table_style: TableStyle,
34 out: W,
35) -> Box<dyn RowWriter + 'w> {
36 match format {
37 Format::Csv => Box::new(csv::CsvRowWriter::new(out, binary_format)),
38 Format::Jsonl => Box::new(jsonl::JsonlRowWriter::new(out, binary_format)),
39 Format::Table => Box::new(table::TableRowWriter::new(out, binary_format, table_style)),
40 }
41}