pub struct Extensions { /* private fields */ }Expand description
The runner’s extensions, each under the namespace the host gave it.
Origins are positions here: the host is OriginId::HOST and the
extension at index i is OriginId(i + 1), which is what an event’s
origin indexes back into.
Implementations§
Source§impl Extensions
impl Extensions
pub fn new() -> Self
Sourcepub fn push(&mut self, ext: Box<dyn Extension>) -> Result<(), String>
pub fn push(&mut self, ext: Box<dyn Extension>) -> Result<(), String>
Adds ext under its own name as the namespace — import fs binds
fs. push_as with an empty namespace, which means the same.
Sourcepub fn push_as(
&mut self,
namespace: impl Into<String>,
ext: Box<dyn Extension>,
) -> Result<(), String>
pub fn push_as( &mut self, namespace: impl Into<String>, ext: Box<dyn Extension>, ) -> Result<(), String>
Adds ext under namespace — import fs as left. An empty
namespace means the extension’s own name: the rule is here, once,
so that a host taking the namespace from outside the program (a C
argument, a Node option, a Lua call) passes it through rather than
substituting name() first — three of them did, and a fourth did
not. Fails when that name is empty too, when the namespace is
already taken (two extensions cannot share one, since slot names
would collide), or when a slot the extension lists contains the
separator (a slot name is the extension’s own word; the host adds
the namespace).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn by_origin(
&mut self,
origin: OriginId,
) -> Option<&mut (dyn Extension + 'static)>
pub fn by_origin( &mut self, origin: OriginId, ) -> Option<&mut (dyn Extension + 'static)>
The extension an event’s origin names, if any. None while that
extension is drawing — nothing routes events mid-frame — and for
an origin no extension has.
Sourcepub fn namespace_of(&self, origin: OriginId) -> Option<&str>
pub fn namespace_of(&self, origin: OriginId) -> Option<&str>
The namespace the host gave the extension at origin.
Sourcepub fn asked_by(&self, origin: OriginId) -> OriginId
pub fn asked_by(&self, origin: OriginId) -> OriginId
Who declared the slot the extension at origin last filled, and
so where its replies go: OriginId::HOST unless another extension
declared it.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &dyn Extension)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &dyn Extension)>
Every (namespace, extension), in origin order.
Sourcepub fn route(
&mut self,
events: impl IntoIterator<Item = UiEvent>,
to_host: impl FnMut(UiEvent),
)
pub fn route( &mut self, events: impl IntoIterator<Item = UiEvent>, to_host: impl FnMut(UiEvent), )
Delivers events to the extensions they came from and hands
to_host everything addressed to the host: the host’s own events,
and the replies of every extension whose slot the host declared.
A reply from an extension a guest placed goes to that guest
instead, as one more event — its origin still the replier’s, so
the receiver knows who spoke — and whatever the guest answers
travels the same way, up to MAX_REPLY_HOPS levels. This is the
loop all four hosts route with; one that grew its own would
disagree with the others about who hears a nested plugin.
Trait Implementations§
Source§impl Default for Extensions
impl Default for Extensions
Source§impl Fill for Extensions
The runner’s loop, as a Fill. A declared name is split at its last
/ into the namespace and the extension’s own slot name; the
extension under that namespace fills it if it lists the name (or the
name is "root" and it lists none). A view that errors leaves its
message in the tree (red, where the fill would have been) and raises
extension-view-error, once per extension and slot.
impl Fill for Extensions
The runner’s loop, as a Fill. A declared name is split at its last
/ into the namespace and the extension’s own slot name; the
extension under that namespace fills it if it lists the name (or the
name is "root" and it lists none). A view that errors leaves its
message in the tree (red, where the fill would have been) and raises
extension-view-error, once per extension and slot.
Source§fn fill(&mut self, full_name: &str, key: Key, params: &Value, ui: &mut Ui<'_>)
fn fill(&mut self, full_name: &str, key: Key, params: &Value, ui: &mut Ui<'_>)
full_name now, at the cursor, with
key its key: for the extension it names,
ui.fill(origin, slot, |ui| ext.view(slot, ui)), which is where
the namespace and the bound come from.Source§fn finish(&mut self, ui: &mut Ui<'_>)
fn finish(&mut self, ui: &mut Ui<'_>)
ns/root the host did not
declare, and warn about every slot an extension names that
nothing declared this frame.Source§fn add(
&mut self,
namespace: &str,
ext: Box<dyn Extension>,
) -> Result<OriginId, String>
fn add( &mut self, namespace: &str, ext: Box<dyn Extension>, ) -> Result<OriginId, String>
ext under namespace, mid-frame, and answers with the
origin it got — what a guest that hosts guests of its own calls
(env.add_extension in Lua). It joins the same list as everyone
else, so namespace has to be free of the host’s names too. Read more