Struct guppy::graph::feature::FeatureSet
source · pub struct FeatureSet<'g> { /* private fields */ }
Expand description
A set of resolved feature IDs in a feature graph.
Created by FeatureQuery::resolve
, the FeatureGraph::resolve_
methods, or from
PackageSet::to_feature_set
.
Implementations§
source§impl<'g> FeatureSet<'g>
impl<'g> FeatureSet<'g>
sourcepub fn graph(&self) -> &FeatureGraph<'g>
pub fn graph(&self) -> &FeatureGraph<'g>
Returns the FeatureGraph
that this feature set was computed against.
sourcepub fn contains<'a>(
&self,
feature_id: impl Into<FeatureId<'a>>,
) -> Result<bool, Error>
pub fn contains<'a>( &self, feature_id: impl Into<FeatureId<'a>>, ) -> Result<bool, Error>
Returns true if this set contains the given feature ID.
Returns an error if this feature ID was unknown.
sourcepub fn contains_package(&self, package_id: &PackageId) -> Result<bool, Error>
pub fn contains_package(&self, package_id: &PackageId) -> Result<bool, Error>
Returns true if this set contains this package.
Returns an error if this package ID was unknown.
sourcepub fn to_feature_query(
&self,
direction: DependencyDirection,
) -> FeatureQuery<'g>
pub fn to_feature_query( &self, direction: DependencyDirection, ) -> FeatureQuery<'g>
Creates a new FeatureQuery
from this set in the specified direction.
This is equivalent to constructing a query from all the feature IDs in this set.
sourcepub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
Returns a FeatureSet
that contains all packages present in at least one of self
and other
.
§Panics
Panics if the package graphs associated with self
and other
don’t match.
sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
Returns a FeatureSet
that contains all packages present in both self
and other
.
§Panics
Panics if the package graphs associated with self
and other
don’t match.
sourcepub fn difference(&self, other: &Self) -> Self
pub fn difference(&self, other: &Self) -> Self
Returns a FeatureSet
that contains all packages present in self
but not other
.
§Panics
Panics if the package graphs associated with self
and other
don’t match.
sourcepub fn symmetric_difference(&self, other: &Self) -> Self
pub fn symmetric_difference(&self, other: &Self) -> Self
Returns a FeatureSet
that contains all packages present in exactly one of self
and
other
.
§Panics
Panics if the package graphs associated with self
and other
don’t match.
sourcepub fn filter(
&self,
direction: DependencyDirection,
callback: impl FnMut(FeatureMetadata<'g>) -> bool,
) -> Self
pub fn filter( &self, direction: DependencyDirection, callback: impl FnMut(FeatureMetadata<'g>) -> bool, ) -> Self
Returns a PackageSet
on which a filter has been applied.
Filters out all values for which the callback returns false.
§Cycles
For packages within a dependency cycle, the callback will be called in non-dev order. When the direction is forward, if package Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then Foo is returned before Bar.
sourcepub fn partition(
&self,
direction: DependencyDirection,
callback: impl FnMut(FeatureMetadata<'g>) -> bool,
) -> (Self, Self)
pub fn partition( &self, direction: DependencyDirection, callback: impl FnMut(FeatureMetadata<'g>) -> bool, ) -> (Self, Self)
Partitions this PackageSet
into two.
The first PackageSet
contains packages for which the callback returned true, and the
second one contains packages for which the callback returned false.
§Cycles
For packages within a dependency cycle, the callback will be called in non-dev order. When the direction is forward, if package Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then Foo is returned before Bar.
sourcepub fn filter_partition(
&self,
direction: DependencyDirection,
callback: impl FnMut(FeatureMetadata<'g>) -> Option<bool>,
) -> (Self, Self)
pub fn filter_partition( &self, direction: DependencyDirection, callback: impl FnMut(FeatureMetadata<'g>) -> Option<bool>, ) -> (Self, Self)
Performs filtering and partitioning at the same time.
The first PackageSet
contains packages for which the callback returned Some(true)
, and
the second one contains packages for which the callback returned Some(false)
. Packages
for which the callback returned None
are dropped.
§Cycles
For packages within a dependency cycle, the callback will be called in non-dev order. When the direction is forward, if package Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then Foo is returned before Bar.
sourcepub fn features_for(
&self,
package_id: &PackageId,
) -> Result<Option<FeatureList<'g>>, Error>
pub fn features_for( &self, package_id: &PackageId, ) -> Result<Option<FeatureList<'g>>, Error>
Returns a list of features present for this package, or None
if this package is not
present in the feature set.
Returns an error if the package ID was unknown.
sourcepub fn to_package_set(&self) -> PackageSet<'g>
pub fn to_package_set(&self) -> PackageSet<'g>
Converts this FeatureSet
into a PackageSet
containing all packages with any selected
features (including the “base” feature).
sourcepub fn into_cargo_set(
self,
opts: &CargoOptions<'_>,
) -> Result<CargoSet<'g>, Error>
pub fn into_cargo_set( self, opts: &CargoOptions<'_>, ) -> Result<CargoSet<'g>, Error>
Converts this feature set into a Cargo set, simulating a Cargo build for it.
The feature set is expected to be entirely within the workspace. Its behavior outside the workspace isn’t defined and may be surprising.
Returns an error if the CargoOptions
weren’t valid in some way (for example if an omitted
package ID wasn’t known to this graph.)
sourcepub fn feature_ids<'a>(
&'a self,
direction: DependencyDirection,
) -> impl ExactSizeIterator<Item = FeatureId<'g>> + 'a
pub fn feature_ids<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = FeatureId<'g>> + 'a
Iterates over feature IDs, in topological order in the direction specified.
§Cycles
The features within a dependency cycle will be returned in non-dev order. When the direction is forward, if feature Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then Foo is returned before Bar.
sourcepub fn features<'a>(
&'a self,
direction: DependencyDirection,
) -> impl ExactSizeIterator<Item = FeatureMetadata<'g>> + 'a
pub fn features<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = FeatureMetadata<'g>> + 'a
Iterates over feature metadatas, in topological order in the direction specified.
§Cycles
The features within a dependency cycle will be returned in non-dev order. When the direction is forward, if feature Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then Foo is returned before Bar.
sourcepub fn packages_with_features<'a>(
&'a self,
direction: DependencyDirection,
) -> impl Iterator<Item = FeatureList<'g>> + 'a
pub fn packages_with_features<'a>( &'a self, direction: DependencyDirection, ) -> impl Iterator<Item = FeatureList<'g>> + 'a
Iterates over package metadatas and their corresponding features, in topological order in the direction specified.
§Cycles
The packages within a dependency cycle will be returned in non-dev order. When the direction is forward, if package Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then Foo is returned before Bar.
sourcepub fn root_ids<'a>(
&'a self,
direction: DependencyDirection,
) -> impl ExactSizeIterator<Item = FeatureId<'g>> + 'a
pub fn root_ids<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = FeatureId<'g>> + 'a
Returns the set of “root feature” IDs in the specified direction.
- If direction is Forward, return the set of feature IDs that do not have any dependencies within the selected graph.
- If direction is Reverse, return the set of feature IDs that do not have any dependents within the selected graph.
§Cycles
If a root consists of a dependency cycle, all the packages in it will be returned in non-dev order (when the direction is forward).
sourcepub fn root_features<'a>(
&'a self,
direction: DependencyDirection,
) -> impl Iterator<Item = FeatureMetadata<'g>> + 'a
pub fn root_features<'a>( &'a self, direction: DependencyDirection, ) -> impl Iterator<Item = FeatureMetadata<'g>> + 'a
Returns the set of “root feature” metadatas in the specified direction.
- If direction is Forward, return the set of metadatas that do not have any dependencies within the selected graph.
- If direction is Reverse, return the set of metadatas that do not have any dependents within the selected graph.
§Cycles
If a root consists of a dependency cycle, all the packages in it will be returned in non-dev order (when the direction is forward).
sourcepub fn conditional_links<'a>(
&'a self,
direction: DependencyDirection,
) -> impl Iterator<Item = ConditionalLink<'g>> + 'a
pub fn conditional_links<'a>( &'a self, direction: DependencyDirection, ) -> impl Iterator<Item = ConditionalLink<'g>> + 'a
Creates an iterator over ConditionalLink
instances in the direction specified.
§Cycles
The links in a dependency cycle will be returned in non-dev order. When the direction is forward, if feature Foo has a dependency on Bar, and Bar has a cyclic dev-dependency on Foo, then the link Foo -> Bar is returned before the link Bar -> Foo.
Trait Implementations§
source§impl<'g> Clone for FeatureSet<'g>
impl<'g> Clone for FeatureSet<'g>
source§fn clone(&self) -> FeatureSet<'g>
fn clone(&self) -> FeatureSet<'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 FeatureSet<'g>
impl<'g> Debug for FeatureSet<'g>
source§impl<'g> PartialEq for FeatureSet<'g>
impl<'g> PartialEq for FeatureSet<'g>
impl<'g> Eq for FeatureSet<'g>
Auto Trait Implementations§
impl<'g> Freeze for FeatureSet<'g>
impl<'g> RefUnwindSafe for FeatureSet<'g>
impl<'g> Send for FeatureSet<'g>
impl<'g> Sync for FeatureSet<'g>
impl<'g> Unpin for FeatureSet<'g>
impl<'g> UnwindSafe for FeatureSet<'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