Skip to main content

artifactize_core/
project.rs

1//! Project selection, verification orchestration, and status.
2
3pub mod selection;
4
5mod status;
6pub use status::{
7    ArtifactCondition, ArtifactState, Counts, EvalCondition, EvalState, StatusView, VerifyAction,
8    status,
9};
10
11pub(crate) mod verify;
12pub use verify::{VerifyOptions, verify};
13
14/// The fingerprint bound `status` and `verify` use: `--fingerprint-jobs`, else the CPUs.
15fn fingerprint_parallelism(options: &VerifyOptions) -> Result<crate::cache::Parallelism, String> {
16    let jobs = options
17        .fingerprint_jobs
18        .unwrap_or_else(crate::cache::Parallelism::available);
19    if jobs == 0 {
20        return Err("fingerprint jobs must be at least 1.".into());
21    }
22    // Tokio's semaphore has a platform-sized permit ceiling; external input must not panic.
23    if jobs > tokio::sync::Semaphore::MAX_PERMITS {
24        return Err(format!(
25            "fingerprint jobs must be at most {}.",
26            tokio::sync::Semaphore::MAX_PERMITS
27        ));
28    }
29    Ok(crate::cache::Parallelism::new(jobs))
30}