From d44041040d755306c39d6de8da5b42d7ded6808c Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 25 Sep 2024 15:13:34 +0200 Subject: added notifications and improved stuff --- src/packages.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/packages.rs') diff --git a/src/packages.rs b/src/packages.rs index de818f4..41b9478 100644 --- a/src/packages.rs +++ b/src/packages.rs @@ -37,15 +37,12 @@ pub enum Manager { } impl Manager { - pub fn get_manager(manager: Option) -> Result> { + pub fn from_sys() -> Result { #[cfg(not(target_os = "linux"))] return Err(Error::Unsupported); #[cfg(target_os = "linux")] { - if let Some(man) = manager { - return Ok(man.to_package_manager()); - } let mut os_release = File::open("/etc/os-release")?; let mut content = String::new(); os_release.read_to_string(&mut content)?; @@ -63,15 +60,15 @@ impl Manager { } } - fn from_str(value: &str) -> Result> { + fn from_str(value: &str) -> Result { Ok(match value { - "arch" => Box::new(Pacman), - "gentoo" => Box::new(Portage), + "arch" => Self::Pacman, + "gentoo" => Self::Portage, _ => return Err(Error::Unsupported), }) } - fn to_package_manager(&self) -> Box { + pub fn to_package_manager(&self) -> Box { match self { Self::Pacman => Box::new(Pacman), Self::Portage => Box::new(Portage), -- cgit v1.2.3