Skip to main content

Interface

Trait Interface 

Source
pub trait Interface: Facet {
    // Provided methods
    fn options(&self) -> Vec<Key>  { ... }
    fn select(&mut self, _key: &str) -> bool { ... }
    fn selected(&mut self) -> Option<&mut dyn Interface> { ... }
    fn controls(&self) -> Vec<Control> { ... }
}
Expand description

A node in the app’s ui tree — recursive, so a tab and a view mode are the same kind of thing at different depths.

app.ui().select("map");
app.ui().selected()?.select("3d");     // the SAME call, one level down

The controls under a choice are not looked up: they are selected. Pick 3d and you get the 3d node; its Facet::ui draws 3d’s controls, and nothing else can appear because nothing else was returned.

A leaf overrides nothing — impl Interface for MyPane {} is complete and means “no sub-choices”. See the module docs for why there is no blanket impl.

Provided Methods§

Source

fn options(&self) -> Vec<Key>

The choices available AT THIS LEVEL, in display order — tabs at the top, view modes one level down.

This must be the only list. korp’s tab strip, its state oracle and its own test each carried a separate copy — 17, 16 and 9 entries — and the test compared its copy to itself, so it was green forever while the first tab was unreachable. One list cannot disagree with itself.

Source

fn select(&mut self, _key: &str) -> bool

Choose one of options. Returns false for a key that is not on offer — a caller that ignores the result is asking for the same silent-no-op class this module exists to kill.

Source

fn selected(&mut self) -> Option<&mut dyn Interface>

The currently-selected child, or None for a leaf.

This is the load-bearing method. Rendering the selected child is what makes the dependent ui change when the choice changes, with nothing to keep in sync.

Source

fn controls(&self) -> Vec<Control>

The controls this node offers — as DATA, so every renderer draws the same set and a guard can compare two choices.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§