Struct minimad::TableBuilder
source · [−]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
sourceimpl TableBuilder
impl TableBuilder
Trait Implementations
sourceimpl Clone for TableBuilder
impl Clone for TableBuilder
sourcefn clone(&self) -> TableBuilder
fn clone(&self) -> TableBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for TableBuilder
impl Debug for TableBuilder
sourceimpl Default for TableBuilder
impl Default for TableBuilder
sourcefn default() -> TableBuilder
fn default() -> TableBuilder
Returns the “default value” for a type. Read more
sourceimpl From<&TableBuilder> for String
impl From<&TableBuilder> for String
sourcefn from(tblbl: &TableBuilder) -> String
fn from(tblbl: &TableBuilder) -> String
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for TableBuilder
impl Send for TableBuilder
impl Sync for TableBuilder
impl Unpin for TableBuilder
impl UnwindSafe for TableBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more