Skip to main content

Formatter

Trait Formatter 

Source
pub trait Formatter {
    // Required methods
    fn start(
        &mut self,
        buffer: &mut String,
        top_comments: &IndexMap<FlexStr, FlexStr>,
        tables: &[&FlexStr],
    );
    fn end(&mut self, buffer: &mut String);
    fn start_table(
        &mut self,
        buffer: &mut String,
        name: &FlexStr,
        comment: Option<&FlexStr>,
        columns: &[ColumnInfo],
    );
    fn end_table(&mut self, buffer: &mut String);
    fn start_row(
        &mut self,
        buffer: &mut String,
        name: &FlexStr,
        max_width: usize,
    );
    fn end_row(&mut self, buffer: &mut String);
    fn used_column(
        &mut self,
        buffer: &mut String,
        time: TimeUnit,
        compare: Comparison,
        max_width: usize,
    );
    fn unused_column(&mut self, buffer: &mut String, max_width: usize);
}
Expand description

Implement this “visitor” trait to create a Formatter for a new file type

Required Methods§

Source

fn start( &mut self, buffer: &mut String, top_comments: &IndexMap<FlexStr, FlexStr>, tables: &[&FlexStr], )

Called first at the start of output. Passed top level top_comments and a slice of table names (typically used to build a table of contents)

Source

fn end(&mut self, buffer: &mut String)

Called last after all processing is done

Source

fn start_table( &mut self, buffer: &mut String, name: &FlexStr, comment: Option<&FlexStr>, columns: &[ColumnInfo], )

Called before each table is output with the name of the table, a table comment, if any, and column maximum display width data

Source

fn end_table(&mut self, buffer: &mut String)

Called at the end of each table output

Source

fn start_row(&mut self, buffer: &mut String, name: &FlexStr, max_width: usize)

Called at the start of each new row with the row name and the max_width of the row name column

Source

fn end_row(&mut self, buffer: &mut String)

Called at the end of each row

Source

fn used_column( &mut self, buffer: &mut String, time: TimeUnit, compare: Comparison, max_width: usize, )

Called for each column that is populated with the time measurement, a comparison to baseline, and the maximum display width of the column

Source

fn unused_column(&mut self, buffer: &mut String, max_width: usize)

Called for each column that is blank with the maximum display width of the the column

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§