pub struct FeatureGraph<'g> { /* private fields */ }
Expand description
A derived graph representing every feature of every package.
Constructed through PackageGraph::feature_graph
.
Implementations
sourceimpl<'g> FeatureGraph<'g>
impl<'g> FeatureGraph<'g>
sourcepub fn build_warnings(&self) -> &'g [FeatureGraphWarning]
pub fn build_warnings(&self) -> &'g [FeatureGraphWarning]
Returns any non-fatal warnings encountered while constructing the feature graph.
sourcepub fn package_graph(&self) -> &'g PackageGraph
pub fn package_graph(&self) -> &'g PackageGraph
Returns the PackageGraph
from which this feature graph was constructed.
sourcepub fn feature_count(&self) -> usize
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.
sourcepub fn link_count(&self) -> usize
pub fn link_count(&self) -> usize
Returns the number of links in this graph.
sourcepub fn contains(&self, feature_id: impl Into<FeatureId<'g>>) -> bool
pub fn contains(&self, feature_id: impl Into<FeatureId<'g>>) -> bool
Returns true if this feature graph contains the specified feature.
sourcepub fn metadata(
&self,
feature_id: impl Into<FeatureId<'g>>
) -> Result<FeatureMetadata<'g>, Error>
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.
sourcepub fn all_features_for(
&self,
package_id: &PackageId
) -> Result<FeatureList<'g>, Error>
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.
sourcepub fn is_default_feature<'a>(
&self,
feature_id: impl Into<FeatureId<'a>>
) -> Result<bool, Error>
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.
sourcepub fn depends_on<'a>(
&self,
feature_a: impl Into<FeatureId<'a>>,
feature_b: impl Into<FeatureId<'a>>
) -> Result<bool, Error>
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
.
sourcepub fn directly_depends_on<'a>(
&self,
feature_a: impl Into<FeatureId<'a>>,
feature_b: impl Into<FeatureId<'a>>
) -> Result<bool, Error>
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
.
sourceimpl<'g> FeatureGraph<'g>
impl<'g> FeatureGraph<'g>
Helpers for property testing
The methods in this section allow a FeatureGraph
to be used in property-based testing
scenarios.
Currently, proptest 1 is supported if the proptest1
feature is enabled.
sourcepub fn prop010_id_strategy(&self) -> impl Strategy<Value = FeatureId<'g>> + 'g
This is supported on crate feature proptest1
only.
pub fn prop010_id_strategy(&self) -> impl Strategy<Value = FeatureId<'g>> + 'g
proptest1
only.Returns a Strategy
that generates random feature IDs from this graph.
The IDs so chosen are uniformly random from the entire feature graph. In other words, a package with more optional features is more likely to be chosen.
Requires the proptest1
feature to be enabled.
Panics
Panics if there are no packages in the PackageGraph
from which this FeatureGraph
was
derived.
sourcepub fn prop010_set_strategy(&self) -> impl Strategy<Value = FeatureSet<'g>> + 'g
This is supported on crate feature proptest1
only.
pub fn prop010_set_strategy(&self) -> impl Strategy<Value = FeatureSet<'g>> + 'g
proptest1
only.Returns a Strategy
that generates random feature sets from this graph.
sourceimpl<'g> FeatureGraph<'g>
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.
sourcepub fn query_workspace(
&self,
filter: impl FeatureFilter<'g>
) -> FeatureQuery<'g>
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.
sourcepub fn query_directed<'a>(
&self,
feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>,
dep_direction: DependencyDirection
) -> Result<FeatureQuery<'g>, Error>
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.
sourcepub fn query_forward<'a>(
&self,
feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>
) -> Result<FeatureQuery<'g>, Error>
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.
sourcepub fn query_reverse<'a>(
&self,
feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>
) -> Result<FeatureQuery<'g>, Error>
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.
sourceimpl<'g> FeatureGraph<'g>
impl<'g> FeatureGraph<'g>
sourcepub fn resolve_all(&self) -> FeatureSet<'g>
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.
sourcepub fn resolve_none(&self) -> FeatureSet<'g>
pub fn resolve_none(&self) -> FeatureSet<'g>
Creates a new, empty FeatureSet
associated with this feature graph.
sourcepub fn resolve_ids<'a>(
&self,
feature_ids: impl IntoIterator<Item = impl Into<FeatureId<'a>>>
) -> Result<FeatureSet<'g>, Error>
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
sourceimpl<'g> Clone for FeatureGraph<'g>
impl<'g> Clone for FeatureGraph<'g>
sourcefn clone(&self) -> FeatureGraph<'g>
fn clone(&self) -> FeatureGraph<'g>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'g> Debug for FeatureGraph<'g>
impl<'g> Debug for FeatureGraph<'g>
impl<'g> Copy for FeatureGraph<'g>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more