pub struct DependencyGraph { /* private fields */ }Expand description
Represents a graph of package dependencies to be resolved and installed.
This structure helps determine which packages need to be installed, including any dependencies they require.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn new(install_packages: Vec<String>) -> Self
pub fn new(install_packages: Vec<String>) -> Self
Creates a graph seeded with the packages a caller asked for.
Names are Owner-Name, or Owner-Name-Version to install exactly that
version. Nothing is validated here, so an unknown name surfaces only at
resolution time.
Sourcepub fn pins(self, pins: impl IntoIterator<Item = String>) -> Self
pub fn pins(self, pins: impl IntoIterator<Item = String>) -> Self
Holds packages at Owner-Name-Version if resolution reaches them.
Entries without a version are ignored.
Sourcepub fn resolve(&self, index: &PackageIndex) -> HashMap<String, String>
pub fn resolve(&self, index: &PackageIndex) -> HashMap<String, String>
Resolves all dependencies for the requested packages against the package index.
This method:
- Starts with the user-requested packages
- For each package, adds its dependencies to the list to process
- Continues until all dependencies are resolved
Returns a map of archive filename to download URL covering the requested
packages and their full transitive closure, ready to hand to
crate::client::ThunderstoreClient::download_files.
§Limitations
The version suffix of a dependency string (e.g. the 1.2.3 in
Owner-Mod-1.2.3) is discarded, so every package resolves to its latest
available version unless a requested Owner-Name-Version or a
pins entry names one. There is no version-constraint
solving: a package whose manifest depends on an older version of another
still receives the latest one.
A requested package or dependency that is absent from index is silently
skipped here; use resolve_report to learn which
names failed to resolve so an incomplete install can be surfaced rather than
treated as success.
Sourcepub fn resolve_report(&self, index: &PackageIndex) -> Resolution
pub fn resolve_report(&self, index: &PackageIndex) -> Resolution
Resolves the install set like resolve, but also reports
every requested package or transitive dependency that could not be resolved
to a download — either absent from index, or present but with no
downloadable version.
A non-empty Resolution::unresolved means the returned URL map is
incomplete: those names were moderated/removed, misspelled, live in a
different community, or have no downloadable version, and installing only
what resolved would leave a broken mod. Callers that must fail (or warn) on a
missing dependency should use this instead of resolve,
which discards the report.