Skip to main content

TableFormatter

Trait TableFormatter 

Source
pub trait TableFormatter<'data> {
    // Required method
    fn fmt<'context>(&'data self, c: &mut Context<'context>) -> Result;

    // Provided methods
    fn table_to_string(&'data self) -> String { ... }
    fn table_to_string_with_format<'context, Styles>(
        &'data self,
        styles: &'context Styles,
    ) -> String
       where Styles: TableOutputFormat { ... }
}
Expand description

Trait for defining table formatting logic.

TableFormatter allows implementations to specify how tables are formatted and displayed, providing flexibility in presentation.

§Type Parameters

  • 'data: The lifetime of the data being formatted.

Required Methods§

Source

fn fmt<'context>(&'data self, c: &mut Context<'context>) -> Result

Formats the table and writes the result to the provided context.

Provided Methods§

Source

fn table_to_string(&'data self) -> String

Converts the table to a string representation.

§Returns

A String containing the formatted table.

Source

fn table_to_string_with_format<'context, Styles>( &'data self, styles: &'context Styles, ) -> String
where Styles: TableOutputFormat,

Converts the table to a string representation specifying printer.

§Returns

A String containing the formatted table.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<'data, T, RowKey, Row, CellKey> TableFormatter<'data> for AsTable<'data, T, RowKey, Row, CellKey>
where Self: TableRows<CellKey = CellKey, RowKey = RowKey, Row = Row> + TableHeader<CellKey = CellKey>, RowKey: RowKey, Row: Cells<CellKey>, CellKey: CellKey + ?Sized,

A trait for formatting tables.