pub struct PackageMetadata<'g> { /* private fields */ }Expand description
Information about a specific package in a PackageGraph.
Most of the metadata is extracted from Cargo.toml files. See
the Cargo.toml reference for more
details.
Implementations§
Source§impl<'g> PackageMetadata<'g>
impl<'g> PackageMetadata<'g>
Sourcepub fn graph(&self) -> &'g PackageGraph
pub fn graph(&self) -> &'g PackageGraph
Returns the package graph this PackageMetadata is derived from.
Sourcepub fn to_package_query(
&self,
direction: DependencyDirection,
) -> PackageQuery<'g>
pub fn to_package_query( &self, direction: DependencyDirection, ) -> PackageQuery<'g>
Creates a PackageQuery consisting of this package, in the given direction.
The PackageQuery can be used to inspect dependencies in this graph.
Sourcepub fn to_package_set(&self) -> PackageSet<'g>
pub fn to_package_set(&self) -> PackageSet<'g>
Creates a PackageSet consisting of just this package.
Sourcepub fn to_feature_set(&self, features: impl FeatureFilter<'g>) -> FeatureSet<'g>
pub fn to_feature_set(&self, features: impl FeatureFilter<'g>) -> FeatureSet<'g>
Creates a FeatureSet that consists of all features in the package that match the given
named filter.
Sourcepub fn direct_links_directed(
&self,
direction: DependencyDirection,
) -> impl Iterator<Item = PackageLink<'g>> + 'g + use<'g>
pub fn direct_links_directed( &self, direction: DependencyDirection, ) -> impl Iterator<Item = PackageLink<'g>> + 'g + use<'g>
Returns PackageLink instances corresponding to the direct dependencies for this package in
the specified direction.
Sourcepub fn direct_links(
&self,
) -> impl Iterator<Item = PackageLink<'g>> + 'g + use<'g>
pub fn direct_links( &self, ) -> impl Iterator<Item = PackageLink<'g>> + 'g + use<'g>
Returns PackageLink instances corresponding to the direct dependencies for this package.
Sourcepub fn reverse_direct_links(
&self,
) -> impl Iterator<Item = PackageLink<'g>> + 'g + use<'g>
pub fn reverse_direct_links( &self, ) -> impl Iterator<Item = PackageLink<'g>> + 'g + use<'g>
Returns PackageLink instances corresponding to the packages that directly depend on this
one.
Sourcepub fn link_between(
&self,
other: &PackageId,
direction: DependencyDirection,
) -> Result<Option<PackageLink<'g>>, Error>
pub fn link_between( &self, other: &PackageId, direction: DependencyDirection, ) -> Result<Option<PackageLink<'g>>, Error>
Returns the direct PackageLink between self and other in the specified direction:
Forward: fromselftootherReverse: fromothertoself
Returns None if the direct link does not exist, or an error if to isn’t found in
self.graph().
Sourcepub fn link_to(&self, to: &PackageId) -> Result<Option<PackageLink<'g>>, Error>
pub fn link_to(&self, to: &PackageId) -> Result<Option<PackageLink<'g>>, Error>
Returns the direct PackageLink from self to the specified package, or None if self
does not directly depend on the specified package.
Returns an error if to isn’t found in self.graph().
Sourcepub fn link_from(
&self,
from: &PackageId,
) -> Result<Option<PackageLink<'g>>, Error>
pub fn link_from( &self, from: &PackageId, ) -> Result<Option<PackageLink<'g>>, Error>
Returns the direct PackageLink from the specified package to self, or None if the
specified package does not directly depend on self.
Returns an error if from isn’t found in self.graph().
Sourcepub fn name(&self) -> &'g str
pub fn name(&self) -> &'g str
Returns the name of this package.
This is the same as the name field of Cargo.toml.
Sourcepub fn version(&self) -> &'g Version
pub fn version(&self) -> &'g Version
Returns the version of this package as resolved by Cargo.
This is the same as the version field of Cargo.toml.
Returns the authors of this package.
This is the same as the authors field of Cargo.toml.
Sourcepub fn description(&self) -> Option<&'g str>
pub fn description(&self) -> Option<&'g str>
Returns a short description for this package.
This is the same as the description field of Cargo.toml.
Sourcepub fn license(&self) -> Option<&'g str>
pub fn license(&self) -> Option<&'g str>
Returns an SPDX 2.1 license expression for this package, if specified.
This is the same as the license field of Cargo.toml. Note that guppy does not perform
any validation on this, though crates.io does if a crate is uploaded there.
Sourcepub fn license_file(&self) -> Option<&'g Utf8Path>
pub fn license_file(&self) -> Option<&'g Utf8Path>
Returns the path to a license file for this package, if specified.
This is the same as the license_file field of Cargo.toml. It is typically only specified
for nonstandard licenses.
Sourcepub fn source(&self) -> PackageSource<'g>
pub fn source(&self) -> PackageSource<'g>
Returns the source from which this package was retrieved.
This may be the workspace path, an external path, or a registry like crates.io.
Sourcepub fn in_workspace(&self) -> bool
pub fn in_workspace(&self) -> bool
Returns true if this package is in the workspace.
For more detailed information, use source().
Sourcepub fn manifest_path(&self) -> &'g Utf8Path
pub fn manifest_path(&self) -> &'g Utf8Path
Returns the full path to the Cargo.toml for this package.
This is specific to the system that cargo metadata was run on.
Sourcepub fn categories(&self) -> &'g [String]
pub fn categories(&self) -> &'g [String]
Returns categories for this package.
This is the same as the categories field of Cargo.toml. For packages on crates.io,
returned values are guaranteed to be
valid category slugs.
Sourcepub fn keywords(&self) -> &'g [String]
pub fn keywords(&self) -> &'g [String]
Returns keywords for this package.
This is the same as the keywords field of Cargo.toml.
Sourcepub fn readme(&self) -> Option<&'g Utf8Path>
pub fn readme(&self) -> Option<&'g Utf8Path>
Returns a path to the README for this package, if specified.
This is the same as the readme field of Cargo.toml. The path returned is relative to the
directory the Cargo.toml is in (i.e. relative to the parent of self.manifest_path()).
Sourcepub fn repository(&self) -> Option<&'g str>
pub fn repository(&self) -> Option<&'g str>
Returns the source code repository for this package, if specified.
This is the same as the repository field of Cargo.toml.
Sourcepub fn homepage(&self) -> Option<&'g str>
pub fn homepage(&self) -> Option<&'g str>
Returns the homepage for this package, if specified.
This is the same as the homepage field of Cargo.toml.
Sourcepub fn documentation(&self) -> Option<&'g str>
pub fn documentation(&self) -> Option<&'g str>
Returns the documentation URL for this package, if specified.
This is the same as the homepage field of Cargo.toml.
Sourcepub fn edition(&self) -> &'g str
pub fn edition(&self) -> &'g str
Returns the Rust edition this package is written against.
This is the same as the edition field of Cargo.toml. It is "2015" by default.
Sourcepub fn metadata_table(&self) -> &'g JsonValue
pub fn metadata_table(&self) -> &'g JsonValue
Returns the freeform metadata table for this package.
This is the same as the package.metadata section of Cargo.toml. This section is
typically used by tools which would like to store package configuration in Cargo.toml.
Sourcepub fn links(&self) -> Option<&'g str>
pub fn links(&self) -> Option<&'g str>
Returns the name of a native library this package links to, if specified.
This is the same as the links field of Cargo.toml. See The links Manifest
Key in
the Cargo book for more details.
Sourcepub fn publish(&self) -> PackagePublish<'g>
pub fn publish(&self) -> PackagePublish<'g>
Returns the registries to which this package may be published.
This is derived from the publish field of Cargo.toml.
Sourcepub fn default_run(&self) -> Option<&'g str>
pub fn default_run(&self) -> Option<&'g str>
Returns the binary that is run by default, if specified.
Information about this binary can be queried using the build_target
method.
This is derived from the default-run field of Cargo.toml.
Sourcepub fn minimum_rust_version(&self) -> Option<&'g Version>
pub fn minimum_rust_version(&self) -> Option<&'g Version>
Returns the minimum Rust compiler version, which should be able to compile the package, if specified.
This is the same as the rust-version field of Cargo.toml. For more, see the
rust-version field
in the Cargo reference.
Sourcepub fn rust_version(&self) -> Option<&'g VersionReq>
👎Deprecated since 0.17.1: use Self::rust_version instead, it returns a Version
pub fn rust_version(&self) -> Option<&'g VersionReq>
Returns the minimum Rust compiler version, which should be able to compile the package, if specified.
Returned as a semver::VersionReq. This is actually not correct – it is deprecated and
will go away in the next major version of guppy: use Self::minimum_rust_version instead.
This is the same as the rust-version field of Cargo.toml. For more, see the
rust-version
field in
the Cargo reference.
Sourcepub fn build_targets(&self) -> impl Iterator<Item = BuildTarget<'g>> + use<'g>
pub fn build_targets(&self) -> impl Iterator<Item = BuildTarget<'g>> + use<'g>
Returns all the build targets for this package.
For more, see Cargo Targets in the Cargo reference.
Sourcepub fn build_target(&self, id: &BuildTargetId<'_>) -> Option<BuildTarget<'g>>
pub fn build_target(&self, id: &BuildTargetId<'_>) -> Option<BuildTarget<'g>>
Looks up a build target by identifier.
Sourcepub fn is_proc_macro(&self) -> bool
pub fn is_proc_macro(&self) -> bool
Returns true if this package is a procedural macro.
For more about procedural macros, see Procedural Macros in the Rust reference.
Sourcepub fn has_build_script(&self) -> bool
pub fn has_build_script(&self) -> bool
Returns true if this package has a build script.
Cargo only follows build dependencies if a build script is set.
For more about build scripts, see Build Scripts in the Cargo reference.
Sourcepub fn has_default_feature(&self) -> bool
pub fn has_default_feature(&self) -> bool
Returns true if this package has a named feature named default.
For more about default features, see The [features]
section in
the Cargo reference.
Sourcepub fn default_feature_id(&self) -> FeatureId<'g>
pub fn default_feature_id(&self) -> FeatureId<'g>
Returns the FeatureId corresponding to the default feature.
Sourcepub fn named_features(&self) -> impl Iterator<Item = &'g str> + 'g + use<'g>
pub fn named_features(&self) -> impl Iterator<Item = &'g str> + 'g + use<'g>
Returns the list of named features available for this package. This will include a feature named “default” if it is defined.
A named feature is listed in the [features] section of Cargo.toml. For more, see
the reference.
Trait Implementations§
Source§impl<'g> Clone for PackageMetadata<'g>
impl<'g> Clone for PackageMetadata<'g>
Source§fn clone(&self) -> PackageMetadata<'g>
fn clone(&self) -> PackageMetadata<'g>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PackageMetadata<'_>
impl Debug for PackageMetadata<'_>
Source§impl PartialEq for PackageMetadata<'_>
PackageMetadata’s PartialEq implementation uses pointer equality for the PackageGraph.
impl PartialEq for PackageMetadata<'_>
PackageMetadata’s PartialEq implementation uses pointer equality for the PackageGraph.
impl<'g> Copy for PackageMetadata<'g>
impl Eq for PackageMetadata<'_>
Auto Trait Implementations§
impl<'g> Freeze for PackageMetadata<'g>
impl<'g> RefUnwindSafe for PackageMetadata<'g>
impl<'g> Send for PackageMetadata<'g>
impl<'g> Sync for PackageMetadata<'g>
impl<'g> Unpin for PackageMetadata<'g>
impl<'g> UnwindSafe for PackageMetadata<'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,
§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
key and return true if they are equal.§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
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