pub struct CargoProject {
pub name: String,
pub version: String,
pub manifest_path: PathBuf,
pub package_dir: PathBuf,
pub workspace_root: PathBuf,
pub binaries: Vec<CargoBinary>,
pub default_binary: String,
}Expand description
Cargo project metadata, discovered via cargo metadata --no-deps.
This is the primary domain entity for Rust project management. All fields are resolved by Cargo itself, ensuring accuracy even for workspace members with inherited fields.
§Construction
Use CargoProject::discover() to create instances from real Cargo
projects. Direct struct construction is available for testing but
callers must ensure default_binary exists in binaries.
§Examples
use propel_core::CargoProject;
use std::path::Path;
let project = CargoProject::discover(Path::new(".")).unwrap();
println!("Deploying {} v{}", project.name, project.version);
println!("Binary: {}", project.default_binary);Fields§
§name: StringPackage name from [package].name
version: StringResolved version (handles version.workspace = true)
manifest_path: PathBufAbsolute path to the package’s Cargo.toml
package_dir: PathBufAbsolute path to the package directory (parent of manifest_path)
workspace_root: PathBufAbsolute path to the workspace root directory
binaries: Vec<CargoBinary>All binary targets in this package
default_binary: StringThe binary selected for deployment.
Invariant: must match a name in binaries.
Implementations§
Source§impl CargoProject
impl CargoProject
Sourcepub fn discover(project_dir: &Path) -> Result<Self>
pub fn discover(project_dir: &Path) -> Result<Self>
Discover the Cargo project at the given directory.
Runs cargo metadata --no-deps and locates the package whose
manifest lives in project_dir. For single-package projects this
is the only package; for workspaces the matching member is selected.
§Errors
crate::Error::CargoMetadataifcargo metadatafails (e.g. cargo not installed)crate::Error::NoPackageInDirifproject_diris a workspace root without[package]crate::Error::NoBinaryTargetif the package has no binary targetscrate::Error::MultipleBinariesif multiple binaries exist and none is selected
Trait Implementations§
Source§impl Clone for CargoProject
impl Clone for CargoProject
Source§fn clone(&self) -> CargoProject
fn clone(&self) -> CargoProject
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more