Struct Projects

Source
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

Source

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);
Source

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 user
  • Err(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
Source

pub fn len(&self) -> usize

Get the number of projects in the collection.

§Returns

The number of projects contained in this collection.

§Examples
println!("Found {} projects", projects.len());
Source

pub fn is_empty(&self) -> bool

Check if the collection is empty.

§Returns

true if the collection contains no projects, false otherwise.

§Examples
if projects.is_empty() {
    println!("No projects found");
}
Source

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 from get_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

Source§

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 of Project 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

Source§

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§

type Iter = Iter<'a, Project>

The parallel iterator type that will be created.
Source§

type Item = &'a Project

The type of item that the parallel iterator will produce.
Source§

impl IntoParallelIterator for Projects

Source§

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();
Source§

type Iter = IntoIter<Project>

The parallel iterator type that will be created.
Source§

type Item = Project

The type of item that the parallel iterator will produce.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

Source§

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
Source§

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
Source§

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.