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
impl Cell
sourcepub fn new_align(string: &str, align: Alignment) -> Cell
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
sourcepub fn new(string: &str) -> Cell
pub fn new(string: &str) -> Cell
Create a new Cell
initialized with content from string
.
By default, content is align to LEFT
sourcepub fn with_style(self, attr: Attr) -> Cell
pub fn with_style(self, attr: Attr) -> Cell
Add a style attribute to the cell. Can be chained
sourcepub fn with_hspan(self, hspan: usize) -> Cell
pub fn with_hspan(self, hspan: usize) -> Cell
Add horizontal spanning to the cell
sourcepub fn reset_style(&mut self)
pub fn reset_style(&mut self)
Remove all style attributes and reset alignment to default (LEFT)
sourcepub fn style_spec(self, spec: &str) -> Cell
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 …
sourcepub fn get_height(&self) -> usize
👎Deprecated since 0.8.0: Will become private in future release. See issue #87
pub fn get_height(&self) -> usize
Return the height of the cell
sourcepub fn get_width(&self) -> usize
👎Deprecated since 0.8.0: Will become private in future release. See issue #87
pub fn get_width(&self) -> usize
Return the width of the cell
sourcepub fn get_content(&self) -> String
pub fn get_content(&self) -> String
Return a copy of the full string contained in the cell
sourcepub 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
pub fn print<T: Write + ?Sized>( &self, out: &mut T, idx: usize, col_width: usize, skip_right_fill: bool, ) -> Result<(), Error>
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
Trait Implementations§
source§impl PartialEq for Cell
impl PartialEq for Cell
impl Eq for Cell
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)