Struct guppy::graph::PackageSet
source · pub struct PackageSet<'g> { /* private fields */ }
Expand description
A set of resolved packages in a package graph.
Created by PackageQuery::resolve
.
Implementations§
source§impl<'g> PackageSet<'g>
impl<'g> PackageSet<'g>
sourcepub fn contains(&self, package_id: &PackageId) -> Result<bool, Error>
pub fn contains(&self, package_id: &PackageId) -> Result<bool, Error>
Returns true if this package ID is contained in this resolve set.
Returns an error if the package ID is unknown.
sourcepub fn to_package_query(
&self,
direction: DependencyDirection,
) -> PackageQuery<'g>
pub fn to_package_query( &self, direction: DependencyDirection, ) -> PackageQuery<'g>
Creates a new PackageQuery
from this set in the specified direction.
This is equivalent to constructing a query from all the package_ids
.
sourcepub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
Returns a PackageSet
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 PackageSet
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 PackageSet
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 PackageSet
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(PackageMetadata<'g>) -> bool,
) -> Self
pub fn filter( &self, direction: DependencyDirection, callback: impl FnMut(PackageMetadata<'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(PackageMetadata<'g>) -> bool,
) -> (Self, Self)
pub fn partition( &self, direction: DependencyDirection, callback: impl FnMut(PackageMetadata<'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(PackageMetadata<'g>) -> Option<bool>,
) -> (Self, Self)
pub fn filter_partition( &self, direction: DependencyDirection, callback: impl FnMut(PackageMetadata<'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 to_feature_set(&self, filter: impl FeatureFilter<'g>) -> FeatureSet<'g>
pub fn to_feature_set(&self, filter: impl FeatureFilter<'g>) -> FeatureSet<'g>
Creates a new FeatureSet
consisting of all packages in this PackageSet
, using the given
feature filter.
This will cause the feature graph to be constructed if it hasn’t been done so already.
sourcepub fn package_ids<'a>(
&'a self,
direction: DependencyDirection,
) -> impl ExactSizeIterator<Item = &'g PackageId> + 'a
pub fn package_ids<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = &'g PackageId> + 'a
Iterates over package IDs, 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 packages<'a>(
&'a self,
direction: DependencyDirection,
) -> impl ExactSizeIterator<Item = PackageMetadata<'g>> + 'a
pub fn packages<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = PackageMetadata<'g>> + 'a
Iterates over package metadatas, 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 = &'g PackageId> + 'a
pub fn root_ids<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = &'g PackageId> + 'a
Returns the set of “root package” IDs in the specified direction.
- If direction is Forward, return the set of packages that do not have any dependencies within the selected graph.
- If direction is Reverse, return the set of packages 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_packages<'a>(
&'a self,
direction: DependencyDirection,
) -> impl ExactSizeIterator<Item = PackageMetadata<'g>> + 'a
pub fn root_packages<'a>( &'a self, direction: DependencyDirection, ) -> impl ExactSizeIterator<Item = PackageMetadata<'g>> + 'a
Returns the set of “root package” metadatas in the specified direction.
- If direction is Forward, return the set of packages that do not have any dependencies within the selected graph.
- If direction is Reverse, return the set of packages 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 links<'a>(
&'a self,
direction: DependencyDirection,
) -> impl Iterator<Item = PackageLink<'g>> + 'a
pub fn links<'a>( &'a self, direction: DependencyDirection, ) -> impl Iterator<Item = PackageLink<'g>> + 'a
Creates an iterator over PackageLink
instances.
If the iteration is in forward order, for any given package, at least one link where the
package is on the to
end is returned before any links where the package is on the
from
end.
If the iteration is in reverse order, for any given package, at least one link where the
package is on the from
end is returned before any links where the package is on the to
end.
§Cycles
The links in 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 the link Foo -> Bar is returned before the link Bar -> Foo.
sourcepub fn display_dot<'a, V: PackageDotVisitor + 'g>(
&'a self,
visitor: V,
) -> impl Display + 'a
pub fn display_dot<'a, V: PackageDotVisitor + 'g>( &'a self, visitor: V, ) -> impl Display + 'a
Constructs a representation of the selected packages in dot
format.
Trait Implementations§
source§impl<'g> Clone for PackageSet<'g>
impl<'g> Clone for PackageSet<'g>
source§fn clone(&self) -> PackageSet<'g>
fn clone(&self) -> PackageSet<'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 PackageSet<'g>
impl<'g> Debug for PackageSet<'g>
source§impl<'g> PartialEq for PackageSet<'g>
impl<'g> PartialEq for PackageSet<'g>
impl<'g> Eq for PackageSet<'g>
Auto Trait Implementations§
impl<'g> Freeze for PackageSet<'g>
impl<'g> RefUnwindSafe for PackageSet<'g>
impl<'g> Send for PackageSet<'g>
impl<'g> Sync for PackageSet<'g>
impl<'g> Unpin for PackageSet<'g>
impl<'g> UnwindSafe for PackageSet<'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