implement generic backend methods with a macro

This commit is contained in:
timeshifter
2023-01-09 17:23:34 +01:00
parent 098ab765b3
commit 20a37c4d5f
4 changed files with 25 additions and 32 deletions
+2 -16
View File
@@ -1,7 +1,7 @@
use std::{collections::HashSet, process::Command};
use super::{Backend, Switches, Text};
use crate::Package;
use crate::{impl_backend_constants, Package};
pub struct Rust {
pub packages: HashSet<Package>,
@@ -13,21 +13,7 @@ const SWITCHES_INSTALL: Switches = &["install"];
const SWITCHES_REMOVE: Switches = &["uninstall"];
impl Backend for Rust {
fn get_binary(&self) -> Text {
BINARY
}
fn get_section(&self) -> Text {
SECTION
}
fn get_switches_install(&self) -> Switches {
SWITCHES_INSTALL
}
fn get_switches_remove(&self) -> Switches {
SWITCHES_REMOVE
}
impl_backend_constants!(Rust);
fn get_all_installed_packages(&self) -> HashSet<Package> {
extract_packages_names(&run_cargo_install_list())