Skip to main content

PluginHost

Struct PluginHost 

Source
pub struct PluginHost { /* private fields */ }
Expand description

Window-scoped plugin host: discovery cache, running processes, restart supervision, and the last SetWidget text per plugin.

Implementations§

Source§

impl PluginHost

Source

pub fn overlays(&self) -> &HashMap<String, PluginOverlay>

Live plugin overlays (plugin id → overlay), for the render layer.

Source

pub fn focused_overlay(&self) -> Option<&str>

The focused overlay’s plugin id, if any — the render layer’s click-to-focus target check and the key router’s focus check.

Source

pub fn focus_overlay(&mut self, plugin_id: &str)

Focus one plugin’s overlay (the render layer’s click path). Only an overlay that is live AND interactive can take focus — everything else clears focus, so the call doubles as the unfocus path.

Source

pub fn unfocus_overlay(&mut self)

Drop overlay focus entirely (Escape path; also called when the focused overlay stops being focusable).

Source

pub fn send_overlay_event( &mut self, plugin_id: &str, widget_id: &str, event: OverlayWidgetEvent, ) -> bool

Deliver one semantic overlay-widget event to a plugin’s running overlay process (the renderer’s interaction sink). Returns false without warning when there is nothing to deliver to — the renderer only calls this for a focused overlay it just drew, so a miss means the process raced an exit, which the supervisor reports.

Source

pub fn overlay_events_dispatched_count(&self) -> u64

Successful overlay-event stdin writes this session — the plugin_overlay_event ui-test operand’s source. Monotonic.

Source§

impl PluginHost

Source

pub fn new() -> Self

Create an empty host. Nothing runs until refresh_discovery + apply_enabled say otherwise.

Source

pub fn refresh_discovery(&mut self, root: &Path) -> &[DiscoveredPlugin]

Re-scan a plugins root, replacing the discovery cache. Running plugins are preserved — a re-scan never stops or spawns anything.

Source

pub fn discovered(&self, id: &str) -> Option<&DiscoveredPlugin>

The discovery-cache entry for a plugin id, if the last scan found it.

Source

pub fn discovered_count(&self) -> usize

Number of plugins the last discovery scan accepted.

Source

pub fn apply_enabled(&mut self, enabled: &[EnabledPlugin])

Reconcile running plugins with the enabled set (diff → spawn/stop).

Land-disabled is structural: only ids present in enabled AND in the discovery cache are spawned, so dropping a plugin directory into the root does nothing until the Settings layer enables it. A multi-kind manifest spawns every declared kind’s entry in this one pass, with the same settings argv and one supervision slot per kind (design D5).

Source

pub fn poll(&mut self)

Advance supervision one frame: drain each running plugin process’s commands (every kind), observe exits, and drive each kind’s restart supervisor (manifest-declared mode, capped) — one frame advance covers the widget, action, and panel maps identically.

Commands are drained before exit handling so a plugin’s final output before a crash still lands.

Source

pub fn widget_text(&self, plugin_id: &str) -> Option<&str>

Last SetWidget text recorded for a plugin, if any.

Source

pub fn panel_content(&self, plugin_id: &str) -> Option<&(String, String)>

Last SetPanel (title, content) recorded for a panel plugin, if any.

Source

pub fn subscription_forwarders( &self, ) -> &HashMap<String, Arc<ScriptEventForwarder>>

Live per-plugin event forwarders (plugin id → forwarder), for the window layer’s observer registration and per-sweep drain — the pump in StatusBarUI::pump_plugin_events.

Source

pub fn deliver_events(&mut self, plugin_id: &str, events: &[ScriptEvent])

Deliver drained events to one plugin’s running processes (every kind alike — the manifest’s subscriptions are plugin-level, so every running process of the plugin hears them).

A plugin with no running process this sweep silently drops the events: they are moments in time, not state, and its supervisor restarts it for the next ones. Write failures (a process exiting mid-delivery) warn once per episode.

Source

pub fn sync_theme(&mut self, theme: &Theme)

Deliver the active theme to every running plugin subscribed to THEME_CHANGED_KIND: the greet after each (re)spawn and every change thereafter, deduped by theme name.

App-sourced — nothing here reads a terminal. The status bar calls this per frame with the config-resolved theme, which catches every theme-application site (system dark/light switch, settings apply, config reload) without editing any of them. A same-name sync delivers nothing unless the plugin was (re)spawned since (the greet-due flag), so a respawned process that has never seen a theme still gets one.

Source

pub fn widget_texts(&self) -> &HashMap<String, String>

All recorded widget texts (plugin id → text), for the status bar.

Source

pub fn panel_contents(&self) -> &HashMap<String, (String, String)>

All recorded panel contents (plugin id → (title, content)), for the settings plugins section.

Source

pub fn actions_dispatched_count(&self) -> u64

Successful Self::invoke_action stdin writes this session. Monotonic for the session and never reset — delivered-means-true dispatch has no undo, so the count only grows.

Source

pub fn running_plugin_ids(&self) -> Vec<String>

Ids of plugins with any running or supervised process, of any kind. A multi-kind plugin appears once.

Source

pub fn invoke_action(&mut self, plugin_id: &str, action_id: &str) -> bool

Invoke one of a plugin’s contributed palette actions: write a single ScriptEvent line carrying ScriptEventData::PluginActionInvoked to the plugin’s running action process.

Returns true only when the plugin is discovered, declares the action-contributor kind, the action id is in its manifest, a process is running, and the stdin write succeeded. Every miss returns false behind WarnOnce gates (warned_not_discovered, and warned_action_not_running for every post-discovery miss) — a stuck keybinding can retry this at frame rate.

Source

pub fn palette_actions(&self) -> Vec<PluginActionRow>

Palette rows for every action of every discovered, enabled, action-contributor plugin (design D2), in discovery order.

Source

pub fn drain_ignored(&mut self) -> Vec<String>

Take the lines accumulated from refused plugin commands (the read-errors-style surface for commands v1 ignores).

Source

pub fn drain_crash_caps(&mut self) -> Vec<PluginCrashCap>

Drain supervisor give-up events (see PluginCrashCap). Called once per frame by the window layer.

Source

pub fn stop_all(&mut self)

Stop every plugin and drop all supervision state.

Trait Implementations§

Source§

impl Default for PluginHost

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.