prettytable

Struct Cell

Source
pub struct Cell { /* private fields */ }
Expand description

Represent a table cell containing a string.

Once created, a cell’s content cannot be modified. The cell would have to be replaced by another one

Implementations§

Source§

impl Cell

Source

pub fn new_align(string: &str, align: Alignment) -> Cell

Create a new Cell initialized with content from string. Text alignment in cell is configurable with the align argument

Source

pub fn new(string: &str) -> Cell

Create a new Cell initialized with content from string. By default, content is align to LEFT

Source

pub fn align(&mut self, align: Alignment)

Set text alignment in the cell

Source

pub fn style(&mut self, attr: Attr)

Add a style attribute to the cell

Source

pub fn with_style(self, attr: Attr) -> Cell

Add a style attribute to the cell. Can be chained

Source

pub fn with_hspan(self, hspan: usize) -> Cell

Add horizontal spanning to the cell

Source

pub fn reset_style(&mut self)

Remove all style attributes and reset alignment to default (LEFT)

Source

pub fn style_spec(self, spec: &str) -> Cell

Set the cell’s style by applying the given specifier string

§Style spec syntax

The syntax for the style specifier looks like this : FrBybl which means Foreground red Background yellow bold left

§List of supported specifiers :
  • F : Foreground (must be followed by a color specifier)
  • B : Background (must be followed by a color specifier)
  • H : Horizontal span (must be followed by a number)
  • b : bold
  • i : italic
  • u : underline
  • c : Align center
  • l : Align left
  • r : Align right
  • d : default style
§List of color specifiers :
  • r : Red
  • b : Blue
  • g : Green
  • y : Yellow
  • c : Cyan
  • m : Magenta
  • w : White
  • d : Black

And capital letters are for bright colors. Eg :

  • R : Bright Red
  • B : Bright Blue
  • … and so on …
Source

pub fn set_hspan(&mut self, hspan: usize)

Set horizontal span for this cell (must be > 0)

Source

pub fn get_hspan(&self) -> usize

Get horizontal span of this cell (> 0)

Source

pub fn get_content(&self) -> String

Return a copy of the full string contained in the cell

Source

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

Print the cell in HTML format to out.

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Cell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cell

Source§

fn default() -> Cell

Return a cell initialized with a single empty String, with LEFT alignment

Source§

impl<'a, T: ToString> From<&'a T> for Cell

Source§

fn from(f: &T) -> Cell

Converts to this type from the input type.
Source§

impl Hash for Cell

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Cell

Source§

fn eq(&self, other: &Cell) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for Cell

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl Eq for Cell

Source§

impl StructuralPartialEq for Cell

Auto Trait Implementations§

§

impl Freeze for Cell

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnwindSafe for Cell

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.