pub trait Writer {
// Required method
fn write(&self, table: &Table, output: &mut dyn Write) -> Result<()>;
}Expand description
Trait for writing table data to various output formats.
Implement this trait to add support for new output formats.
§Examples
use table_extractor::{Writer, Table, error::Result};
use std::io::Write as IoWrite;
struct CustomWriter;
impl Writer for CustomWriter {
fn write(&self, table: &Table, output: &mut dyn IoWrite) -> Result<()> {
// Write headers
writeln!(output, "{}", table.headers().join(","))?;
// Write rows
for row in table.rows() {
writeln!(output, "{}", row.join(","))?;
}
Ok(())
}
}