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,
no_deps: bool,
locked: bool,
progress: &dyn Fn(String),
) -> Result<(Metadata, Option<Error>)>
pub fn fetch_metadata( cargo_toml: &ManifestPath, current_dir: &AbsPath, config: &CargoMetadataConfig, sysroot: &Sysroot, no_deps: bool, 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.
The sysroot is used to set the RUSTUP_TOOLCHAIN env var when invoking cargo
to ensure that the rustup proxy uses the correct toolchain.
pub fn new( meta: Metadata, ws_manifest_path: ManifestPath, cargo_config_env: Env, is_sysroot: bool, ) -> 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
pub fn is_sysroot(&self) -> bool
Trait Implementations§
Source§impl Clone for CargoWorkspace
impl Clone for CargoWorkspace
Source§fn clone(&self) -> CargoWorkspace
fn clone(&self) -> CargoWorkspace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl Index<Idx<TargetData>> for CargoWorkspace
impl Index<Idx<TargetData>> for CargoWorkspace
Source§type Output = TargetData
type Output = TargetData
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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