pub struct Table { /* private fields */ }
Expand description
An owned printable table
Implementations§
Source§impl Table
impl Table
Sourcepub fn from_csv_string(csv_s: &str) -> Result<Self>
pub fn from_csv_string(csv_s: &str) -> Result<Self>
Create a table from a CSV string
For more customisability use from_csv()
Sourcepub fn from_csv_file<P: AsRef<Path>>(csv_p: P) -> Result<Self>
pub fn from_csv_file<P: AsRef<Path>>(csv_p: P) -> Result<Self>
Create a table from a CSV file
For more customisability use from_csv()
Source§impl Table
impl Table
Sourcepub fn set_format(&mut self, format: TableFormat)
pub fn set_format(&mut self, format: TableFormat)
Change the table format. Eg : Separators
Sourcepub fn get_format(&mut self) -> &mut TableFormat
pub fn get_format(&mut self) -> &mut TableFormat
Get a mutable reference to the internal format
Sourcepub fn get_column_num(&self) -> usize
👎Deprecated since 0.8.0: Will become private in future release. See issue #87
pub fn get_column_num(&self) -> usize
Compute and return the number of column
Sourcepub fn set_titles(&mut self, titles: Row)
pub fn set_titles(&mut self, titles: Row)
Set the optional title lines
Sourcepub fn unset_titles(&mut self)
pub fn unset_titles(&mut self)
Unset the title line
Sourcepub fn get_mut_row(&mut self, row: usize) -> Option<&mut Row>
pub fn get_mut_row(&mut self, row: usize) -> Option<&mut Row>
Get a mutable reference to a row
Sourcepub fn add_row(&mut self, row: Row) -> &mut Row
pub fn add_row(&mut self, row: Row) -> &mut Row
Append a row in the table, transferring ownership of this row to the table and returning a mutable reference to the row
Sourcepub fn add_empty_row(&mut self) -> &mut Row
pub fn add_empty_row(&mut self) -> &mut Row
Append an empty row in the table. Return a mutable reference to this new row.
Sourcepub fn insert_row(&mut self, index: usize, row: Row) -> &mut Row
pub fn insert_row(&mut self, index: usize, row: Row) -> &mut Row
Insert row
at the position index
, and return a mutable reference to this row.
If index is higher than current numbers of rows, row
is appended at the end of the table
Sourcepub fn set_element(
&mut self,
element: &str,
column: usize,
row: usize,
) -> Result<(), &str>
pub fn set_element( &mut self, element: &str, column: usize, row: usize, ) -> Result<(), &str>
Modify a single element in the table
Sourcepub fn remove_row(&mut self, index: usize)
pub fn remove_row(&mut self, index: usize)
Remove the row at position index
. Silently skip if the row does not exist
Sourcepub fn column_iter(&self, column: usize) -> ColumnIter<'_> ⓘ
pub fn column_iter(&self, column: usize) -> ColumnIter<'_> ⓘ
Return an iterator over the immutable cells of the column specified by column
Sourcepub fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut<'_> ⓘ
pub fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut<'_> ⓘ
Return an iterator over the mutable cells of the column specified by column
Sourcepub fn row_iter_mut(&mut self) -> IterMut<'_, Row>
pub fn row_iter_mut(&mut self) -> IterMut<'_, Row>
Returns an iterator over mutable rows
Sourcepub fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<usize, Error>
pub fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<usize, Error>
Print the table to out
and returns the number
of lines printed, or an error
Sourcepub fn print_term<T: Terminal + ?Sized>(
&self,
out: &mut T,
) -> Result<usize, Error>
pub fn print_term<T: Terminal + ?Sized>( &self, out: &mut T, ) -> Result<usize, Error>
Print the table to terminal out
, applying styles when needed and returns the number
of lines printed, or an error
Sourcepub fn print_tty(&self, force_colorize: bool) -> usize
pub fn print_tty(&self, force_colorize: bool) -> usize
Print the table to standard output. Colors won’t be displayed unless
stdout is a tty terminal, or force_colorize
is set to true
.
In ANSI terminals, colors are displayed using ANSI escape characters. When for example the
output is redirected to a file, or piped to another program, the output is considered
as not beeing tty, and ANSI escape characters won’t be displayed unless force colorize
is set to true
.
§Returns
The number of lines printed
§Panic
Panic if writing to standard output fails
Sourcepub fn printstd(&self) -> usize
pub fn printstd(&self) -> usize
Print the table to standard output. Colors won’t be displayed unless
stdout is a tty terminal. This means that if stdout is redirected to a file, or piped
to another program, no color will be displayed.
To force colors rendering, use print_tty()
method.
Calling printstd()
is equivalent to calling print_tty(false)
§Returns
The number of lines printed
§Panic
Panic if writing to standard output fails
Trait Implementations§
Source§impl<A: Into<Row>> Extend<A> for Table
impl<A: Into<Row>> Extend<A> for Table
Source§fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<B: ToString, A: IntoIterator<Item = B>> FromIterator<A> for Table
impl<B: ToString, A: IntoIterator<Item = B>> FromIterator<A> for Table
Source§impl FromIterator<Row> for Table
impl FromIterator<Row> for Table
Source§impl<'a> IntoIterator for &'a Table
impl<'a> IntoIterator for &'a Table
Source§impl<'a> IntoIterator for &'a mut Table
impl<'a> IntoIterator for &'a mut Table
impl Eq for Table
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)