pub struct WidgetProcessManager {
processes: HashMap<(String, String), ManagedProcess>,
events_tx: SyncSender<WidgetProcessEvent>,
events_rx: Receiver<WidgetProcessEvent>,
pending_events: VecDeque<WidgetProcessEvent>,
}Expand description
Starts, feeds, and stops the processes widgets declare, and buffers their output.
Processes are keyed by widget ID and process ID. Dropping the manager stops them all.
Fields§
§processes: HashMap<(String, String), ManagedProcess>§events_tx: SyncSender<WidgetProcessEvent>§events_rx: Receiver<WidgetProcessEvent>§pending_events: VecDeque<WidgetProcessEvent>Events read from the channel but not yet taken by their widget.
Implementations§
Source§impl WidgetProcessManager
impl WidgetProcessManager
Sourcepub fn start(
&mut self,
widget_id: &str,
widget_root: &Path,
declaration: &WidgetProcess,
arguments: &[String],
) -> Result<(), String>
pub fn start( &mut self, widget_id: &str, widget_root: &Path, declaration: &WidgetProcess, arguments: &[String], ) -> Result<(), String>
Starts a declared process with arguments from its allow list.
The executable must resolve inside the widget folder. Fails when the process is already running; an exited process is replaced.
Sourcepub fn send(
&mut self,
widget_id: &str,
process_id: &str,
message: &str,
) -> Result<(), String>
pub fn send( &mut self, widget_id: &str, process_id: &str, message: &str, ) -> Result<(), String>
Writes one line of JSON to the process’s input.
Sourcepub fn stop(&mut self, widget_id: &str, process_id: &str) -> Result<(), String>
pub fn stop(&mut self, widget_id: &str, process_id: &str) -> Result<(), String>
Closes the process’s input so it can clean up and exit, and kills it after EXIT_GRACE. Stopping a missing or exited process succeeds.
Sourcepub fn stop_widget(&mut self, widget_id: &str)
pub fn stop_widget(&mut self, widget_id: &str)
Stops every process a widget started.
Sourcepub fn drain_events(&mut self, widget_id: &str) -> Vec<WidgetProcessEvent>
pub fn drain_events(&mut self, widget_id: &str) -> Vec<WidgetProcessEvent>
Returns and removes the widget’s buffered output, keeping other widgets’ output.
Trait Implementations§
Source§impl Default for WidgetProcessManager
impl Default for WidgetProcessManager
Source§impl Drop for WidgetProcessManager
impl Drop for WidgetProcessManager
Auto Trait Implementations§
impl !Sync for WidgetProcessManager
impl Freeze for WidgetProcessManager
impl RefUnwindSafe for WidgetProcessManager
impl Send for WidgetProcessManager
impl Unpin for WidgetProcessManager
impl UnsafeUnpin for WidgetProcessManager
impl UnwindSafe for WidgetProcessManager
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
Mutably borrows from an owned value. Read more