cargo::core::resolver

Struct Resolve

Source
pub struct Resolve {
    graph: Graph<PackageId, HashSet<Dependency>>,
    replacements: HashMap<PackageId, PackageId>,
    reverse_replacements: HashMap<PackageId, PackageId>,
    features: HashMap<PackageId, Vec<InternedString>>,
    checksums: HashMap<PackageId, Option<String>>,
    metadata: Metadata,
    unused_patches: Vec<PackageId>,
    public_dependencies: HashMap<PackageId, HashSet<PackageId>>,
    version: ResolveVersion,
    summaries: HashMap<PackageId, Summary>,
}
Expand description

Represents a fully-resolved package dependency graph. Each node in the graph is a package and edges represent dependencies between packages.

Each instance of Resolve also understands the full set of features used for each package.

Fields§

§graph: Graph<PackageId, HashSet<Dependency>>

A graph, whose vertices are packages and edges are dependency specifications from Cargo.toml. We need a HashSet here because the same package might be present in both [dependencies] and [build-dependencies].

§replacements: HashMap<PackageId, PackageId>

Replacements from the [replace] table.

§reverse_replacements: HashMap<PackageId, PackageId>

Inverted version of replacements.

§features: HashMap<PackageId, Vec<InternedString>>

Features enabled for a given package.

§checksums: HashMap<PackageId, Option<String>>

Checksum for each package. A SHA256 hash of the .crate file used to validate the correct crate file is used. This is None for sources that do not use .crate files, like path or git dependencies.

§metadata: Metadata

“Unknown” metadata. This is a collection of extra, unrecognized data found in the [metadata] section of Cargo.lock, preserved for forwards compatibility.

§unused_patches: Vec<PackageId>

[patch] entries that did not match anything, preserved in Cargo.lock as the [[patch.unused]] table array. Tracking unused patches helps prevent Cargo from being forced to re-update the registry every time it runs, and keeps the resolve in a locked state so it doesn’t re-resolve the unused entries.

§public_dependencies: HashMap<PackageId, HashSet<PackageId>>

A map from packages to a set of their public dependencies

§version: ResolveVersion

Version of the Cargo.lock format, see cargo::core::resolver::encode for more.

§summaries: HashMap<PackageId, Summary>

Implementations§

Source§

impl Resolve

Source

pub fn new( graph: Graph<PackageId, HashSet<Dependency>>, replacements: HashMap<PackageId, PackageId>, features: HashMap<PackageId, Vec<InternedString>>, checksums: HashMap<PackageId, Option<String>>, metadata: Metadata, unused_patches: Vec<PackageId>, version: ResolveVersion, summaries: HashMap<PackageId, Summary>, ) -> Resolve

Source

pub fn path_to_top<'a>( &'a self, pkg: &'a PackageId, ) -> Vec<(&'a PackageId, Option<&'a HashSet<Dependency>>)>

Resolves one of the paths from the given dependent package up to the root.

Source

pub fn register_used_patches<'a>( &mut self, patches: impl Iterator<Item = &'a Summary>, )

Source

pub fn merge_from(&mut self, previous: &Resolve) -> CargoResult<()>

Source

pub fn contains<Q>(&self, k: &Q) -> bool
where PackageId: Borrow<Q>, Q: Ord + Eq + ?Sized,

Source

pub fn sort(&self) -> Vec<PackageId>

Source

pub fn iter(&self) -> impl Iterator<Item = PackageId> + '_

Source

pub fn len(&self) -> usize

Source

pub fn deps( &self, pkg: PackageId, ) -> impl Iterator<Item = (PackageId, &HashSet<Dependency>)>

Source

pub fn deps_not_replaced( &self, pkg: PackageId, ) -> impl Iterator<Item = (PackageId, &HashSet<Dependency>)>

Source

pub fn transitive_deps_not_replaced( &self, pkg: PackageId, ) -> impl Iterator<Item = (PackageId, &Dependency)>

Source

pub fn replacement(&self, pkg: PackageId) -> Option<PackageId>

Source

pub fn replacements(&self) -> &HashMap<PackageId, PackageId>

Source

pub fn features(&self, pkg: PackageId) -> &[InternedString]

Source

pub fn features_clone(&self) -> HashMap<PackageId, Vec<InternedString>>

This is only here for legacy support, it will be removed when switching to the new feature resolver.

Source

pub fn is_public_dep(&self, pkg: PackageId, dep: PackageId) -> bool

Source

pub fn query(&self, spec: &str) -> CargoResult<PackageId>

Source

pub fn specs_to_ids( &self, specs: &[PackageIdSpec], ) -> CargoResult<Vec<PackageId>>

Source

pub fn unused_patches(&self) -> &[PackageId]

Source

pub fn checksums(&self) -> &HashMap<PackageId, Option<String>>

Source

pub fn metadata(&self) -> &Metadata

Source

pub fn extern_crate_name_and_dep_name( &self, from: PackageId, to: PackageId, to_target: &Target, ) -> CargoResult<(InternedString, Option<InternedString>)>

Source

fn dependencies_listed( &self, from: PackageId, to: PackageId, ) -> &HashSet<Dependency>

Source

pub fn version(&self) -> ResolveVersion

Returns the version of the encoding that’s being used for this lock file.

Source

pub fn set_version(&mut self, version: ResolveVersion)

Source

pub fn summary(&self, pkg_id: PackageId) -> &Summary

Trait Implementations§

Source§

impl Debug for Resolve

Source§

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

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

impl PartialEq for Resolve

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Resolve

Source§

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

Serialize this value into the given Serde serializer. Read more

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 360 bytes