Trait radicle_cli::terminal::cell::Cell

source ·
pub trait Cell: Display {
    type Truncated: Cell;
    type Padded: Cell;

    // Required methods
    fn width(&self) -> usize;
    fn truncate(&self, width: usize, delim: &str) -> Self::Truncated;
    fn pad(&self, width: usize) -> Self::Padded;

    // Provided method
    fn background(&self) -> Color { ... }
}
Expand description

Text that can be displayed on the terminal, measured, truncated and padded.

Required Associated Types§

source

type Truncated: Cell

Type after truncation.

source

type Padded: Cell

Type after padding.

Required Methods§

source

fn width(&self) -> usize

Cell display width in number of terminal columns.

source

fn truncate(&self, width: usize, delim: &str) -> Self::Truncated

Truncate cell if longer than given width. Shows the delimiter if truncated.

source

fn pad(&self, width: usize) -> Self::Padded

Pad the cell so that it is the given width, while keeping the content left-aligned.

Provided Methods§

source

fn background(&self) -> Color

Background color of cell.

Implementations on Foreign Types§

source§

impl Cell for str

§

type Truncated = String

§

type Padded = String

source§

fn width(&self) -> usize

source§

fn truncate(&self, width: usize, delim: &str) -> String

source§

fn pad(&self, max: usize) -> String

source§

impl Cell for String

§

type Truncated = String

§

type Padded = String

source§

fn width(&self) -> usize

source§

fn truncate(&self, width: usize, delim: &str) -> String

source§

fn pad(&self, width: usize) -> String

source§

impl<T> Cell for &T
where T: Cell + ?Sized,

§

type Truncated = <T as Cell>::Truncated

§

type Padded = <T as Cell>::Padded

source§

fn width(&self) -> usize

source§

fn truncate(&self, width: usize, delim: &str) -> <&T as Cell>::Truncated

source§

fn pad(&self, width: usize) -> <&T as Cell>::Padded

Implementors§