pub struct CargoLayout { /* private fields */ }Expand description
The recognised Cargo packages in a scanned tree.
Implementations§
Source§impl CargoLayout
impl CargoLayout
Sourcepub fn from_manifests(manifests: &[PathBuf]) -> Self
pub fn from_manifests(manifests: &[PathBuf]) -> Self
Build a layout from a set of Cargo.toml paths.
Manifests without a [package] section (pure [workspace] roots) or
that fail to parse are skipped; a malformed manifest never aborts
discovery.
Sourcepub fn packages(&self) -> Vec<PackageInfo>
pub fn packages(&self) -> Vec<PackageInfo>
The recognised packages, ordered by name.
Sourcepub fn classify(&self, absolute_path: &Path) -> (Option<String>, TargetKind)
pub fn classify(&self, absolute_path: &Path) -> (Option<String>, TargetKind)
Attribute an absolute file path to its package name and target kind.
Files outside every recognised package resolve to
(None, TargetKind::Unknown).
Sourcepub fn crate_name(&self, absolute_path: &Path) -> Option<String>
pub fn crate_name(&self, absolute_path: &Path) -> Option<String>
The name a compiler knows absolute_path’s crate by, when the layout
says which crate that is.
A compiler names a crate after the target, not the package: one package is a library, some binaries and a test crate per test file, and asking about a file under the wrong one gets an answer about somebody else’s code. Dashes become underscores because that mapping is the compiler’s — a crate name is an identifier and a package name need not be — rather than a guess about spelling.
None where the layout does not settle it: a file under tests/ that
is not a target’s own entry point is a module of one of them, and which
one is written in the code rather than in the manifest. Asking under a
guessed crate would produce an answer about a crate the file is not in,
which is worse than reporting that nobody asked.
Trait Implementations§
Source§impl Clone for CargoLayout
impl Clone for CargoLayout
Source§fn clone(&self) -> CargoLayout
fn clone(&self) -> CargoLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more