Struct prettytable::Table
source · 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
source§impl PartialEq for Table
impl PartialEq for 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)