Struct prettytable::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 get_height(&self) -> usize

👎Deprecated since 0.8.0: Will become private in future release. See issue #87

Return the height of the cell

source

pub fn get_width(&self) -> usize

👎Deprecated since 0.8.0: Will become private in future release. See issue #87

Return the width of the cell

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<T: Write + ?Sized>( &self, out: &mut T, idx: usize, col_width: usize, skip_right_fill: bool, ) -> Result<(), Error>

👎Deprecated since 0.8.0: Will become private in future release. See issue #87

Print a partial cell to out. Since the cell may be multi-lined, idx is the line index to print. col_width is the column width used to fill the cells with blanks so it fits in the table. If ìdx is higher than this cell’s height, it will print empty content

source

pub fn print_term<T: Terminal + ?Sized>( &self, out: &mut T, idx: usize, col_width: usize, skip_right_fill: bool, ) -> Result<(), Error>

👎Deprecated since 0.8.0: Will become private in future release. See issue #87

Apply style then call print to print the cell into a terminal

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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§

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

🔬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,

§

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>,

§

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>,

§

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.