Struct prettytable::Table
source · [−]pub struct Table { /* private fields */ }
Expand description
An owned printable table
Implementations
sourceimpl 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()
sourceimpl 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 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<'_>ⓘNotable traits for ColumnIter<'a>impl<'a> Iterator for ColumnIter<'a> type Item = &'a Cell;
pub fn column_iter(&self, column: usize) -> ColumnIter<'_>ⓘNotable traits for ColumnIter<'a>impl<'a> Iterator for ColumnIter<'a> type Item = &'a Cell;
Return an iterator over the immutable cells of the column specified by column
sourcepub fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut<'_>ⓘNotable traits for ColumnIterMut<'a>impl<'a> Iterator for ColumnIterMut<'a> type Item = &'a mut Cell;
pub fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut<'_>ⓘNotable traits for ColumnIterMut<'a>impl<'a> Iterator for ColumnIterMut<'a> type Item = &'a mut Cell;
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) -> Result<usize, Error>
pub fn print_tty(&self, force_colorize: bool) -> Result<usize, Error>
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
A Result
holding the number of lines printed, or an io::Error
if any failure happens
sourcepub fn printstd(&self)
pub fn printstd(&self)
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.
Any failure to print is ignored. For better control, use print_tty()
.
Calling printstd()
is equivalent to calling print_tty(false)
and ignoring the result.
Trait Implementations
sourceimpl<'a> AsRef<TableSlice<'a>> for Table
impl<'a> AsRef<TableSlice<'a>> for Table
sourcefn as_ref(&self) -> &TableSlice<'a>
fn as_ref(&self) -> &TableSlice<'a>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<A: Into<Row>> Extend<A> for Table
impl<A: Into<Row>> Extend<A> for Table
sourcefn extend<T: IntoIterator<Item = A>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T, A, B> From<T> for Table where
B: ToString,
A: IntoIterator<Item = B>,
T: IntoIterator<Item = A>,
impl<T, A, B> From<T> for Table where
B: ToString,
A: IntoIterator<Item = B>,
T: IntoIterator<Item = A>,
sourceimpl<B: ToString, A: IntoIterator<Item = B>> FromIterator<A> for Table
impl<B: ToString, A: IntoIterator<Item = B>> FromIterator<A> for Table
sourcefn from_iter<T>(iterator: T) -> Table where
T: IntoIterator<Item = A>,
fn from_iter<T>(iterator: T) -> Table where
T: IntoIterator<Item = A>,
Creates a value from an iterator. Read more
sourceimpl FromIterator<Row> for Table
impl FromIterator<Row> for Table
sourceimpl<'a> IntoIterator for &'a Table
impl<'a> IntoIterator for &'a Table
sourceimpl<'a> IntoIterator for &'a mut Table
impl<'a> IntoIterator for &'a mut Table
impl Eq for Table
impl StructuralEq for Table
impl StructuralPartialEq for Table
Auto Trait Implementations
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnwindSafe for Table
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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