pub struct CargoWorkspace { /* private fields */ }
Expand description
CargoWorkspace
represents the logical structure of, well, a Cargo
workspace. It pretty closely mirrors cargo metadata
output.
Note that internally, rust-analyzer uses a different structure:
CrateGraph
. CrateGraph
is lower-level: it knows only about the crates,
while this knows about Packages
& Targets
: purely cargo-related
concepts.
We use absolute paths here, cargo metadata
guarantees to always produce
abs paths.
Implementations§
Source§impl CargoWorkspace
impl CargoWorkspace
Sourcepub fn fetch_metadata(
cargo_toml: &ManifestPath,
current_dir: &AbsPath,
config: &CargoMetadataConfig,
sysroot: &Sysroot,
locked: bool,
progress: &dyn Fn(String),
) -> Result<(Metadata, Option<Error>)>
pub fn fetch_metadata( cargo_toml: &ManifestPath, current_dir: &AbsPath, config: &CargoMetadataConfig, sysroot: &Sysroot, locked: bool, progress: &dyn Fn(String), ) -> Result<(Metadata, Option<Error>)>
Fetches the metadata for the given cargo_toml
manifest.
A successful result may contain another metadata error if the initial fetching failed but
the --no-deps
retry succeeded.
pub fn new( meta: Metadata, ws_manifest_path: ManifestPath, cargo_config_env: Env, ) -> CargoWorkspace
pub fn packages(&self) -> impl ExactSizeIterator<Item = Package> + '_
pub fn target_by_root(&self, root: &AbsPath) -> Option<Target>
pub fn workspace_root(&self) -> &AbsPath
pub fn manifest_path(&self) -> &ManifestPath
pub fn target_directory(&self) -> &AbsPath
pub fn package_flag(&self, package: &PackageData) -> String
pub fn parent_manifests( &self, manifest_path: &ManifestPath, ) -> Option<Vec<ManifestPath>>
Sourcepub fn workspace_features(&self) -> FxHashSet<String>
pub fn workspace_features(&self) -> FxHashSet<String>
Returns the union of the features of all member crates in this workspace.
pub fn is_virtual_workspace(&self) -> bool
pub fn env(&self) -> &Env
Trait Implementations§
Source§impl Clone for CargoWorkspace
impl Clone for CargoWorkspace
Source§fn clone(&self) -> CargoWorkspace
fn clone(&self) -> CargoWorkspace
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CargoWorkspace
impl Debug for CargoWorkspace
Source§impl Index<Idx<PackageData>> for CargoWorkspace
impl Index<Idx<PackageData>> for CargoWorkspace
Source§type Output = PackageData
type Output = PackageData
The returned type after indexing.
Source§impl Index<Idx<TargetData>> for CargoWorkspace
impl Index<Idx<TargetData>> for CargoWorkspace
Source§type Output = TargetData
type Output = TargetData
The returned type after indexing.
Source§impl PartialEq for CargoWorkspace
impl PartialEq for CargoWorkspace
impl Eq for CargoWorkspace
impl StructuralPartialEq for CargoWorkspace
Auto Trait Implementations§
impl Freeze for CargoWorkspace
impl RefUnwindSafe for CargoWorkspace
impl Send for CargoWorkspace
impl Sync for CargoWorkspace
impl Unpin for CargoWorkspace
impl UnwindSafe for CargoWorkspace
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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