Module settings

Source
Expand description

Module contains various table configuration settings.

There 2 types of settings;

CellOption works on behave of Modify which is actually a TableOption.

Notice that it’s possible to combine settings together by the help of Settings.

use tabled::{Table, settings::{Settings, Style, Padding}};

let table_config = Settings::default()
    .with(Padding::new(2, 2, 1, 1))
    .with(Style::rounded());

let data = [[2023;9]; 3];

let table = Table::new(data).with(table_config).to_string();

assert_eq!(
    table,
    "╭────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────╮\n\
     │        │        │        │        │        │        │        │        │        │\n\
     │  0     │  1     │  2     │  3     │  4     │  5     │  6     │  7     │  8     │\n\
     │        │        │        │        │        │        │        │        │        │\n\
     ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤\n\
     │        │        │        │        │        │        │        │        │        │\n\
     │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │\n\
     │        │        │        │        │        │        │        │        │        │\n\
     │        │        │        │        │        │        │        │        │        │\n\
     │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │\n\
     │        │        │        │        │        │        │        │        │        │\n\
     │        │        │        │        │        │        │        │        │        │\n\
     │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │  2023  │\n\
     │        │        │        │        │        │        │        │        │        │\n\
     ╰────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────╯"
)

Re-exports§

pub use self::style::Border;
pub use self::style::Style;
pub use self::disable::Remove;
pub use self::format::Format;
pub use self::height::Height;
pub use self::highlight::Highlight;
pub use self::merge::Merge;
pub use self::panel::Panel;
pub use self::span::Span;
pub use self::themes::Theme;
pub use self::width::Width;

Modules§

disable
This module contains a Remove structure which helps to remove an etheir column or row from a Table.
format
This module contains a list of primitives to help to modify a Table.
formatting
This module contains settings for render strategy of papergrid.
height
The module contains Height structure which is responsible for a table and cell height.
highlight
This module contains a Highlight primitive, which helps changing a Border style of any segment on a Table.
location
The module contains a Location trait and implementations for it.
measurement
The module contains Measurement trait and its implementations to be used in Height and Width.;
merge
The module contains a set of methods to merge cells together via Spans.
object
This module contains a list of primitives that implement a Object trait.
They help to locate a necessary segment on a Table.
padding_expand
This module contains a PaddingExpand setting to expand cells padding to its limit a cell.
panel
This module contains primitives to create a spread row. Ultimately it is a cell with a span set to a number of columns on the Table.
peaker
The module contains Priority and Peaker trait, its implementations to be used in Height and Width.
span
This module contains a Span settings, it helps to make a cell take more space then it generally takes.
split
This module contains a Split setting which is used to format the cells of a Table by a provided index, direction, behavior, and display preference.
style
This module contains a list of primitives which can be applied to change Table style.
themes
The module contains a variety of configurations of table, which often changes not a single setting. As such they are making relatively big changes to the configuration.
width
This module contains object which can be used to limit a cell to a given width:

Structs§

Alignment
Alignment represent a horizontal and vertical alignment setting for any cell on a Table.
Color
Color represents a color which can be set to things like Border, Padding and Margin.
Concat
Concat concatenates tables along a particular axis [Horizontal | Vertical]. It doesn’t do any key or column comparisons like SQL’s join does.
Dup
Dup duplicates a given set of cells into another set of ones Table.
EmptySettings
A marker structure to be able to create an empty Settings.
Extract
Returns a new Table that reflects a segment of the referenced Table
Margin
Margin is responsible for a left/right/top/bottom outer indent of a grid.
MarginColor
MarginColor is responsible for a left/right/top/bottom outer color of a grid.
Modify
Modify structure provide an abstraction, to be able to apply a set of CellOptions to the same object.
ModifyList
This is a container of CellOptions which are applied to a set Object.
Padding
Padding is responsible for a left/right/top/bottom inner indent of a particular cell.
PaddingColor
PaddingColor is responsible for a left/right/top/bottom inner color of a particular cell.
Reverse
Reverse data on the table.
Settings
Settings is a combinator of TableOptions.
Shadow
The structure represents a shadow of a table.

Enums§

Rotate
Rotate can be used to rotate a table by 90 degrees.

Traits§

CellOption
A trait for configuring a single cell.
TableOption
A trait which is responsible for configuration of a Table.