Skip to main content

Table

Struct Table 

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

A grid of cells rendered inside a box. Mirrors rich.table.Table.

Implementations§

Source§

impl Table

Source

pub fn new() -> Self

Source

pub fn box_set(self, box_set: BoxSet) -> Self

Choose the box-drawing set.

Source

pub fn border_style(self, style: Style) -> Self

Style the box border (edges + dividers). Composed over the table-level style: border = style + border_style. Port of Table(border_style=…).

Source

pub fn show_header(self, show: bool) -> Self

Whether to render the header row.

Source

pub fn expand(self, expand: bool) -> Self

Expand the table to fill the available width.

Source

pub fn show_lines(self, show: bool) -> Self

Draw a separator line between each body row.

Source

pub fn show_edge(self, show: bool) -> Self

Draw the outer box edges (top/bottom borders + left/right glyphs). When off, only the internal dividers and content remain. Port of show_edge.

Source

pub fn pad_edge(self, pad: bool) -> Self

Pad the outer cell edges. When off, the first column drops its left pad and the last column its right pad. Port of pad_edge.

Source

pub fn collapse_padding(self, collapse: bool) -> Self

Merge adjacent cell padding: an interior column’s left pad is reduced by the previous column’s right pad. Port of collapse_padding.

Source

pub fn style(self, style: Style) -> Self

Default style for the whole table. Upstream applies it as the base of the border style (border_style = style + border_style); cell content keeps its own styles. Port of Table(style=…).

Source

pub fn title(self, title: impl Into<String>) -> Self

A centered title rendered above the table.

Source

pub fn caption(self, caption: impl Into<String>) -> Self

A centered caption rendered below the table.

Source

pub fn add_column(&mut self, header: impl Into<String>) -> &mut Self

Add a left-justified column with the given header.

Source

pub fn add_column_justify( &mut self, header: impl Into<String>, justify: Justify, ) -> &mut Self

Add a column with an explicit justification.

Source

pub fn column_width(&mut self, width: usize) -> &mut Self

Pin the most-recently-added column to an explicit content width. Content wider than this wraps (with ellipsis overflow) instead of shrinking the column. Chain after add_column.

Source

pub fn column_ratio(&mut self, ratio: usize) -> &mut Self

Give the most-recently-added column a flex ratio: when the table is expanded, ratio columns share the free width in proportion. Chain after add_column. Port of Column.ratio.

Source

pub fn column_min_width(&mut self, min_width: usize) -> &mut Self

Set a minimum content width on the most-recently-added column. Chain after add_column. Port of Column.min_width.

Source

pub fn column_max_width(&mut self, max_width: usize) -> &mut Self

Set a maximum content width on the most-recently-added column — wider cells wrap. Chain after add_column. Port of Column.max_width.

Source

pub fn column_style(&mut self, style: Style) -> &mut Self

Apply a style to the most-recently-added column’s body cells. Chain after add_column.

Source

pub fn column_header_style(&mut self, style: Style) -> &mut Self

Style the most-recently-added column’s header content (the visible characters), leaving its padding as the base header_style. Chain after add_column. Mirrors upstream stylizing the heading Text.

Source

pub fn column_header_fill(&mut self, style: Style) -> &mut Self

Style the most-recently-added column’s whole header cell (content + padding), combined over the table-level header_style. Chain after add_column. Port of Column.header_style.

Source

pub fn column_no_wrap(&mut self) -> &mut Self

Mark the most-recently-added column no_wrap: its cells crop to a single line (with ellipsis) instead of wrapping. Chain after add_column.

Source

pub fn add_row(&mut self, cells: &[&str]) -> &mut Self

Add a row of cells (extra cells are ignored; missing cells render empty).

Trait Implementations§

Source§

impl Default for Table

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl LineRenderable for Table

Source§

fn try_for_each_line<E>( &self, console: &Console, options: &ConsoleOptions, emit: impl FnMut(Vec<Segment>) -> Result<(), E>, ) -> Result<(), E>

Render visual lines in order without retaining the full rendered table.

Like upstream’s Table.__rich_console__ / _render generators, this measures all columns first, then renders only one row block at a time. Lines contain styled segments without a trailing newline. The callback may write each line immediately; its first error stops rendering. The table still owns its source rows for column-width measurement.

Source§

impl OwnedTableRows for Table

Source§

fn extend_owned_rows(&mut self, rows: Vec<Vec<String>>) -> &mut Self

Source§

impl Renderable for Table

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement

The (minimum, maximum) cell width this renderable wants. The default assumes the renderable fills the available width (e.g. Panel, Table); Text overrides it with its content width so the top-level print path can shrink to fit. Port of __rich_measure__ / Measurement.get.

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.