pub trait List {
// Required methods
fn render_item<B: Backend>(
&mut self,
index: usize,
hovered: bool,
layout: Layout,
backend: &mut B,
) -> Result<()>;
fn is_selectable(&self, index: usize) -> bool;
fn page_size(&self) -> usize;
fn should_loop(&self) -> bool;
fn height_at(&mut self, index: usize, layout: Layout) -> u16;
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A trait to represent a renderable list.
See Select
Required Methods§
Sourcefn render_item<B: Backend>(
&mut self,
index: usize,
hovered: bool,
layout: Layout,
backend: &mut B,
) -> Result<()>
fn render_item<B: Backend>( &mut self, index: usize, hovered: bool, layout: Layout, backend: &mut B, ) -> Result<()>
Render a single element at some index.
When rendering the element, only at most layout.max_height lines can be used. If more
lines are used, the list may not be rendered properly. The place the terminal cursor ends at
does not matter.
layout.max_height may be less than the height given by height_at.
layout.render_region can be used to determine which part of the element you want to
render.
Sourcefn is_selectable(&self, index: usize) -> bool
fn is_selectable(&self, index: usize) -> bool
Whether the element at a particular index is selectable. Those that are not selectable are skipped during navigation.
Sourcefn page_size(&self) -> usize
fn page_size(&self) -> usize
The maximum height that can be taken by the list.
If the total height exceeds the page size, the list will be scrollable.
Sourcefn should_loop(&self) -> bool
fn should_loop(&self) -> bool
Whether to wrap around when user gets to the last element.
This only applies when the list is scrollable, i.e. page size > total height.
Provided Methods§
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.