Struct prettytable::Table [−][src]
pub struct Table { /* fields omitted */ }
An owned printable table
Methods
impl Table
[src]
impl Table
pub fn from_csv_string(csv_s: &str) -> Result<Self>
[src]
pub fn from_csv_string(csv_s: &str) -> Result<Self>
Create a table from a CSV string
For more customisability use from_csv()
pub fn from_csv_file<P: AsRef<Path>>(csv_p: P) -> Result<Self>
[src]
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()
pub fn from_csv<R: Read>(reader: &mut Reader<R>) -> Self
[src]
pub fn from_csv<R: Read>(reader: &mut Reader<R>) -> Self
Create a table from a CSV reader
pub fn to_csv<W: Write>(&self, w: W) -> Result<Writer<W>>
[src]
pub fn to_csv<W: Write>(&self, w: W) -> Result<Writer<W>>
Write the table to the specified writer.
pub fn to_csv_writer<W: Write>(&self, writer: Writer<W>) -> Result<Writer<W>>
[src]
pub fn to_csv_writer<W: Write>(&self, writer: Writer<W>) -> Result<Writer<W>>
Write the table to the specified writer.
This allows for format customisation.
impl Table
[src]
impl Table
pub fn new() -> Table
[src]
pub fn new() -> Table
Create an empty table
pub fn init(rows: Vec<Row>) -> Table
[src]
pub fn init(rows: Vec<Row>) -> Table
Create a table initialized with rows
pub fn set_format(&mut self, format: TableFormat)
[src]
pub fn set_format(&mut self, format: TableFormat)
Change the table format. Eg : Separators
pub fn get_format(&mut self) -> &mut TableFormat
[src]
pub fn get_format(&mut self) -> &mut TableFormat
Get a mutable reference to the internal format
pub fn get_column_num(&self) -> usize
[src]
pub fn get_column_num(&self) -> usize
: Will become private in future release. See issue #87
Compute and return the number of column
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Get the number of rows
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Check if the table is empty
pub fn set_titles(&mut self, titles: Row)
[src]
pub fn set_titles(&mut self, titles: Row)
Set the optional title lines
pub fn unset_titles(&mut self)
[src]
pub fn unset_titles(&mut self)
Unset the title line
pub fn get_mut_row(&mut self, row: usize) -> Option<&mut Row>
[src]
pub fn get_mut_row(&mut self, row: usize) -> Option<&mut Row>
Get a mutable reference to a row
pub fn get_row(&self, row: usize) -> Option<&Row>
[src]
pub fn get_row(&self, row: usize) -> Option<&Row>
Get an immutable reference to a row
pub fn add_row(&mut self, row: Row) -> &mut Row
[src]
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
pub fn add_empty_row(&mut self) -> &mut Row
[src]
pub fn add_empty_row(&mut self) -> &mut Row
Append an empty row in the table. Return a mutable reference to this new row.
pub fn insert_row(&mut self, index: usize, row: Row) -> &mut Row
[src]
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
pub fn set_element(
&mut self,
element: &str,
column: usize,
row: usize
) -> Result<(), &str>
[src]
pub fn set_element(
&mut self,
element: &str,
column: usize,
row: usize
) -> Result<(), &str>
Modify a single element in the table
pub fn remove_row(&mut self, index: usize)
[src]
pub fn remove_row(&mut self, index: usize)
Remove the row at position index
. Silently skip if the row does not exist
ⓘImportant traits for ColumnIter<'a>pub fn column_iter(&self, column: usize) -> ColumnIter
[src]
pub fn column_iter(&self, column: usize) -> ColumnIter
Return an iterator over the immutable cells of the column specified by column
ⓘImportant traits for ColumnIterMut<'a>pub fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut
[src]
pub fn column_iter_mut(&mut self, column: usize) -> ColumnIterMut
Return an iterator over the mutable cells of the column specified by column
ⓘImportant traits for Iter<'a, T>pub fn row_iter(&self) -> Iter<Row>
[src]
pub fn row_iter(&self) -> Iter<Row>
Returns an iterator over immutable rows
ⓘImportant traits for IterMut<'a, T>pub fn row_iter_mut(&mut self) -> IterMut<Row>
[src]
pub fn row_iter_mut(&mut self) -> IterMut<Row>
Returns an iterator over mutable rows
pub fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<usize, Error>
[src]
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
pub fn print_term<T: Terminal + ?Sized>(
&self,
out: &mut T
) -> Result<usize, Error>
[src]
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
pub fn print_tty(&self, force_colorize: bool) -> usize
[src]
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
pub fn printstd(&self) -> usize
[src]
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
impl Clone for Table
[src]
impl Clone for Table
fn clone(&self) -> Table
[src]
fn clone(&self) -> Table
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Table
[src]
impl Debug for Table
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Hash for Table
[src]
impl Hash for Table
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Table
[src]
impl PartialEq for Table
fn eq(&self, other: &Table) -> bool
[src]
fn eq(&self, other: &Table) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Table) -> bool
[src]
fn ne(&self, other: &Table) -> bool
This method tests for !=
.
impl Eq for Table
[src]
impl Eq for Table
impl Index<usize> for Table
[src]
impl Index<usize> for Table
type Output = Row
The returned type after indexing.
fn index(&self, idx: usize) -> &Self::Output
[src]
fn index(&self, idx: usize) -> &Self::Output
Performs the indexing (container[index]
) operation.
impl IndexMut<usize> for Table
[src]
impl IndexMut<usize> for Table
fn index_mut(&mut self, idx: usize) -> &mut Self::Output
[src]
fn index_mut(&mut self, idx: usize) -> &mut Self::Output
Performs the mutable indexing (container[index]
) operation.
impl Display for Table
[src]
impl Display for Table
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<B: ToString, A: IntoIterator<Item = B>> FromIterator<A> for Table
[src]
impl<B: ToString, A: IntoIterator<Item = B>> FromIterator<A> for Table
fn from_iter<T>(iterator: T) -> Table where
T: IntoIterator<Item = A>,
[src]
fn from_iter<T>(iterator: T) -> Table where
T: IntoIterator<Item = A>,
Creates a value from an iterator. Read more
impl FromIterator<Row> for Table
[src]
impl FromIterator<Row> for Table
fn from_iter<T>(iterator: T) -> Table where
T: IntoIterator<Item = Row>,
[src]
fn from_iter<T>(iterator: T) -> Table where
T: IntoIterator<Item = Row>,
Creates a value from an iterator. Read more
impl<T, A, B> From<T> for Table where
B: ToString,
A: IntoIterator<Item = B>,
T: IntoIterator<Item = A>,
[src]
impl<T, A, B> From<T> for Table where
B: ToString,
A: IntoIterator<Item = B>,
T: IntoIterator<Item = A>,
impl<'a> IntoIterator for &'a Table
[src]
impl<'a> IntoIterator for &'a Table
type Item = &'a Row
The type of the elements being iterated over.
type IntoIter = Iter<'a, Row>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a> IntoIterator for &'a mut Table
[src]
impl<'a> IntoIterator for &'a mut Table
type Item = &'a mut Row
The type of the elements being iterated over.
type IntoIter = IterMut<'a, Row>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<A: Into<Row>> Extend<A> for Table
[src]
impl<A: Into<Row>> Extend<A> for Table
fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T)
[src]
fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
impl<'a> AsRef<TableSlice<'a>> for Table
[src]
impl<'a> AsRef<TableSlice<'a>> for Table
fn as_ref(&self) -> &TableSlice<'a>
[src]
fn as_ref(&self) -> &TableSlice<'a>
Performs the conversion.