pub struct PackageSetSummary {
    pub summary_ids: BTreeSet<SummaryId>,
    pub workspace_members: BTreeSet<String>,
    pub third_party: Vec<ThirdPartySummary>,
}
Available on crate feature summaries only.
Expand description

A set of packages specified in a summary. Can be resolved into a PackageSet given a PackageGraph.

Requires the summaries feature to be enabled.

§Examples

Parsing a summary from a TOML specification, as found in e.g. a config file.


// This is an example TOML config for a PackageSet resolved from this workspace.
static TOML_INPUT: &str = r#"
workspace-members = ["guppy", "target-spec"]
# The version field specifies a range, just like Cargo.
# Third-party specifications also include "git" and "path".
third-party = [
    { name = "serde", version = "*" },
    { name = "rayon", version = "1.5" },
]
"#;

let summary: PackageSetSummary = toml::from_str(TOML_INPUT).expect("input parsed correctly");

let graph = MetadataCommand::new().build_graph().expect("guppy graph constructed");
let package_set = summary
    .to_package_set(&graph, "resolving example TOML")
    .expect("all elements matched");
let package_names: HashSet<_> = package_set
    .packages(DependencyDirection::Forward)
    .map(|metadata| metadata.name())
    .collect();

let mut expected_names = HashSet::new();
expected_names.extend(["guppy", "target-spec", "serde", "rayon"]);
assert_eq!(package_names, expected_names, "package names matched");

Specifying an invalid package results in an error.


// This is an example TOML config that contains package names that are unknown to this
// workspace.
static UNKNOWN_TOML_INPUT: &str = r#"
# serde is a third-party dependency, so it won't be matched in workspace-members.
workspace-members = ["unknown-member", "serde"]
# guppy is a workspace dependency, so it won't be matched in workspace-members.
# serde is present but the version number doesn't match.
third-party = [
    { name = "guppy" },
    { name = "serde", version = "0.9" },
    { name = "unknown-third-party" },
]
"#;

let summary: PackageSetSummary = toml::from_str(UNKNOWN_TOML_INPUT).expect("input parsed correctly");

let graph = MetadataCommand::new().build_graph().expect("guppy graph constructed");
let err = summary
    .to_package_set(&graph, "resolving example TOML")
    .expect_err("some elements are unknown");

assert_eq!(
    format!("{}", err),
    r#"unknown elements: resolving example TOML
* unknown workspace names:
  - serde
  - unknown-member
* unknown third-party:
  - { name = "guppy", version = "*", source = crates.io }
  - { name = "serde", version = "^0.9", source = crates.io }
  - { name = "unknown-third-party", version = "*", source = crates.io }
"#
);

Fields§

§summary_ids: BTreeSet<SummaryId>

A set of summary identifiers. Typically used in generated summaries.

Does not require a PackageGraph as context.

§workspace_members: BTreeSet<String>

Workspace packages, specified by names. Typically used in config files.

These require a PackageGraph as context.

§third_party: Vec<ThirdPartySummary>

Non-workspace packages, including non-workspace path dependencies. Typically used in config files.

Requires a PackageGraph as context.

Implementations§

source§

impl PackageSetSummary

source

pub fn new(package_set: &PackageSet<'_>) -> Self

Constructs a PackageSetSummary from a PackageSet.

source

pub fn from_package_ids<'a>( graph: &PackageGraph, package_ids: impl IntoIterator<Item = &'a PackageId> ) -> Result<Self, Error>

Constructs a PackageSetSummary from an iterator of PackageIds.

source

pub fn is_empty(&self) -> bool

Returns true if this PackageSetSummary is empty.

source

pub fn to_package_set<'g>( &self, graph: &'g PackageGraph, error_message: impl Into<String> ) -> Result<PackageSet<'g>, Error>

Converts this PackageSetSummary to a PackageSet.

Returns an error if any of the elements weren’t matched.

source

pub fn to_package_set_registry<'g, 'a>( &'a self, graph: &'g PackageGraph, registry_name_to_url: impl FnMut(&str) -> Option<&'a str>, error_message: impl Into<String> ) -> Result<PackageSet<'g>, Error>

Converts this PackageSetSummary to a PackageSet, with the given source for registry names.

Returns an error if any of the elements weren’t matched.

This is a temporary workaround until Cargo issue #9052 is resolved.

Trait Implementations§

source§

impl Clone for PackageSetSummary

source§

fn clone(&self) -> PackageSetSummary

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 Debug for PackageSetSummary

source§

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

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

impl Default for PackageSetSummary

source§

fn default() -> PackageSetSummary

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for PackageSetSummary

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for PackageSetSummary

source§

fn eq(&self, other: &PackageSetSummary) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for PackageSetSummary

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for PackageSetSummary

source§

impl StructuralPartialEq for PackageSetSummary

Auto Trait Implementations§

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,