Skip to main content

StatusMatrix

Struct StatusMatrix 

Source
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

Source

pub fn new() -> Self

An empty matrix that knows pass, fail, skip and flaky.

Source

pub fn columns<S: Into<String>>( self, headers: impl IntoIterator<Item = S>, ) -> Self

The column headers.

Source

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.

Source

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).

Source

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

Show the legend (default on).

Source

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).

Source

pub fn counts(&self) -> Vec<(String, usize)>

How many cells are in each state that appears, in legend order: known states in the order they were added, then unknown names in the order they first appear.

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.

Source§

fn accessible_text(&self, _width: usize) -> String

The content as plain lines, laid out for width where layout matters.
Source§

impl Clone for StatusMatrix

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StatusMatrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StatusMatrix

Source§

fn default() -> Self

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

impl Draw for StatusMatrix

Source§

fn draw( &self, console: &Console, options: &ConsoleOptions, screen: &mut Screen, rect: Rect, )

Draw into rect of screen, rendered with options (its width and height are the rectangle’s): the cells screen.write_lines(rect, &console.render_lines(self, options, false)) would give.
Source§

impl PartialEq for StatusMatrix

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Renderable for StatusMatrix

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. 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

Whether a top-level 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>

The vertical alignment a 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

Whether a top-level print ends this renderable’s last line. This port’s renderables separate lines, where upstream’s end each line with "\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.
Source§

impl StructuralPartialEq for StatusMatrix

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more