use crate::cache::*;
use crate::library::CargoCachePaths;
use crate::top_items::binaries::*;
use crate::top_items::git_bare_repos::*;
use crate::top_items::git_checkouts::*;
use crate::top_items::registry_pkg_cache::*;
use crate::top_items::registry_sources::*;
#[allow(clippy::complexity)]
pub(crate) fn get_top_crates(
limit: u32,
ccd: &CargoCachePaths,
bin_cache: &mut bin::BinaryCache,
checkouts_cache: &mut git_checkouts::GitCheckoutCache,
bare_repos_cache: &mut git_bare_repos::GitRepoCache,
registry_pkg_caches: &mut registry_pkg_cache::RegistryPkgCaches,
registry_sources_caches: &mut registry_sources::RegistrySourceCaches,
) -> String {
let mut reg_src = String::new();
let mut reg_cache = String::new();
let mut bare_repos = String::new();
let mut repo_checkouts = String::new();
let mut binaries = String::new();
rayon::scope(|s| {
s.spawn(|_| {
reg_src = registry_source_stats(&ccd.registry_sources, limit, registry_sources_caches);
});
s.spawn(|_| {
reg_cache =
registry_pkg_cache_stats(&ccd.registry_pkg_cache, limit, registry_pkg_caches);
});
s.spawn(|_| {
bare_repos = git_repos_bare_stats(&ccd.git_repos_bare, limit, bare_repos_cache);
});
s.spawn(|_| {
repo_checkouts = git_checkouts_stats(&ccd.git_checkouts, limit, checkouts_cache);
});
s.spawn(|_| {
binaries = binary_stats(&ccd.bin_dir, limit, bin_cache);
});
});
let mut output = String::with_capacity(
binaries.len() + reg_src.len() + reg_cache.len() + bare_repos.len() + repo_checkouts.len(),
);
output.push_str(&binaries);
output.push_str(®_src);
output.push_str(®_cache);
output.push_str(&bare_repos);
output.push_str(&repo_checkouts);
output.trim().to_string()
}