pub struct StatusMatrix { /* private fields */ }Expand description
Rows and columns of states: a test suite across platforms, services across regions, checks across hosts.
Each cell is a State named by a string. pass, fail, skip and
flaky are built in; state adds your own or restyles a
built-in one. Every state is a symbol and a colour, never colour
alone, and the legend under the grid names each symbol with how many
cells are in that state. A name with no state is drawn ? in
chart.state.unknown and named in the legend as it is.
- Columns are as wide as their widest header, with a cell between them,
and the symbol is centred. Given less width, headers are cut (with
…, or.in ASCII, and left out below three cells) down to the symbol, then the row labels are cut, then the gaps go; columns that still do not fit are left off the right. - A row shorter than the headers leaves its last cells blank.
use rich::Console;
use rich_ext::chart::StatusMatrix;
let console = Console::builder().width(40).color_system(None).build();
let matrix = StatusMatrix::new()
.columns(["linux", "macos", "win"])
.row("unit", ["pass", "pass", "fail"])
.row("e2e", ["pass", "flaky", "skip"]);
assert_eq!(
console.render_export(&matrix),
concat!(
" linux macos win \n",
"unit ✓ ✓ ✗ \n",
"e2e ✓ ≈ ○ \n",
"✓ pass 3 ✗ fail 1 ○ skip 1 ≈ flaky 1\n",
)
);Implementations§
Source§impl StatusMatrix
impl StatusMatrix
Sourcepub fn columns<S: Into<String>>(
self,
headers: impl IntoIterator<Item = S>,
) -> Self
pub fn columns<S: Into<String>>( self, headers: impl IntoIterator<Item = S>, ) -> Self
The column headers.
Sourcepub fn row<S: Into<String>>(
self,
label: impl Into<String>,
states: impl IntoIterator<Item = S>,
) -> Self
pub fn row<S: Into<String>>( self, label: impl Into<String>, states: impl IntoIterator<Item = S>, ) -> Self
Add a row: its label and the name of each cell’s state, in column order.
Sourcepub fn state(self, state: State) -> Self
pub fn state(self, state: State) -> Self
Add a state, or replace the one with the same name. The legend lists states in the order they were added (built-in ones first).
Sourcepub fn charset(self, charset: Charset) -> Self
pub fn charset(self, charset: Charset) -> Self
Glyphs to draw with: Charset::Ascii asks for the ASCII symbols;
anything else draws the states’ own symbols (ASCII on an ASCII-only
console).
Trait Implementations§
Source§impl AccessibleText for StatusMatrix
Status matrix, 3 rows by 4 columns: 9 pass, 2 fail, 1 skip, then the
cells of every state but pass and skip, each row on column (fail: unit on windows, lint on macos), ten at most.
impl AccessibleText for StatusMatrix
Status matrix, 3 rows by 4 columns: 9 pass, 2 fail, 1 skip, then the
cells of every state but pass and skip, each row on column (fail: unit on windows, lint on macos), ten at most.
Source§fn accessible_text(&self, _width: usize) -> String
fn accessible_text(&self, _width: usize) -> String
width where layout matters.Source§impl Clone for StatusMatrix
impl Clone for StatusMatrix
Source§impl Debug for StatusMatrix
impl Debug for StatusMatrix
Source§impl Default for StatusMatrix
impl Default for StatusMatrix
Source§impl Draw for StatusMatrix
impl Draw for StatusMatrix
Source§impl PartialEq for StatusMatrix
impl PartialEq for StatusMatrix
Source§impl Renderable for StatusMatrix
impl Renderable for StatusMatrix
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
(minimum, maximum) cell width this renderable wants. Port of
__rich_measure__. The default is what upstream’s Measurement.get
returns for a renderable without one: anything from nothing to the
whole width, (0, max_width).Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.Source§fn vertical(&self) -> Option<VerticalAlign>
fn vertical(&self) -> Option<VerticalAlign>
Table cell holding this renderable uses in
place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.Source§fn print_end_line(&self, _options: &ConsoleOptions) -> bool
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
"\n", so a print adds the final line break. A renderable
whose upstream output stops without one (Screen, LiveRender, a
Rule whose end has no newline) returns false, and the next
output continues its last line. options are the print’s options.