pub struct Table {Show 23 fields
pub title: Option<String>,
pub caption: Option<String>,
pub box_style: BoxStyle,
pub show_header: bool,
pub show_footer: bool,
pub show_edge: bool,
pub show_lines: bool,
pub padding: (usize, usize, usize, usize),
pub collapse_padding: bool,
pub style: Style,
pub border_style: Style,
pub title_style: Style,
pub caption_style: Style,
pub title_justify: AlignMethod,
pub caption_justify: AlignMethod,
pub highlight: bool,
pub width: Option<usize>,
pub row_styles: Vec<Style>,
pub leading: usize,
pub rowspans: Vec<usize>,
pub section_rows: HashSet<usize>,
pub pad_edge: bool,
pub sections: Vec<usize>,
/* private fields */
}Expand description
A renderable for tabular data.
Fields§
§title: Option<String>Title above the table.
caption: Option<String>Caption below the table.
box_style: BoxStyleBox style.
show_header: boolShow the header row.
Show the footer row.
show_edge: boolShow outer edge border.
show_lines: boolShow lines between every row.
padding: (usize, usize, usize, usize)Padding per cell (top, right, bottom, left).
collapse_padding: boolCollapse padding between rows.
style: StyleDefault style for the table.
border_style: StyleBorder style.
title_style: StyleTitle style.
caption_style: StyleCaption style.
title_justify: AlignMethodTitle justification.
caption_justify: AlignMethodCaption justification.
highlight: boolIf true, highlight cell strings.
width: Option<usize>Optional fixed width.
row_styles: Vec<Style>Row styles (alternating).
leading: usizeNumber of blank lines between rows.
rowspans: Vec<usize>Active rowspan counts per column (tracked during rendering).
section_rows: HashSet<usize>Row indices that have a section separator before them.
pad_edge: boolPad the outer edge of the table (left of first column, right of last).
sections: Vec<usize>Row indices where sections end (ordered, in insertion order).
Implementations§
Source§impl Table
impl Table
Sourcepub fn add_column(&mut self, column: Column)
pub fn add_column(&mut self, column: Column)
Add a column definition to the table.
Columns must be added before rows are populated.
§Examples
use rusty_rich::{Table, Column};
let mut table = Table::new();
table.add_column(Column::new("Name"));
table.add_column(Column::new("Age"));Sourcepub fn add_row_explicit(&mut self, row: Row) -> &mut Self
pub fn add_row_explicit(&mut self, row: Row) -> &mut Self
Add a pre-built Row object, which may carry a style and section
information.
If the row has end_section set to true, a section divider is
inserted before this row.
Sourcepub fn add_row_str(&mut self, row: Vec<String>)
pub fn add_row_str(&mut self, row: Vec<String>)
Sourcepub fn row_explicit(self, row: Row) -> Self
pub fn row_explicit(self, row: Row) -> Self
Builder: add a pre-built Row and return self.
Sourcepub fn border_style(self, s: Style) -> Self
pub fn border_style(self, s: Style) -> Self
Builder: set border style.
Sourcepub fn hide_header(self) -> Self
pub fn hide_header(self) -> Self
Builder: hide the header.
Sourcepub fn show_lines(self) -> Self
pub fn show_lines(self) -> Self
Builder: show lines.
Sourcepub fn title_justify(self, justify: AlignMethod) -> Self
pub fn title_justify(self, justify: AlignMethod) -> Self
Builder: set title alignment.
Sourcepub fn caption_justify(self, justify: AlignMethod) -> Self
pub fn caption_justify(self, justify: AlignMethod) -> Self
Builder: set caption alignment.
Sourcepub fn row_styles(self, styles: Vec<Style>) -> Self
pub fn row_styles(self, styles: Vec<Style>) -> Self
Builder: set alternating row styles.
Sourcepub fn collapse_padding(self, value: bool) -> Self
pub fn collapse_padding(self, value: bool) -> Self
Builder: collapse padding between cells.
Sourcepub fn get_row_style(&self, row_index: usize) -> Option<Style>
pub fn get_row_style(&self, row_index: usize) -> Option<Style>
Get the style for a specific row (cycling through row_styles if set).
Sourcepub fn grid() -> Self
pub fn grid() -> Self
Create a grid table (no outer border, no header, no footer).
Equivalent to Table.grid().
Sourcepub fn add_section(&mut self) -> &mut Self
pub fn add_section(&mut self) -> &mut Self
Add a section separator before the next row.
The next row added will have a horizontal rule above it.
Returns &mut Self for chaining.
Trait Implementations§
Source§impl Renderable for Table
impl Renderable for Table
Source§fn render(&self, options: &ConsoleOptions) -> RenderResult
fn render(&self, options: &ConsoleOptions) -> RenderResult
RenderResult using the provided options. Read moreSource§fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>
fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>
__rich_measure__).
Override to provide min/max width constraints for layout.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<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more