pub struct Table { /* private fields */ }Expand description
A simple table builder for rendering tabular CLI output.
§Examples
use blazer::table::Table;
let mut table = Table::new(vec!["Name", "Age", "City"]);
table.add_row(vec!["Alice", "30", "NYC"]);
table.add_row(vec!["Bob", "25", "LA"]);
println!("{}", table.render());Implementations§
Source§impl Table
impl Table
Sourcepub fn with_alignment(self, alignment: Alignment) -> Self
pub fn with_alignment(self, alignment: Alignment) -> Self
Sets the alignment used for all cells.
Sourcepub fn with_borders(self, borders: Borders) -> Self
pub fn with_borders(self, borders: Borders) -> Self
Sets the border characters used for the table.
Sourcepub fn borderless(self) -> Self
pub fn borderless(self) -> Self
Disables all borders.
Sourcepub fn with_padding(self, padding: Padding) -> Self
pub fn with_padding(self, padding: Padding) -> Self
Sets the padding used for all cells.
Sourcepub fn add_row(&mut self, row: Vec<&str>)
pub fn add_row(&mut self, row: Vec<&str>)
Adds a row of data to the table.
Rows with fewer cells than there are headers will have missing cells rendered as empty strings.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Renders the table as a formatted, box-drawn string ready to print.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more