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( gctx: &GlobalContext, 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.

source

pub fn remove_bin_then_save( &mut self, pkg_id: PackageId, bin: &str, bin_path: &PathBuf, ) -> CargoResult<()>

Remove a bin after it successfully had been removed in disk and then save the tracker at last.

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