From 06123b5b7b23cf0a3a56a4e297c04c5b6efc71d2 Mon Sep 17 00:00:00 2001 From: futile Date: Thu, 4 Dec 2025 08:05:27 +0000 Subject: [PATCH] process: improve type ergonomics --- src/process.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/process.rs b/src/process.rs index 8ee7a5f..29d37a0 100644 --- a/src/process.rs +++ b/src/process.rs @@ -25,6 +25,12 @@ impl From<&str> for Identifier { } } +impl From for Identifier { + fn from(value: String) -> Self { + Self::Name(value) + } +} + #[derive(Debug, Default, Clone)] /// a process running on the system pub struct Process { @@ -75,7 +81,8 @@ impl Process { } /// get a `Module` of a `Process` by name (case-insensitive) - pub fn module(&self, name: &str) -> Result { + pub fn module>(&self, name: T) -> Result { + let name = name.as_ref(); let Some(snapshot) = snapshot::ModuleSnapshot::get_modules(self.id)? .into_iter() .find(|snapshot| name.eq_ignore_ascii_case(&snapshot.name)) @@ -110,7 +117,8 @@ impl Process { } /// follow a pointer chain to the end and return an address - pub fn resolve_pointer_chain(&self, chain: &[usize]) -> Result { + pub fn resolve_pointer_chain>(&self, chain: T) -> Result { + let chain = chain.as_ref(); if chain.is_empty() { return Err(Error::ResolvePointerChainError("chain was empty".into())); }