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() -> Extensions
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§fn default() -> Extensions
fn default() -> 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 moreAuto Trait Implementations§
impl !RefUnwindSafe for Extensions
impl !Send for Extensions
impl !Sync for Extensions
impl !UnwindSafe for Extensions
impl Freeze for Extensions
impl Unpin for Extensions
impl UnsafeUnpin for Extensions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.