pub struct Project {
pub kind: ProjectType,
pub root_path: PathBuf,
pub build_arts: BuildArtifacts,
pub name: Option<String>,
}
Expand description
Representation of a development project with cleanable build artifacts.
This struct encapsulates all information about a development project, including its type, location, build artifacts, and metadata extracted from project configuration files.
Fields§
§kind: ProjectType
Type of the project (Rust or Node.js)
root_path: PathBuf
The root directory of the project where the configuration file is located
For Rust projects, this is the directory containing Cargo.toml
.
For Node.js projects, this is the directory containing package.json
.
build_arts: BuildArtifacts
The build directory to be cleaned and its metadata
Contains information about the target/
or node_modules/
directory
that is a candidate for cleanup, including its path and total size.
name: Option<String>
Name of the project extracted from configuration files
For Rust projects, this is extracted from the name
field in Cargo.toml
.
For Node.js projects, this is extracted from the name
field in package.json
.
May be None
if the name cannot be determined or parsed.
Implementations§
Source§impl Project
impl Project
Sourcepub fn new(
kind: ProjectType,
root_path: PathBuf,
build_arts: BuildArtifacts,
name: Option<String>,
) -> Self
pub fn new( kind: ProjectType, root_path: PathBuf, build_arts: BuildArtifacts, name: Option<String>, ) -> Self
Create a new project instance.
This constructor creates a new Project
with the specified parameters.
It’s typically used by the scanner when a valid development project
is detected in the file system.
§Arguments
kind
- The type of project (Rust or Node.js)root_path
- Path to the project’s root directorybuild_arts
- Information about the build artifacts to be cleanedname
- Optional project name extracted from configuration files
§Returns
A new Project
instance with the specified parameters.
§Examples
let build_arts = BuildArtifacts {
path: PathBuf::from("/path/to/project/target"),
size: 1024,
};
let project = Project::new(
ProjectType::Rust,
PathBuf::from("/path/to/project"),
build_arts,
Some("my-project".to_string()),
);
Trait Implementations§
Source§impl Display for Project
impl Display for Project
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format the project for display with the appropriate emoji and name.
This implementation provides a human-readable representation of the project that includes:
- An emoji indicator based on the project type (🦀 for Rust, 📦 for Node.js, 🐍 for Python, 🐹 for Go)
- The project name if available, otherwise just the path
- The project’s root path
§Examples
🦀 my-rust-project (/path/to/project)
📦 my-node-app (/path/to/app)
🐍 my-python-project (/path/to/project)
🐹 my-go-project (/path/to/project)
🦀 /path/to/unnamed/project
(when no name is available)
Auto Trait Implementations§
impl Freeze for Project
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnwindSafe for Project
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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