1use std::{collections::HashSet, fs::read_dir, path::Path};
4
5use clap::ValueEnum;
6use strum::{Display, EnumIter};
7
8pub mod aur;
9pub mod mirror;
10pub mod pkgsrc;
11
12use crate::Error;
13
14#[derive(Clone, Debug, Display, EnumIter, PartialEq, ValueEnum)]
16pub enum PackageRepositories {
17 #[strum(to_string = "core")]
21 Core,
22
23 #[strum(to_string = "extra")]
27 Extra,
28
29 #[strum(to_string = "multilib")]
33 Multilib,
34}
35
36pub fn filenames_in_dir(path: &Path) -> Result<HashSet<String>, Error> {
38 let entries = read_dir(path).map_err(|source| Error::IoPath {
39 path: path.to_path_buf(),
40 context: "retrieving the entries of the directory".to_string(),
41 source,
42 })?;
43 let mut files: HashSet<String> = HashSet::new();
44 for entry in entries {
45 let entry = entry.map_err(|source| Error::IoPath {
46 path: path.to_path_buf(),
47 context: "retrieving an entry in the directory".to_string(),
48 source,
49 })?;
50 files.insert(entry.file_name().to_string_lossy().to_string());
51 }
52
53 Ok(files)
54}