Skip to main content

Extension

Trait Extension 

Source
pub trait Extension {
    // Required methods
    fn name(&self) -> &str;
    fn view(&mut self, slot: &Slot<'_>, ui: &mut Ui<'_>) -> Result<(), String>;
    fn on_event(&mut self, ev: &UiEvent) -> Vec<Value>;

    // Provided method
    fn slots(&self) -> &[String] { ... }
}
Expand description

A frontend that draws into the shared tree each frame — the trait the runner uses to host Lua (or any other) extensions without knowing what they are. Origins are assigned by the runner.

Where it draws is a slot the host declared: slots names the ones it fills, view is called once per frame for each of them with which one it is, and an extension naming none is called once after the host’s view for the reserved "root" slot — the sequence every extension got before slots existed. on_event answers with replies: values the runner hands to the host’s own on_event, with this extension’s origin on them.

Required Methods§

Source

fn name(&self) -> &str

Source

fn view(&mut self, slot: &Slot<'_>, ui: &mut Ui<'_>) -> Result<(), String>

Source

fn on_event(&mut self, ev: &UiEvent) -> Vec<Value>

One of this extension’s events; the values returned are replies to the host, delivered in order.

Provided Methods§

Source

fn slots(&self) -> &[String]

The slot names this extension fills; empty means "root". The one entry crate::slot::ANY_SLOT ("*") means every name declared under its namespace, for an extension whose slots are not known when it loads — a Lua host whose init.lua registers views at runtime, one slot per view — and it then gets no unknown-slot warning, since there is no list to check against.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§