Struct prettytable::Table [] [src]

pub struct Table {
    // some fields omitted
}

An owned printable table

Methods

impl Table

fn new() -> Table

Create an empty table

fn init(rows: Vec<Row>) -> Table

Create a table initialized with rows

fn set_format(&mut self, format: TableFormat)

Change the table format. Eg : Separators

fn get_column_num(&self) -> usize

Compute and return the number of column

fn len(&self) -> usize

Get the number of rows

fn set_titles(&mut self, titles: Row)

Set the optional title lines

fn unset_titles(&mut self)

Unset the title line

fn get_mut_row(&mut self, row: usize) -> Option<&mut Row>

Get a mutable reference to a row

fn get_row(&self, row: usize) -> Option<&Row>

Get an immutable reference to a row

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

fn add_empty_row(&mut self) -> &mut Row

Append an empty row in the table. Return a mutable reference to this new row.

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

fn set_element(&mut self, element: &str, column: usize, row: usize) -> Result<(), &str>

Modify a single element in the table

fn remove_row(&mut self, index: usize)

Remove the row at position index. Silently skip if the row does not exist

fn column_iter(&self, column: usize) -> ColumnIter

Return an iterator over the immutable cells of the column specified by column

fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut

Return an iterator over the mutable cells of the column specified by column

fn row_iter<'a>(&'a self) -> Iter<'a, Row>

Returns an iterator over immutable rows

fn row_iter_mut<'a>(&'a mut self) -> IterMut<'a, Row>

Returns an iterator over mutable rows

fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<(), Error>

Print the table to out

fn print_term<T: Terminal + ?Sized>(&self, out: &mut T) -> Result<(), Error>

Print the table to terminal out, applying styles when needed

fn print_tty(&self, force_colorize: bool)

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.

Panic

Panic if writing to standard output fails

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. Calling printstd() is equivalent to calling print_tty(false)

Panic

Panic if writing to standard output fails

Trait Implementations

impl Index<usize> for Table

type Output = Row

fn index(&self, idx: usize) -> &Self::Output

impl IndexMut<usize> for Table

fn index_mut(&mut self, idx: usize) -> &mut Self::Output

impl Display for Table

fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>

impl<B: ToString, A: IntoIterator<Item=B>> FromIterator<A> for Table

fn from_iter<T>(iterator: T) -> Table where T: IntoIterator<Item=A>

impl<T, A, B> From<T> for Table where B: ToString, A: IntoIterator<Item=B>, T: IntoIterator<Item=A>

fn from(it: T) -> Table

impl<'a> IntoIterator for &'a Table

type Item = &'a Row

type IntoIter = Iter<'a, Row>

fn into_iter(self) -> Self::IntoIter

impl<'a> IntoIterator for &'a mut Table

type Item = &'a mut Row

type IntoIter = IterMut<'a, Row>

fn into_iter(self) -> Self::IntoIter

impl<'a> AsRef<TableSlice<'a>> for Table

fn as_ref(&self) -> &TableSlice<'a>

Derived Implementations

impl Debug for Table

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Clone for Table

fn clone(&self) -> Table

1.0.0fn clone_from(&mut self, source: &Self)