Struct guppy::graph::cargo::CargoSet

source ·
pub struct CargoSet<'g> { /* private fields */ }
Expand description

A set of packages and features, as would be built by Cargo.

Cargo implements a set of algorithms to figure out which packages or features are built in a given situation. guppy implements those algorithms.

Implementations§

source§

impl<'g> CargoSet<'g>

source

pub fn new( initials: FeatureSet<'g>, features_only: FeatureSet<'g>, opts: &CargoOptions<'_>, ) -> Result<Self, Error>

Simulates a Cargo build of this feature set, with the given options.

The feature sets are expected to be entirely within the workspace. Its behavior outside the workspace isn’t defined and may be surprising.

CargoSet::new takes two FeatureSet instances:

  • initials, from which dependencies are followed to build the CargoSet.
  • features_only, which are additional inputs that are only used for feature unification. This may be used to simulate, e.g. cargo build --package foo --package bar, when you only care about the results of foo but specifying bar influences the build.

Note that even if a package is in features_only, it may be included in the final build set through other means (for example, if it is also in initials or it is a dependency of one of them).

In many cases features_only is empty – in that case you may wish to use FeatureSet::into_cargo_set(), and it may be more convenient to use that if the code is written in a “fluent” style.

source

pub fn feature_graph(&self) -> &FeatureGraph<'g>

Returns the feature graph for this CargoSet instance.

source

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

Returns the package graph for this CargoSet instance.

source

pub fn initials(&self) -> &FeatureSet<'g>

Returns the initial packages and features from which the CargoSet instance was constructed.

source

pub fn features_only(&self) -> &FeatureSet<'g>

Returns the packages and features that took part in feature unification but were not considered part of the final result.

For more about features_only and how it influences the build, see the documentation for CargoSet::new.

source

pub fn target_features(&self) -> &FeatureSet<'g>

Returns the feature set enabled on the target platform.

This represents the packages and features that are included as code in the final build artifacts. This is relevant for both cross-compilation and auditing.

source

pub fn host_features(&self) -> &FeatureSet<'g>

Returns the feature set enabled on the host platform.

This represents the packages and features that influence the final build artifacts, but whose code is generally not directly included.

This includes all procedural macros, including those specified in the initial query.

source

pub fn platform_features( &self, build_platform: BuildPlatform, ) -> &FeatureSet<'g>

Returns the feature set enabled on the specified build platform.

source

pub fn all_features(&self) -> [(BuildPlatform, &FeatureSet<'g>); 2]

Returns the feature sets across the target and host build platforms.

source

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

Returns the set of workspace and direct dependency packages on the target platform.

The packages in this set are a subset of the packages in target_features.

source

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

Returns the set of workspace and direct dependency packages on the host platform.

The packages in this set are a subset of the packages in host_features.

source

pub fn platform_direct_deps( &self, build_platform: BuildPlatform, ) -> &PackageSet<'g>

Returns the set of workspace and direct dependency packages on the specified build platform.

source

pub fn all_direct_deps(&self) -> [(BuildPlatform, &PackageSet<'g>); 2]

Returns the set of workspace and direct dependency packages across the target and host build platforms.

Returns PackageLink instances for procedural macro dependencies from target packages.

Procedural macros straddle the line between target and host: they’re built for the host but generate code that is compiled for the target platform.

§Notes

Procedural macro packages will be included in the host feature set.

The returned iterator will include proc macros that are depended on normally or in dev builds from initials (if include_dev is set), but not the ones in the [build-dependencies] section.

Returns PackageLink instances for build dependencies from target packages.

§Notes

For each link, the from is built on the target while the to is built on the host. It is possible (though rare) that a build dependency is also included as a normal dependency, or as a dev dependency in which case it will also be built on the target.

The returned iterators will not include build dependencies of host packages – those are also built on the host.

Trait Implementations§

source§

impl<'g> Clone for CargoSet<'g>

source§

fn clone(&self) -> CargoSet<'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 CargoSet<'g>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'g> Freeze for CargoSet<'g>

§

impl<'g> RefUnwindSafe for CargoSet<'g>

§

impl<'g> Send for CargoSet<'g>

§

impl<'g> Sync for CargoSet<'g>

§

impl<'g> Unpin for CargoSet<'g>

§

impl<'g> UnwindSafe for CargoSet<'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> 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.