Skip to main content

Renderable

Trait Renderable 

Source
pub trait Renderable {
    // Required method
    fn render(&self, options: &ConsoleOptions) -> RenderResult;

    // Provided method
    fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement> { ... }
}
Expand description

Trait for anything that can be rendered to the console.

Equivalent to __rich_console__ in Python Rich.

Required Methods§

Source

fn render(&self, options: &ConsoleOptions) -> RenderResult

Render this object into a RenderResult using the provided options.

Implementing types produce Segments or nested Renderables that are recursively flattened by Console::render.

Provided Methods§

Source

fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>

Optional width-measurement hook (equivalent to __rich_measure__). Override to provide min/max width constraints for layout.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Renderable for &str

Allows a &str to be used as a renderable (rendered as plain text).

Source§

fn render(&self, _options: &ConsoleOptions) -> RenderResult

Source§

impl Renderable for String

Allows a String to be used as a renderable.

Implementors§

Source§

impl Renderable for Columns

Source§

impl Renderable for DynRenderable

Delegates rendering to the inner trait object.

Source§

impl Renderable for Group

Renders each child sequentially and concatenates their output lines.

Source§

impl Renderable for JsonRender

Source§

impl Renderable for MarkdownRender

Source§

impl Renderable for Padding

Source§

impl Renderable for Panel

Source§

impl Renderable for Rule

Source§

impl Renderable for Screen

Source§

impl Renderable for Syntax

Source§

impl Renderable for Table

Source§

impl Renderable for Text

Allows a Text object to be used as a renderable.

Source§

impl Renderable for Traceback

Source§

impl Renderable for Tree

Source§

impl<T: Renderable + Clone> Renderable for Align<T>