pub trait MenuProvider {
type MenuId: Copy + Debug + PartialEq;
// Required methods
fn title(&self, menu: Self::MenuId) -> &str;
fn options(&self, menu: Self::MenuId) -> &[MenuOption];
fn option_count(&self, menu: Self::MenuId) -> u8;
fn scrollable(&self, menu: Self::MenuId) -> bool;
fn layout(&self, menu: Self::MenuId) -> MenuLayout;
}Expand description
Provider of static menu definitions (titles, options, layouts).
MenuProvider decouples menu data from menu state and
rendering. The implementing crate supplies concrete menu IDs and
the associated data; the engine’s MenuSystem consumes this data
without knowing anything about the game’s menu hierarchy.
§Associated Types
MenuId— an enum (or otherCopy + PartialEq + Debugtype) that identifies which menu screen to display.
Required Associated Types§
Required Methods§
Sourcefn options(&self, menu: Self::MenuId) -> &[MenuOption]
fn options(&self, menu: Self::MenuId) -> &[MenuOption]
The list of options for this menu. The returned slice must live
at least as long as self.
Sourcefn option_count(&self, menu: Self::MenuId) -> u8
fn option_count(&self, menu: Self::MenuId) -> u8
Number of visible options (for cursor bounds checking and scroll window size).
Sourcefn scrollable(&self, menu: Self::MenuId) -> bool
fn scrollable(&self, menu: Self::MenuId) -> bool
Whether the option list can scroll when it exceeds the visible window.
Sourcefn layout(&self, menu: Self::MenuId) -> MenuLayout
fn layout(&self, menu: Self::MenuId) -> MenuLayout
Static layout descriptor (position, size, spacing, cursor policy).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".