refactor: replace CommandChildGuard with CommandChild and simplify related methods

This commit is contained in:
Tunglies
2025-11-19 22:11:22 +08:00
parent d808e59156
commit 108a05ce96
4 changed files with 13 additions and 40 deletions
-30
View File
@@ -1,30 +0,0 @@
use tauri_plugin_shell::process::CommandChild;
#[derive(Debug)]
pub struct CommandChildGuard(Option<CommandChild>);
impl Drop for CommandChildGuard {
#[inline]
fn drop(&mut self) {
self.kill();
}
}
impl CommandChildGuard {
#[inline]
pub const fn new(child: CommandChild) -> Self {
Self(Some(child))
}
#[inline]
pub fn kill(&mut self) {
if let Some(child) = self.0.take() {
let _ = child.kill();
}
}
#[inline]
pub fn pid(&self) -> Option<u32> {
self.0.as_ref().map(|c| c.pid())
}
}
-2
View File
@@ -1,4 +1,2 @@
mod async_handler;
pub use async_handler::AsyncHandler;
mod guard;
pub use guard::CommandChildGuard;