ref + reset lint warnigs
parent
3d0b7766ac
commit
b456c7aa18
|
|
@ -29,15 +29,7 @@ pub mod v2 {
|
|||
fn new() -> Self {
|
||||
Pid(0)
|
||||
}
|
||||
fn new_from_output(pid: Option<Output>) -> Self {
|
||||
let temp = {
|
||||
match pid {
|
||||
Some(pid) => String::from_utf8_lossy(pid.stdout.trim_ascii()).into_owned(),
|
||||
None => return Pid(0),
|
||||
}
|
||||
};
|
||||
Pid(temp.parse::<u32>().unwrap_or_else(|_| { 0 }))
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn new_sysinfo_pid(&self) -> sysinfo::Pid {
|
||||
sysinfo::Pid::from_u32(self.0 as u32)
|
||||
}
|
||||
|
|
@ -77,6 +69,7 @@ pub mod v2 {
|
|||
self.bin = bin.as_ref().to_string_lossy().into_owned();
|
||||
self
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn get_pid(&self) -> Pid {
|
||||
self.pid
|
||||
}
|
||||
|
|
@ -158,28 +151,33 @@ pub mod v2 {
|
|||
}
|
||||
tokio::time::sleep(Duration::from_micros(100)).await;
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub async fn stop_by_user_call(&mut self) -> anyhow::Result<()> {
|
||||
terminate_process(&self.name).await?;
|
||||
self.state = ProcessState::StoppedByCli;
|
||||
self.pid = Pid::new();
|
||||
Ok(())
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub async fn freeze_by_user_call(&mut self) -> anyhow::Result<()> {
|
||||
freeze_process(&self.name).await?;
|
||||
self.state = ProcessState::HoldingByCli;
|
||||
Ok(())
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub async fn start_by_user_call(&mut self) -> anyhow::Result<()> {
|
||||
let pid = start_process(&self.name, &self.bin).await?;
|
||||
self.state = ProcessState::Pending;
|
||||
self.pid = Pid(pid);
|
||||
Ok(())
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub async fn unfreeze_by_user_call(&mut self) -> anyhow::Result<()> {
|
||||
unfreeze_process(&self.name).await?;
|
||||
self.state = ProcessState::Pending;
|
||||
Ok(())
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub async fn restart_by_user_call(&mut self) -> anyhow::Result<()> {
|
||||
let pid = restart_process(&self.name, &self.bin).await?;
|
||||
self.pid = Pid(pid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue