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>

source

pub fn id(&self) -> &'g PackageId

Returns the unique identifier for this package.

source

pub fn graph(&self) -> &'g PackageGraph

Returns the package graph this PackageMetadata is derived from.

source

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.

source

pub fn to_package_set(&self) -> PackageSet<'g>

Creates a PackageSet consisting of just this package.

source

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.

Returns PackageLink instances corresponding to the direct dependencies for this package in the specified direction.

Returns PackageLink instances corresponding to the direct dependencies for this package.

Returns PackageLink instances corresponding to the packages that directly depend on this one.

Returns the direct PackageLink between self and other in the specified direction:

  • Forward: from self to other
  • Reverse: from other to self

Returns None if the direct link does not exist, or an error if to isn’t found in self.graph().

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().

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().

source

pub fn name(&self) -> &'g str

Returns the name of this package.

This is the same as the name field of Cargo.toml.

source

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.

source

pub fn authors(&self) -> &'g [String]

Returns the authors of this package.

This is the same as the authors field of Cargo.toml.

source

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.

source

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.

source

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.

source

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.

source

pub fn in_workspace(&self) -> bool

Returns true if this package is in the workspace.

For more detailed information, use source().

source

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.

source

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.

source

pub fn keywords(&self) -> &'g [String]

Returns keywords for this package.

This is the same as the keywords field of Cargo.toml.

source

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()).

source

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.

source

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.

source

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.

source

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.

source

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.

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.

source

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.

source

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.

source

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.

source

pub fn rust_version(&self) -> Option<&'g VersionReq>

👎Deprecated since 0.17.1: use Self::rust_version instead, it returns a Version

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.

source

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.

source

pub fn build_target(&self, id: &BuildTargetId<'_>) -> Option<BuildTarget<'g>>

Looks up a build target by identifier.

source

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.

source

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.

source

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.

source

pub fn default_feature_id(&self) -> FeatureId<'g>

Returns the FeatureId corresponding to the default feature.

source

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>

source§

fn clone(&self) -> PackageMetadata<'g>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'g> Debug for PackageMetadata<'g>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'g> PartialEq for PackageMetadata<'g>

PackageMetadata’s PartialEq implementation uses pointer equality for the PackageGraph.

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'g> Copy for PackageMetadata<'g>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.