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§