pub struct Projects(/* private fields */);
Expand description
A collection of development projects with associated operations.
The Projects
struct wraps a vector of Project
instances and provides
higher-level operations such as interactive selection, summary reporting,
and parallel processing support. It serves as the main data structure
for managing collections of projects throughout the application.
Implementations§
Source§impl Projects
impl Projects
Sourcepub fn get_total_size(&self) -> u64
pub fn get_total_size(&self) -> u64
Calculate the total size of all build directories in the collection.
This method sums up the sizes of all build directories (target/ or
node_modules
/) across all projects in the collection to provide a
total estimate of reclaimable disk space.
§Returns
The total size in bytes of all build directories combined.
§Examples
let total_bytes = projects.get_total_size();
println!("Total reclaimable space: {} bytes", total_bytes);
Sourcepub fn interactive_selection(&self) -> Result<Vec<Project>>
pub fn interactive_selection(&self) -> Result<Vec<Project>>
Present an interactive selection interface for choosing projects to clean.
This method displays a multi-select dialog that allows users to choose which projects they want to clean. Each project is shown with its type icon, path, and reclaimable space. All projects are selected by default.
§Returns
Ok(Vec<Project>)
- The projects selected by the userErr(anyhow::Error)
- If the interactive dialog fails or is canceled
§Interface Details
- Uses a colorful theme for better visual appeal
- Shows project type icons (🦀 for Rust, 📦 for Node.js, 🐍 for Python, 🐹 for Go)
- Displays project paths and sizes in human-readable format
- Allows toggling selections with space bar
- Confirms selection with the Enter key
§Examples
let selected_projects = projects.interactive_selection()?;
println!("User selected {} projects", selected_projects.len());
§Errors
This method can fail if:
- The terminal doesn’t support interactive input
- The user cancels the dialog (Ctrl+C)
- There are I/O errors with the terminal
Sourcepub fn print_summary(&self, total_size: u64)
pub fn print_summary(&self, total_size: u64)
Print a detailed summary of the projects and their reclaimable space.
This method analyzes the collection and prints statistics including:
- Number and total size of Rust projects
- Number and total size of Node.js projects
- Number and total size of Python projects
- Number and total size of Go projects
- Total reclaimable space across all projects
The output is formatted with colors and emoji icons for better readability.
§Arguments
total_size
- The total size in bytes (usually fromget_total_size()
)
§Examples
let total_size = projects.get_total_size();
projects.print_summary(total_size);
§Output Format
🦀 5 Rust projects (2.3 GB)
📦 3 Node.js projects (1.7 GB)
🐍 2 Python projects (1.2 GB)
🐹 1 Go project (0.5 GB)
💾 Total reclaimable space: 4.0 GB
Trait Implementations§
Source§impl From<Vec<Project>> for Projects
impl From<Vec<Project>> for Projects
Source§fn from(projects: Vec<Project>) -> Self
fn from(projects: Vec<Project>) -> Self
Create a Projects
collection from a vector of projects.
This conversion allows easy creation of a Projects
instance from
any vector of Project
objects, typically used when the scanner
returns a collection of detected projects.
§Arguments
projects
- A vector ofProject
instances
§Returns
A new Projects
collection containing the provided projects.
§Examples
let project_vec = vec![/* project instances */];
let projects: Projects = project_vec.into();
Source§impl<'a> IntoParallelIterator for &'a Projects
impl<'a> IntoParallelIterator for &'a Projects
Source§fn into_par_iter(self) -> Self::Iter
fn into_par_iter(self) -> Self::Iter
Enable parallel iteration over project references.
This implementation allows the collection to be processed in parallel using Rayon’s parallel iterators, which can significantly improve performance for operations that can be parallelized.
§Returns
A parallel iterator over references to the projects in the collection.
§Examples
projects.into_par_iter().for_each(|project| {
// Process each project in parallel
println!("Processing: {}", project.root_path.display());
});
Source§impl IntoParallelIterator for Projects
impl IntoParallelIterator for Projects
Source§fn into_par_iter(self) -> Self::Iter
fn into_par_iter(self) -> Self::Iter
Enable parallel iteration with ownership transfer.
This implementation allows the collection to be consumed and processed in parallel, transferring ownership of each project to the parallel processing context.
§Returns
A parallel iterator that takes ownership of the projects in the collection.
§Examples
let results: Vec<_> = projects.into_par_iter().map(|project| {
// Transform each project in parallel
process_project(project)
}).collect();
Auto Trait Implementations§
impl Freeze for Projects
impl RefUnwindSafe for Projects
impl Send for Projects
impl Sync for Projects
impl Unpin for Projects
impl UnwindSafe for Projects
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more