ref + reset lint warnigs

migrate
prplV 2025-05-29 17:25:51 +03:00
parent 3d0b7766ac
commit b456c7aa18
1 changed files with 7 additions and 9 deletions

View File

@ -29,15 +29,7 @@ pub mod v2 {
fn new() -> Self { fn new() -> Self {
Pid(0) Pid(0)
} }
fn new_from_output(pid: Option<Output>) -> Self { #[allow(unused)]
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 }))
}
pub fn new_sysinfo_pid(&self) -> sysinfo::Pid { pub fn new_sysinfo_pid(&self) -> sysinfo::Pid {
sysinfo::Pid::from_u32(self.0 as u32) 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.bin = bin.as_ref().to_string_lossy().into_owned();
self self
} }
#[allow(unused)]
pub fn get_pid(&self) -> Pid { pub fn get_pid(&self) -> Pid {
self.pid self.pid
} }
@ -158,28 +151,33 @@ pub mod v2 {
} }
tokio::time::sleep(Duration::from_micros(100)).await; tokio::time::sleep(Duration::from_micros(100)).await;
} }
#[allow(unused)]
pub async fn stop_by_user_call(&mut self) -> anyhow::Result<()> { pub async fn stop_by_user_call(&mut self) -> anyhow::Result<()> {
terminate_process(&self.name).await?; terminate_process(&self.name).await?;
self.state = ProcessState::StoppedByCli; self.state = ProcessState::StoppedByCli;
self.pid = Pid::new(); self.pid = Pid::new();
Ok(()) Ok(())
} }
#[allow(unused)]
pub async fn freeze_by_user_call(&mut self) -> anyhow::Result<()> { pub async fn freeze_by_user_call(&mut self) -> anyhow::Result<()> {
freeze_process(&self.name).await?; freeze_process(&self.name).await?;
self.state = ProcessState::HoldingByCli; self.state = ProcessState::HoldingByCli;
Ok(()) Ok(())
} }
#[allow(unused)]
pub async fn start_by_user_call(&mut self) -> anyhow::Result<()> { pub async fn start_by_user_call(&mut self) -> anyhow::Result<()> {
let pid = start_process(&self.name, &self.bin).await?; let pid = start_process(&self.name, &self.bin).await?;
self.state = ProcessState::Pending; self.state = ProcessState::Pending;
self.pid = Pid(pid); self.pid = Pid(pid);
Ok(()) Ok(())
} }
#[allow(unused)]
pub async fn unfreeze_by_user_call(&mut self) -> anyhow::Result<()> { pub async fn unfreeze_by_user_call(&mut self) -> anyhow::Result<()> {
unfreeze_process(&self.name).await?; unfreeze_process(&self.name).await?;
self.state = ProcessState::Pending; self.state = ProcessState::Pending;
Ok(()) Ok(())
} }
#[allow(unused)]
pub async fn restart_by_user_call(&mut self) -> anyhow::Result<()> { pub async fn restart_by_user_call(&mut self) -> anyhow::Result<()> {
let pid = restart_process(&self.name, &self.bin).await?; let pid = restart_process(&self.name, &self.bin).await?;
self.pid = Pid(pid); self.pid = Pid(pid);