From ddcb5dec3ddb85521ae42984474d8f4f2a81b38c Mon Sep 17 00:00:00 2001 From: steven-omaha <35634100+steven-omaha@users.noreply.github.com> Date: Thu, 5 Jan 2023 16:30:13 +0100 Subject: [PATCH] introduce backend modules --- src/backend/mod.rs | 14 ++++++++++++++ src/{backend.rs => backend/pacman.rs} | 8 +------- 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 src/backend/mod.rs rename src/{backend.rs => backend/pacman.rs} (79%) diff --git a/src/backend/mod.rs b/src/backend/mod.rs new file mode 100644 index 0000000..9b884b0 --- /dev/null +++ b/src/backend/mod.rs @@ -0,0 +1,14 @@ +mod pacman; + +use std::collections::HashSet; + +use crate::Package; + +pub use pacman::Pacman; + +pub trait Backend { + /// Get all packages that are installed in the system. + fn get_all_installed_packages() -> HashSet; + /// Get all packages that were installed in the system explicitly. + fn get_explicitly_installed_packages() -> HashSet; +} diff --git a/src/backend.rs b/src/backend/pacman.rs similarity index 79% rename from src/backend.rs rename to src/backend/pacman.rs index 57314e3..756e6ff 100644 --- a/src/backend.rs +++ b/src/backend/pacman.rs @@ -3,15 +3,9 @@ use std::collections::HashSet; use alpm::Alpm; use alpm::PackageReason::Explicit; +use super::Backend; use crate::Package; -pub trait Backend { - /// Get all packages that are installed in the system. - fn get_all_installed_packages() -> HashSet; - /// Get all packages that were installed in the system explicitly. - fn get_explicitly_installed_packages() -> HashSet; -} - pub struct Pacman; impl Backend for Pacman {