pub struct TableBuilder {
    pub cols: Vec<Col>,
    pub rows_sub_name: Option<String>,
}
Expand description

A facility to build templates for tables

You can for example build a table this two ways:

with an explicit string:

static MD: &str = r#"
|-:|:-:|:-:|:-:|:-:|-:|:-:|:-:|:-|:-
|id|dev|filesystem|disk|type|used|use%|free|size|mount point
|-:|:-|:-|:-:|:-:|-:|-:|-:|:-
${rows
|${id}|${dev-major}:${dev-minor}|${filesystem}|${disk}|${type}|~~${used}~~|~~${use-percents}~~ `${bar}`|*${free}*|**${size}**|${mount-point}
}
|-:
"#;

with a table_builder:

 use minimad::{*, Alignment::*};

 let mut tbl = TableBuilder::default();
 tbl
     .col(Col::simple("id").align(Right))
     .col(Col::new("dev", "${dev-major}:${dev-minor}"))
     .col(Col::simple("filesystem"))
     .col(Col::simple("disk").align_content(Center))
     .col(Col::simple("type"))
     .col(Col::new("used", "~~${used}~~"))
     .col(Col::new("use%", "~~${use-percents}~~ `${bar}`").align_content(Right))
     .col(Col::new("free", "*${free}*").align(Right))
     .col(Col::new("size", "**${size}**"))
     .col(Col::simple("mount point").align(Left));

Both ways are mostly equivalent but a table builder makes it easier to dynamically define the columns.

(example taken from lfs)

Fields

cols: Vec<Col>rows_sub_name: Option<String>

an optional name for the sub template for the rows. This is mostly useful when you want to concatenate table templates and you need to distinguish their subs

Implementations

build the string of a template of the table

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.