Struct guppy::graph::PackageMetadata
source · 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
pub fn direct_links_directed( &self, direction: DependencyDirection, ) -> impl Iterator<Item = PackageLink<'g>> + '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
pub fn direct_links(&self) -> impl Iterator<Item = PackageLink<'g>> + 'g
Returns PackageLink
instances corresponding to the direct dependencies for this package.
sourcepub fn reverse_direct_links(&self) -> impl Iterator<Item = PackageLink<'g>> + 'g
pub fn reverse_direct_links(&self) -> impl Iterator<Item = PackageLink<'g>> + '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
: fromself
toother
Reverse
: fromother
toself
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>>
pub fn build_targets(&self) -> impl Iterator<Item = BuildTarget<'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
pub fn named_features(&self) -> impl Iterator<Item = &'g str> + '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<'g> Debug for PackageMetadata<'g>
impl<'g> Debug for PackageMetadata<'g>
source§impl<'g> PartialEq for PackageMetadata<'g>
impl<'g> PartialEq for PackageMetadata<'g>
PackageMetadata
’s PartialEq
implementation uses pointer equality for the PackageGraph
.
impl<'g> Copy for PackageMetadata<'g>
impl<'g> Eq for PackageMetadata<'g>
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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
§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.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