pub struct InstallTracker {
    v1: CrateListingV1,
    v2: CrateListingV2,
    v1_lock: FileLock,
    v2_lock: FileLock,
}
Expand description

On-disk tracking for which package installed which binary.

v1 is an older style, v2 is a new style that tracks more information, and is both backwards and forwards compatible. Cargo keeps both files in sync, updating both v1 and v2 at the same time. Additionally, if it detects changes in v1 that are not in v2 (such as when an older version of Cargo is used), it will automatically propagate those changes to v2.

This maintains a filesystem lock, preventing other instances of Cargo from modifying at the same time. Drop the value to unlock.

It is intended that v1 should be retained for a while during a longish transition period, and then v1 can be removed.

Fields§

§v1: CrateListingV1§v2: CrateListingV2§v1_lock: FileLock§v2_lock: FileLock

Implementations§

source§

impl InstallTracker

source

pub fn load(config: &Config, root: &Filesystem) -> CargoResult<InstallTracker>

Create an InstallTracker from information on disk.

source

pub fn check_upgrade( &self, dst: &Path, pkg: &Package, force: bool, opts: &CompileOptions, target: &str, _rustc: &str ) -> CargoResult<(Freshness, BTreeMap<String, Option<PackageId>>)>

Checks if the given package should be built, and checks if executables already exist in the destination directory.

Returns a tuple (freshness, map). freshness indicates if the package should be built (Dirty) or if it is already up-to-date (Fresh) and should be skipped. The map maps binary names to the PackageId that installed it (which is None if not known).

If there are no duplicates, then it will be considered Dirty (i.e., it is OK to build/install).

force=true will always be considered Dirty (i.e., it will always be rebuilt/reinstalled).

Returns an error if there is a duplicate and --force is not used.

source

fn find_duplicates( &self, dst: &Path, exes: &BTreeSet<String> ) -> BTreeMap<String, Option<PackageId>>

Check if any executables are already installed.

Returns a map of duplicates, the key is the executable name and the value is the PackageId that is already installed. The PackageId is None if it is an untracked executable.

source

pub fn mark_installed( &mut self, package: &Package, bins: &BTreeSet<String>, version_req: Option<String>, opts: &CompileOptions, target: &str, rustc: &str )

Mark that a package was installed.

source

pub fn save(&self) -> CargoResult<()>

Save tracking information to disk.

source

pub fn all_installed_bins( &self ) -> impl Iterator<Item = (&PackageId, &BTreeSet<String>)>

Iterator of all installed binaries. Items are (pkg_id, bins) where bins is the set of binaries that package installed.

source

pub fn installed_bins(&self, pkg_id: PackageId) -> Option<&BTreeSet<String>>

Set of binaries installed by a particular package. Returns None if the package is not installed.

source

pub fn remove(&mut self, pkg_id: PackageId, bins: &BTreeSet<String>)

Remove a package from the tracker.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere 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.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

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: 136 bytes