Format

Trait Format 

Source
pub trait Format {
    // Required method
    fn format(&self, data: &TableView) -> Result<String, FormatError>;
}
Expand description

Unified formatting interface for all output formats

All formatters (table, json, yaml, text, etc.) implement this trait to provide a consistent interface for formatting TableView data.

§Examples

use tree_fmt::{ RowBuilder, TableFormatter, TableConfig, Format };

let view = RowBuilder::new( vec![ "Name".into(), "Age".into() ] )
  .add_row( vec![ "Alice".into(), "30".into() ] )
  .build_view();

let formatter = TableFormatter::with_config( TableConfig::plain() );
let output = Format::format( &formatter, &view ).unwrap();
assert!( output.contains( "Name" ) );

Required Methods§

Source

fn format(&self, data: &TableView) -> Result<String, FormatError>

Format the table view to a string

§Errors

Returns FormatError if formatting fails due to invalid data, serialization errors, or unsupported operations.

Implementors§