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
impl InstallTracker
Sourcepub fn load(
gctx: &GlobalContext,
root: &Filesystem,
) -> CargoResult<InstallTracker>
pub fn load( gctx: &GlobalContext, root: &Filesystem, ) -> CargoResult<InstallTracker>
Create an InstallTracker
from information on disk.
Sourcepub fn check_upgrade(
&self,
dst: &Path,
pkg: &Package,
force: bool,
opts: &CompileOptions,
target: &str,
_rustc: &str,
) -> CargoResult<(Freshness, BTreeMap<String, Option<PackageId>>)>
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.
Sourcefn find_duplicates(
&self,
dst: &Path,
exes: &BTreeSet<String>,
) -> BTreeMap<String, Option<PackageId>>
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.
Sourcepub fn mark_installed(
&mut self,
package: &Package,
bins: &BTreeSet<String>,
version_req: Option<String>,
opts: &CompileOptions,
target: &str,
rustc: &str,
)
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.
Sourcepub fn save(&self) -> CargoResult<()>
pub fn save(&self) -> CargoResult<()>
Save tracking information to disk.
Sourcepub fn all_installed_bins(
&self,
) -> impl Iterator<Item = (&PackageId, &BTreeSet<String>)>
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.
Sourcepub fn installed_bins(&self, pkg_id: PackageId) -> Option<&BTreeSet<String>>
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.
Sourcepub fn remove(&mut self, pkg_id: PackageId, bins: &BTreeSet<String>)
pub fn remove(&mut self, pkg_id: PackageId, bins: &BTreeSet<String>)
Remove a package from the tracker.
Sourcepub fn remove_bin_then_save(
&mut self,
pkg_id: PackageId,
bin: &str,
bin_path: &PathBuf,
) -> CargoResult<()>
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§
impl Freeze for InstallTracker
impl RefUnwindSafe for InstallTracker
impl Send for InstallTracker
impl Sync for InstallTracker
impl Unpin for InstallTracker
impl UnwindSafe for InstallTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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