Skip to main content

Module projects

Module projects 

Source
Expand description

Locate build-tool artifact directories across many project types and tell you how much disk space they waste — optionally deleting them.

A project is any directory containing a recognized marker file (Cargo.toml, package.json, pom.xml, …). Each project has one or more ProjectTypes, and each type maps to a set of artifact directories (target, node_modules, build, …) that are safe to delete because the toolchain will regenerate them.

A single directory may match several project types at once: a Rust + web project with both Cargo.toml and package.json is {Cargo, Node}, and Project::artifact_dirs yields the union of their artifact directories (target + node_modules).

This module performs no destructive actions on its own — you must call Project::clean explicitly to delete anything.

§Example

use disk_cleaner::projects::{scan, ScanOptions};

let opts = ScanOptions { follow_symlinks: false, same_file_system: false };
for project in scan(&".", &opts).filter_map(Result::ok) {
    println!("{} [{}]", project.path.display(), project.type_name());
}

Structs§

Project
A discovered project: a directory on disk plus the set of project types detected within it.
ProjectAnalysis
A project plus the results of analyzing it, produced by analyze.
ProjectSize
A breakdown of a project directory’s disk usage, produced by Project::size_dirs.
ScanOptions
Options controlling directory traversal, passed to scan and dir_size.

Enums§

ProjectType
A recognized development-project ecosystem (Cargo, Node, Unity, …).
ScanError
Errors that can occur while scanning a directory tree for projects.

Functions§

analyze
Scan path for projects and compute each one’s reclaimable size and last modification time — a streaming convenience over scan + [project_size_and_mtime].
clean
Recursively delete every artifact directory of the project at project_path.
dir_size
Total size in bytes of all regular files beneath path (recursive), traversed with the same options as scan.
scan
Recursively scan path for projects, yielding each wrapped in a Result.