pub trait Component: 'static {
// Required method
fn render(&self, area: Rect, buffer: &mut Buffer);
// Provided methods
fn on_mount(&self) { ... }
fn on_unmount(&self) { ... }
fn component_id(&self) -> String { ... }
fn clone_box(&self) -> Box<dyn Component>
where Self: Clone { ... }
fn render_with_mount(&self, area: Rect, frame: &mut Frame<'_>)
where Self: Clone { ... }
}Required Methods§
Provided Methods§
Sourcefn on_unmount(&self)
fn on_unmount(&self)
Called when the component is about to be unmounted
Sourcefn component_id(&self) -> String
fn component_id(&self) -> String
Gets a unique identifier for this component instance
Sourcefn clone_box(&self) -> Box<dyn Component>where
Self: Clone,
fn clone_box(&self) -> Box<dyn Component>where
Self: Clone,
Clone the component into a Box This method makes the trait object-safe while still allowing cloning
Sourcefn render_with_mount(&self, area: Rect, frame: &mut Frame<'_>)where
Self: Clone,
fn render_with_mount(&self, area: Rect, frame: &mut Frame<'_>)where
Self: Clone,
Renders the component with mount/unmount lifecycle tracking
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".