pub trait ItemDelegate {
// Required methods
fn render(&self, m: &Model, index: usize, item: &dyn Item) -> String;
fn height(&self) -> usize;
fn spacing(&self) -> usize;
fn update(&self, msg: &dyn Msg, m: &Model) -> Cmd;
// Provided methods
fn short_help(&self) -> Vec<Binding> { ... }
fn full_help(&self) -> Vec<Vec<Binding>> { ... }
}Expand description
ItemDelegate encapsulates the general functionality for all list items. The benefit to separating this logic from the item itself is that you can change the functionality of items without changing the actual items themselves.
Note that if the delegate also implements help.KeyMap delegate-related help items will be added to the help view.
Required Methods§
Sourcefn render(&self, m: &Model, index: usize, item: &dyn Item) -> String
fn render(&self, m: &Model, index: usize, item: &dyn Item) -> String
Render renders the item’s view.
Sourcefn spacing(&self) -> usize
fn spacing(&self) -> usize
Spacing is the size of the horizontal gap between list items in cells.
Sourcefn update(&self, msg: &dyn Msg, m: &Model) -> Cmd
fn update(&self, msg: &dyn Msg, m: &Model) -> Cmd
Update is the update loop for items. All messages in the list’s update loop will pass through here except when the user is setting a filter. Use this method to perform item-level updates appropriate to this delegate.
Note: self and m are passed by shared reference (Rust-side
adaptation; the upstream signature takes a mutable model pointer).
Provided Methods§
Sourcefn short_help(&self) -> Vec<Binding>
fn short_help(&self) -> Vec<Binding>
ShortHelp returns bindings for the short help view, if the delegate implements the help keymap interface.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".