Struct guppy::graph::feature::FeatureGraph

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

A derived graph representing every feature of every package.

Constructed through PackageGraph::feature_graph.

Implementations§

source§

impl<'g> FeatureGraph<'g>

source

pub fn build_warnings(&self) -> &'g [FeatureGraphWarning]

Returns any non-fatal warnings encountered while constructing the feature graph.

source

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

Returns the PackageGraph from which this feature graph was constructed.

source

pub fn feature_count(&self) -> usize

Returns the total number of (package ID, feature) combinations in this graph.

Includes the “base” feature for each package.

Returns the number of links in this graph.

source

pub fn contains(&self, feature_id: impl Into<FeatureId<'g>>) -> bool

Returns true if this feature graph contains the specified feature.

source

pub fn metadata( &self, feature_id: impl Into<FeatureId<'g>>, ) -> Result<FeatureMetadata<'g>, Error>

Returns metadata for the given feature ID, or None if the feature wasn’t found.

source

pub fn all_features_for( &self, package_id: &PackageId, ) -> Result<FeatureList<'g>, Error>

Returns all known features for a package.

Returns an error if the package ID was unknown.

source

pub fn is_default_feature<'a>( &self, feature_id: impl Into<FeatureId<'a>>, ) -> Result<bool, Error>

Returns true if this feature is included in a package’s build by default.

Returns an error if this feature ID is unknown.

§Cycles

A cyclic dev-dependency may cause additional features to be turned on. This computation does not follow conditional links and will not return true for such additional features.

source

pub fn depends_on<'a>( &self, feature_a: impl Into<FeatureId<'a>>, feature_b: impl Into<FeatureId<'a>>, ) -> Result<bool, Error>

Returns true if feature_a depends (directly or indirectly) on feature_b.

In other words, this returns true if feature_b is a (possibly transitive) dependency of feature_a.

This also returns true if feature_a is the same as feature_b.

Note that this returns true if feature_a conditionally depends on feature_b.

source

pub fn directly_depends_on<'a>( &self, feature_a: impl Into<FeatureId<'a>>, feature_b: impl Into<FeatureId<'a>>, ) -> Result<bool, Error>

Returns true if feature_a directly depends on feature_b.

In other words, this returns true if feature_a is a direct dependency of feature_b.

This returns false if feature_a is the same as feature_b.

source

pub fn cycles(&self) -> Cycles<'g>

Returns information about dependency cycles.

For more information, see the documentation for Cycles.

source§

impl<'g> FeatureGraph<'g>

§Queries

The methods in this section create queries over subsets of this feature graph. Use the methods here to analyze transitive dependencies.

source

pub fn query_workspace( &self, filter: impl FeatureFilter<'g>, ) -> FeatureQuery<'g>

Creates a new query over the entire workspace.

query_workspace will select all workspace packages (subject to the provided filter) and their transitive dependencies.

source

pub fn query_directed<'a>( &self, feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>, dep_direction: DependencyDirection, ) -> Result<FeatureQuery<'g>, Error>

Creates a new query that returns transitive dependencies of the given feature IDs in the specified direction.

Returns an error if any feature IDs are unknown.

source

pub fn query_forward<'a>( &self, feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>, ) -> Result<FeatureQuery<'g>, Error>

Creates a new query that returns transitive dependencies of the given feature IDs.

Returns an error if any feature IDs are unknown.

source

pub fn query_reverse<'a>( &self, feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>, ) -> Result<FeatureQuery<'g>, Error>

Creates a new query that returns transitive reverse dependencies of the given feature IDs.

Returns an error if any feature IDs are unknown.

source§

impl<'g> FeatureGraph<'g>

source

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

Creates a new FeatureSet consisting of all members of this feature graph.

This will include features that aren’t depended on by any workspace packages.

In most situations, query_workspace().resolve() is preferred. Use resolve_all if you know you need parts of the graph that aren’t accessible from the workspace.

source

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

Creates a new, empty FeatureSet associated with this feature graph.

source

pub fn resolve_ids<'a>( &self, feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>, ) -> Result<FeatureSet<'g>, Error>

Creates a new FeatureSet consisting of the specified feature IDs.

Returns an error if any feature IDs are unknown.

Trait Implementations§

source§

impl<'g> Clone for FeatureGraph<'g>

source§

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

source§

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

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

impl<'g> Copy for FeatureGraph<'g>

Auto Trait Implementations§

§

impl<'g> Freeze for FeatureGraph<'g>

§

impl<'g> RefUnwindSafe for FeatureGraph<'g>

§

impl<'g> Send for FeatureGraph<'g>

§

impl<'g> Sync for FeatureGraph<'g>

§

impl<'g> Unpin for FeatureGraph<'g>

§

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