pub struct Workspace<'g> { /* private fields */ }Expand description
Information about a workspace, parsed from metadata returned by cargo metadata.
For more about workspaces, see Cargo Workspaces in The Rust Programming Language.
Implementations§
Source§impl<'g> Workspace<'g>
impl<'g> Workspace<'g>
Sourcepub fn target_directory(&self) -> &'g Utf8Path
pub fn target_directory(&self) -> &'g Utf8Path
Returns the target directory in which output artifacts are stored.
Sourcepub fn member_count(&self) -> usize
pub fn member_count(&self) -> usize
Returns the number of packages in this workspace.
Sourcepub fn contains_name(&self, name: impl AsRef<str>) -> bool
pub fn contains_name(&self, name: impl AsRef<str>) -> bool
Returns true if the workspace contains a package by the given name.
Sourcepub fn contains_path(&self, path: impl AsRef<Utf8Path>) -> bool
pub fn contains_path(&self, path: impl AsRef<Utf8Path>) -> bool
Returns true if the workspace contains a package by the given workspace path.
Sourcepub fn iter(
&self,
) -> impl ExactSizeIterator<Item = PackageMetadata<'g>> + use<'g>
pub fn iter( &self, ) -> impl ExactSizeIterator<Item = PackageMetadata<'g>> + use<'g>
Returns an iterator over package metadatas, sorted by the path they’re in.
Sourcepub fn iter_by_path(
&self,
) -> impl ExactSizeIterator<Item = (&'g Utf8Path, PackageMetadata<'g>)> + use<'g>
pub fn iter_by_path( &self, ) -> impl ExactSizeIterator<Item = (&'g Utf8Path, PackageMetadata<'g>)> + use<'g>
Returns an iterator over workspace paths and package metadatas, sorted by the path they’re in.
Sourcepub fn iter_by_name(
&self,
) -> impl ExactSizeIterator<Item = (&'g str, PackageMetadata<'g>)> + use<'g>
pub fn iter_by_name( &self, ) -> impl ExactSizeIterator<Item = (&'g str, PackageMetadata<'g>)> + use<'g>
Returns an iterator over workspace names and package metadatas, sorted by names.
Sourcepub fn member_ids(
&self,
) -> impl ExactSizeIterator<Item = &'g PackageId> + use<'g>
pub fn member_ids( &self, ) -> impl ExactSizeIterator<Item = &'g PackageId> + use<'g>
Returns an iterator over package IDs for workspace members. The package IDs will be returned
in the same order as members, sorted by the path they’re in.
Sourcepub fn member_by_path(
&self,
path: impl AsRef<Utf8Path>,
) -> Result<PackageMetadata<'g>, Error>
pub fn member_by_path( &self, path: impl AsRef<Utf8Path>, ) -> Result<PackageMetadata<'g>, Error>
Maps the given path to the corresponding workspace member.
Returns an error if the path didn’t match any workspace members.
Sourcepub fn members_by_paths<B>(
&self,
paths: impl IntoIterator<Item = impl AsRef<Utf8Path>>,
) -> Result<B, Error>where
B: FromIterator<PackageMetadata<'g>>,
pub fn members_by_paths<B>(
&self,
paths: impl IntoIterator<Item = impl AsRef<Utf8Path>>,
) -> Result<B, Error>where
B: FromIterator<PackageMetadata<'g>>,
Maps the given paths to their corresponding workspace members, returning a new value of
the specified collection type (e.g. Vec).
Returns an error if any of the paths were unknown.
Sourcepub fn member_by_name(
&self,
name: impl AsRef<str>,
) -> Result<PackageMetadata<'g>, Error>
pub fn member_by_name( &self, name: impl AsRef<str>, ) -> Result<PackageMetadata<'g>, Error>
Maps the given name to the corresponding workspace member.
Returns an error if the name didn’t match any workspace members.
Sourcepub fn members_by_names<B>(
&self,
names: impl IntoIterator<Item = impl AsRef<str>>,
) -> Result<B, Error>where
B: FromIterator<PackageMetadata<'g>>,
pub fn members_by_names<B>(
&self,
names: impl IntoIterator<Item = impl AsRef<str>>,
) -> Result<B, Error>where
B: FromIterator<PackageMetadata<'g>>,
Maps the given names to their corresponding workspace members, returning a new value of
the specified collection type (e.g. Vec).
Returns an error if any of the paths were unknown.
Sourcepub fn metadata_table(&self) -> &'g JsonValue
pub fn metadata_table(&self) -> &'g JsonValue
Returns the freeform metadata table for this workspace.
This is the same as the workspace.metadata section of Cargo.toml. This section is
typically used by tools which would like to store workspace configuration in Cargo.toml.
Trait Implementations§
Auto Trait Implementations§
impl<'g> Freeze for Workspace<'g>
impl<'g> RefUnwindSafe for Workspace<'g>
impl<'g> Send for Workspace<'g>
impl<'g> Sync for Workspace<'g>
impl<'g> Unpin for Workspace<'g>
impl<'g> UnwindSafe for Workspace<'g>
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