pub mod csv;
pub mod jsonl;
pub mod table;
pub mod value;
use std::io::Write;
use arrow_array::RecordBatch;
use arrow_schema::SchemaRef;
use crate::Result;
use crate::cli::{BinaryFormat, Format};
use crate::output::table::TableStyle;
pub trait RowWriter {
fn start(&mut self, schema: &SchemaRef) -> Result<()>;
fn write_batch(&mut self, batch: &RecordBatch) -> Result<()>;
fn finish(&mut self) -> Result<()>;
}
pub fn make_writer<'w, W: Write + 'w>(
format: Format,
binary_format: BinaryFormat,
table_style: TableStyle,
out: W,
) -> Box<dyn RowWriter + 'w> {
match format {
Format::Csv => Box::new(csv::CsvRowWriter::new(out, binary_format)),
Format::Jsonl => Box::new(jsonl::JsonlRowWriter::new(out, binary_format)),
Format::Table => Box::new(table::TableRowWriter::new(out, binary_format, table_style)),
}
}