Struct cargo::core::registry::PackageRegistry
[−]
[src]
pub struct PackageRegistry<'cfg> { /* fields omitted */ }
This structure represents a registry of known packages. It internally
contains a number of Box<Source>
instances which are used to load a
Package
from.
The resolution phase of Cargo uses this to drive knowledge about new packages as well as querying for lists of new packages. It is here that sources are updated (e.g. network operations) and overrides are handled.
The general idea behind this registry is that it is centered around the
SourceMap
structure, contained within which is a mapping of a SourceId
to
a Source
. Each Source
in the map has been updated (using network
operations if necessary) and is ready to be queried for packages.
Methods
impl<'cfg> PackageRegistry<'cfg>
[src]
fn new(config: &'cfg Config) -> CargoResult<PackageRegistry<'cfg>>
fn get(self, package_ids: &[PackageId]) -> PackageSet<'cfg>
fn add_sources(&mut self, ids: &[SourceId]) -> CargoResult<()>
fn add_preloaded(&mut self, source: Box<Source + 'cfg>)
fn add_override(&mut self, source: Box<Source + 'cfg>)
fn register_lock(&mut self, id: PackageId, deps: Vec<PackageId>)
fn lock(&self, summary: Summary) -> Summary
This function is used to transform a summary to another locked summary if possible. This is where the concept of a lockfile comes into play.
If a summary points at a package id which was previously locked, then we override the summary's id itself, as well as all dependencies, to be rewritten to the locked versions. This will transform the summary's source to a precise source (listed in the locked version) as well as transforming all of the dependencies from range requirements on imprecise sources to exact requirements on precise sources.
If a summary does not point at a package id which was previously locked, or if any dependencies were added and don't have a previously listed version, we still want to avoid updating as many dependencies as possible to keep the graph stable. In this case we map all of the summary's dependencies to be rewritten to a locked version wherever possible. If we're unable to map a dependency though, we just pass it on through.
Trait Implementations
impl<'cfg> Registry for PackageRegistry<'cfg>
[src]
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>>
Attempt to find the packages that match a dependency request.
fn supports_checksums(&self) -> bool
Returns whether or not this registry will return summaries with checksums listed. Read more