Struct guppy::graph::summaries::PackageSetSummary[][src]

pub struct PackageSetSummary {
    pub summary_ids: BTreeSet<SummaryId>,
    pub workspace_members: BTreeSet<String>,
    pub third_party: Vec<ThirdPartySummary>,
}
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

Constructs a PackageSetSummary from a PackageSet.

Constructs a PackageSetSummary from an iterator of PackageIds.

Returns true if this PackageSetSummary is empty.

Converts this PackageSetSummary to a PackageSet.

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.