Skip to main content

Renderable

Trait Renderable 

Source
pub trait Renderable {
    // Required method
    fn rich_render(
        &self,
        console: &Console,
        options: &ConsoleOptions,
    ) -> Vec<Segment>;

    // Provided method
    fn measure(
        &self,
        _console: &Console,
        options: &ConsoleOptions,
    ) -> Measurement { ... }
}
Expand description

Anything that can be rendered to a stream of Segments within a width.

The Rust equivalent of upstream’s __rich_console__(console, options) protocol. Implement it to make a custom type printable by Console. The options carry the available width (and, later, height/justify) the renderable must fit into. Newlines between lines are emitted as ordinary segments containing \n.

Required Methods§

Source

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Provided Methods§

Source

fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement

The (minimum, maximum) cell width this renderable wants. The default assumes the renderable fills the available width (e.g. Panel, Table); Text overrides it with its content width so the top-level print path can shrink to fit. Port of __rich_measure__ / Measurement.get.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§