pub struct ProcessSpawner { /* private fields */ }Expand description
Unified process spawner.
Automatically detects the best backend (systemd if available, otherwise standalone) and provides a consistent API for spawning and managing processes.
§Example
use hyprstream_rpc::service::spawner::{ProcessSpawner, ProcessConfig};
// Auto-detect best backend
let spawner = ProcessSpawner::new();
// Spawn a daemon
let config = ProcessConfig::new("nydusd", "/usr/bin/nydusd")
.args(["--config", "/etc/nydusd.json"]);
let process = spawner.spawn(config).await?;
println!("Spawned: {}", process.id());
// Later, stop it
spawner.stop(&process).await?;Implementations§
Source§impl ProcessSpawner
impl ProcessSpawner
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new process spawner with auto-detection.
Uses systemd if available, otherwise falls back to standalone spawning.
Sourcepub fn with_backend(backend: ProcessBackend) -> Self
pub fn with_backend(backend: ProcessBackend) -> Self
Create a spawner with explicit backend selection.
If systemd is requested but not available, falls back to standalone.
Sourcepub fn standalone() -> Self
pub fn standalone() -> Self
Create a spawner that always uses standalone spawning.
Sourcepub fn backend_type(&self) -> &ProcessBackend
pub fn backend_type(&self) -> &ProcessBackend
Get the backend type being used.
Sourcepub fn is_systemd_available() -> bool
pub fn is_systemd_available() -> bool
Check if systemd is available on this system.
Sourcepub async fn spawn(&self, config: ProcessConfig) -> Result<SpawnedProcess>
pub async fn spawn(&self, config: ProcessConfig) -> Result<SpawnedProcess>
Sourcepub async fn stop(&self, process: &SpawnedProcess) -> Result<()>
pub async fn stop(&self, process: &SpawnedProcess) -> Result<()>
Sourcepub async fn is_running(&self, process: &SpawnedProcess) -> Result<bool>
pub async fn is_running(&self, process: &SpawnedProcess) -> Result<bool>
Sourcepub fn stop_tracked_child_sync(&self, process: &SpawnedProcess) -> Result<()>
pub fn stop_tracked_child_sync(&self, process: &SpawnedProcess) -> Result<()>
Synchronous bounded stop of a TRACKED direct child, used only by the
launch-transaction guard’s Drop for cancellation cleanup where no
async runtime work is guaranteed (#1585). Delegates to the backend,
which stops through its retained child handle — never a blind by-PID
signal; unsupported backends fail honestly.
Trait Implementations§
Source§impl Clone for ProcessSpawner
impl Clone for ProcessSpawner
Auto Trait Implementations§
impl Freeze for ProcessSpawner
impl !RefUnwindSafe for ProcessSpawner
impl Send for ProcessSpawner
impl Sync for ProcessSpawner
impl Unpin for ProcessSpawner
impl UnsafeUnpin for ProcessSpawner
impl !UnwindSafe for ProcessSpawner
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more