use derive_more for From implementations on Identifier
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ repository = "https://github.com/elituf/haxor"
|
|||||||
keywords = ["memory", "game", "hacking", "process"]
|
keywords = ["memory", "game", "hacking", "process"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive_more = { version = "2", features = ["debug", "display"] }
|
derive_more = { version = "2", features = ["debug", "display", "from"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
windows = { version = "0.62", features = [
|
windows = { version = "0.62", features = [
|
||||||
|
|||||||
+4
-20
@@ -2,7 +2,7 @@ use crate::{
|
|||||||
error::Error,
|
error::Error,
|
||||||
sys::{handle::Handle, memory, snapshot},
|
sys::{handle::Handle, memory, snapshot},
|
||||||
};
|
};
|
||||||
use derive_more::{Debug, derive::Display};
|
use derive_more::{Debug, From, derive::Display};
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
/// a process running on the system
|
/// a process running on the system
|
||||||
@@ -137,29 +137,13 @@ pub struct Module {
|
|||||||
pub base_size: usize,
|
pub base_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Display)]
|
#[derive(Display, From)]
|
||||||
/// an identifier for searching for a process
|
/// an identifier for searching for a process
|
||||||
pub enum Identifier {
|
pub enum Identifier {
|
||||||
/// process id to search for
|
/// process id to search for
|
||||||
|
#[from(u32)]
|
||||||
Pid(u32),
|
Pid(u32),
|
||||||
/// process name to search for
|
/// process name to search for
|
||||||
|
#[from(&str, String)]
|
||||||
Name(String),
|
Name(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u32> for Identifier {
|
|
||||||
fn from(value: u32) -> Self {
|
|
||||||
Self::Pid(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&str> for Identifier {
|
|
||||||
fn from(value: &str) -> Self {
|
|
||||||
Self::Name(value.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<String> for Identifier {
|
|
||||||
fn from(value: String) -> Self {
|
|
||||||
Self::Name(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user