Trait Element

Source
pub trait Element:
    Debug
    + Send
    + Sync {
    // Required methods
    fn size(&self, parent: Constraint) -> Size;
    fn render(&self, parent: Constraint) -> Vec<Line>;

    // Provided methods
    fn columns(&self, parent: Constraint) -> usize { ... }
    fn rows(&self, parent: Constraint) -> usize { ... }
    fn print(&self) { ... }
    fn write(&self, constraints: Constraint) -> Result<(), Error>
       where Self: Sized { ... }
    fn display(&self, constraints: Constraint) -> String { ... }
}
Expand description

A text element that has a size and can be rendered to the terminal.

Required Methods§

Source

fn size(&self, parent: Constraint) -> Size

Get the size of the element, in rows and columns.

Source

fn render(&self, parent: Constraint) -> Vec<Line>

Render the element as lines of text that can be printed.

Provided Methods§

Source

fn columns(&self, parent: Constraint) -> usize

Get the number of columns occupied by this element.

Source

fn rows(&self, parent: Constraint) -> usize

Get the number of rows occupied by this element.

Source

fn print(&self)

Print this element to stdout.

Source

fn write(&self, constraints: Constraint) -> Result<(), Error>
where Self: Sized,

Write using the given constraints to stdout.

Source

fn display(&self, constraints: Constraint) -> String

Return a string representation of this element.

Trait Implementations§

Source§

impl Element for Box<dyn Element + '_>

Source§

fn size(&self, parent: Constraint) -> Size

Get the size of the element, in rows and columns.
Source§

fn render(&self, parent: Constraint) -> Vec<Line>

Render the element as lines of text that can be printed.
Source§

fn print(&self)

Print this element to stdout.
Source§

fn columns(&self, parent: Constraint) -> usize

Get the number of columns occupied by this element.
Source§

fn rows(&self, parent: Constraint) -> usize

Get the number of rows occupied by this element.
Source§

fn write(&self, constraints: Constraint) -> Result<(), Error>
where Self: Sized,

Write using the given constraints to stdout.
Source§

fn display(&self, constraints: Constraint) -> String

Return a string representation of this element.

Implementations on Foreign Types§

Source§

impl Element for Box<dyn Element + '_>

Source§

fn size(&self, parent: Constraint) -> Size

Source§

fn render(&self, parent: Constraint) -> Vec<Line>

Source§

fn print(&self)

Source§

impl Element for Vec<Line>

Source§

fn size(&self, parent: Constraint) -> Size

Source§

fn render(&self, parent: Constraint) -> Vec<Line>

Source§

impl<T> Element for &T
where T: Element,

Source§

fn size(&self, parent: Constraint) -> Size

Source§

fn render(&self, parent: Constraint) -> Vec<Line>

Source§

fn print(&self)

Implementors§

Source§

impl Element for HStack<'_>

Source§

impl Element for Label

Source§

impl Element for Line

Source§

impl Element for TextArea

Source§

impl Element for VStack<'_>

Source§

impl<const W: usize, T> Element for Table<W, T>
where T: Cell + Debug + Send + Sync, <T as Cell>::Padded: Into<Line>,