Expand description
Counted filesystem probe funnel, shared by every ecosystem crate’s config-file cache.
crate::mtime_cache::MtimeFileCache claims “one stat, zero reads on a cache hit” — a
claim Arc::ptr_eq on the returned value cannot verify, since that only proves the
parsed value was reused, not that no syscall ran to get there. Counting actual
stat/read calls needs a single chokepoint every cache implementation routes through,
so the count is trustworthy across crate boundaries.
Most wrappers below are a bare passthrough to their std::fs equivalent in a shipped
build (the exception is read_to_string_capped, which adds a real size bound on top of
File::open/Read::take); the counters are compiled out entirely unless this crate is
built for its own tests or with the test-util feature, so counting one function’s calls
costs nothing in production. cfg(test) alone cannot gate the public snapshot function,
because
deps-core is an ordinary (non-dev) dependency of deps-cargo/deps-npm — it is never
compiled with cfg(test) when a downstream crate’s own tests build, so the test-util
feature is what those crates enable in their dev-dependencies instead.
Constants§
- MAX_
CONFIG_ ANCESTOR_ DEPTH - Shared upper bound on how many ancestor directories a config-file discovery walk climbs, independent of whether the filesystem root has been reached.
Functions§
- exists
- Whether
pathexists —falseon any error, including a missing path. - is_file
- Whether
pathexists and is a regular file —falseon any error, including a missing path. - metadata
- Counted wrapper around
std::fs::metadata. - read_
to_ string_ capped - Counted, size-bounded wrapper around
std::fs::File::open+Read::take. - snapshot
- The current
(stat_count, read_count)totals.