use crate::list_envelope::{ListEnvelope, Reason, Total, Unit};
pub const GLOB_LIST_ID: &str = "payload.files";
pub const GLOB_UNIT: Unit = Unit::Files;
pub const GLOB_NARROW: &[&str] = &["path"];
pub const DEFAULT_MAX_RESULTS: usize = 100;
pub const MAX_DISPLAY_FILES_PER_DIRECTORY: usize = 5;
pub const MAX_DISPLAY_DIRECTORIES: usize = 6;
pub fn build_glob_envelope(
shown: usize,
total: usize,
executor_capped: bool,
walk_truncated: bool,
skipped_foreign_mounts: usize,
) -> Option<ListEnvelope> {
let mut causes = Vec::new();
let has_walk = walk_truncated || skipped_foreign_mounts > 0;
if has_walk {
causes.push(Reason::Walk);
}
let has_cap = executor_capped || shown < total;
if has_cap {
causes.push(Reason::Cap);
}
if causes.is_empty() {
return None;
}
let total_bound = if has_walk || executor_capped {
Total::AtLeast(total)
} else {
Total::Exact(total)
};
Some(ListEnvelope::new(
shown,
total_bound,
GLOB_UNIT,
causes,
GLOB_NARROW,
))
}