Skip to main content

Renderable

Trait Renderable 

Source
pub trait Renderable {
    // Required method
    fn render(&self, context: &RenderContext) -> Vec<Segment>;

    // Provided methods
    fn min_width(&self) -> usize { ... }
    fn max_width(&self) -> usize { ... }
}
Expand description

Trait for objects that can be rendered to the console.

This is the core abstraction for renderable content, similar to Rich’s __rich_console__ protocol.

Required Methods§

Source

fn render(&self, context: &RenderContext) -> Vec<Segment>

Render this object to a sequence of segments.

The context provides information about the rendering environment, such as available width.

Provided Methods§

Source

fn min_width(&self) -> usize

Get the minimum width required to render this object.

Source

fn max_width(&self) -> usize

Get the maximum/natural width of this object.

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

Implement Renderable for &str.

Source§

fn render(&self, _context: &RenderContext) -> Vec<Segment>

Source§

fn max_width(&self) -> usize

Source§

impl Renderable for String

Implement Renderable for String.

Source§

fn render(&self, _context: &RenderContext) -> Vec<Segment>

Source§

fn max_width(&self) -> usize

Implementors§