1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// Sonic // // Fast, lightweight and schema-less search backend // Copyright: 2026, Rémi Bardon <remi@remibardon.name> // License: Mozilla Public License v2.0 (MPL v2.0) /// Automatically kills the child process on [Drop]. pub struct SpawnGuard(pub std::process::Child); impl std::ops::Deref for SpawnGuard { type Target = std::process::Child; fn deref(&self) -> &Self::Target { &self.0 } } impl std::ops::DerefMut for SpawnGuard { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } impl Drop for SpawnGuard { fn drop(&mut self) { self.0.kill().unwrap(); self.0.wait().unwrap(); } }