pub trait Renderable {
// Required method
fn rich_render(
&self,
console: &Console,
options: &ConsoleOptions,
) -> Vec<Segment>;
// Provided methods
fn measure(
&self,
_console: &Console,
options: &ConsoleOptions,
) -> Measurement { ... }
fn fit_to_measurement(&self) -> bool { ... }
}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§
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Provided Methods§
Sourcefn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
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.
Sourcefn fit_to_measurement(&self) -> bool
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Renderable for Align
impl Renderable for Bar
impl Renderable for Columns
impl Renderable for Constrain
impl Renderable for Control
impl Renderable for Json
impl Renderable for Layout
impl Renderable for LiveRender
impl Renderable for LogRecord
impl Renderable for Markdown
impl Renderable for Padding
impl Renderable for Panel
impl Renderable for Pretty
impl Renderable for Progress
impl Renderable for ProgressBar
impl Renderable for Rule
impl Renderable for Screen
impl Renderable for Spinner
impl Renderable for Status
Upstream’s Status.__rich__ returns the spinner, so a status renders (and
measures) exactly as its spinner: the frame for the console’s clock.