pub struct PluginHostProcess { /* private fields */ }Expand description
Manages a plugin running in an isolated process.
Responses are read on a background thread and delivered over a channel, so
Self::send_command can wait with a deadline: a hung plugin yields a timeout
error (and the child is killed) instead of blocking the host forever, and a
crashed helper surfaces as a disconnect error rather than a silent wedge.
Implementations§
Source§impl PluginHostProcess
impl PluginHostProcess
Sourcepub fn new(
helper_override: Option<PathBuf>,
timeout: Duration,
) -> Result<Self, String>
pub fn new( helper_override: Option<PathBuf>, timeout: Duration, ) -> Result<Self, String>
Create a new isolated plugin host process
Sourcepub fn set_timeout(&mut self, timeout: Duration)
pub fn set_timeout(&mut self, timeout: Duration)
Set how long to wait for a helper response before declaring a timeout.
Sourcepub fn send_command(
&mut self,
command: HostCommand,
) -> Result<HostResponse, String>
pub fn send_command( &mut self, command: HostCommand, ) -> Result<HostResponse, String>
Send a command to the helper process and wait (with a deadline) for a response.
Returns an error without blocking indefinitely if the plugin hangs (the child is killed) or the helper has crashed/exited.
Sourcepub fn helper_pid(&self) -> Option<u32>
pub fn helper_pid(&self) -> Option<u32>
OS process id of the running helper, if any. Useful for monitoring — and for tests that need to simulate a crash by killing the helper.
Sourcepub fn check_process_status(&mut self) -> Result<(), String>
pub fn check_process_status(&mut self) -> Result<(), String>
Check if the helper process is still running