Skip to main content

ItemDelegate

Trait ItemDelegate 

Source
pub trait ItemDelegate<I: Item>:
    Clone
    + Send
    + 'static {
    // Required methods
    fn height(&self) -> usize;
    fn spacing(&self) -> usize;
    fn render(
        &self,
        item: &I,
        index: usize,
        selected: bool,
        width: usize,
    ) -> String;

    // Provided method
    fn update(&mut self, _msg: &Message, _item: &mut I) -> Option<Cmd> { ... }
}
Expand description

Trait for rendering list items.

Required Methods§

Source

fn height(&self) -> usize

Returns the height of each item in lines.

Source

fn spacing(&self) -> usize

Returns the spacing between items.

Source

fn render(&self, item: &I, index: usize, selected: bool, width: usize) -> String

Renders an item.

Provided Methods§

Source

fn update(&mut self, _msg: &Message, _item: &mut I) -> Option<Cmd>

Updates the delegate (optional).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§