mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-24 20:52:15 +08:00
refactor: replace CommandChildGuard with CommandChild and simplify related methods
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,2 @@
|
||||
mod async_handler;
|
||||
pub use async_handler::AsyncHandler;
|
||||
mod guard;
|
||||
pub use guard::CommandChildGuard;
|
||||
|
||||
Reference in New Issue
Block a user