cargo::core::global_cache_tracker

Struct DeferredGlobalLastUse

Source
pub struct DeferredGlobalLastUse {
    registry_keys: HashMap<InternedString, ParentId>,
    git_keys: HashMap<InternedString, ParentId>,
    registry_index_timestamps: HashMap<RegistryIndex, u64>,
    registry_crate_timestamps: HashMap<RegistryCrate, u64>,
    registry_src_timestamps: HashMap<RegistrySrc, u64>,
    git_db_timestamps: HashMap<GitDb, u64>,
    git_checkout_timestamps: HashMap<GitCheckout, u64>,
    save_err_has_warned: bool,
    now: u64,
}
Expand description

This is a cache of modifications that will be saved to disk all at once via the DeferredGlobalLastUse::save method.

This is here to improve performance.

Fields§

§registry_keys: HashMap<InternedString, ParentId>

Cache of registry keys, used for faster fetching.

The key is the registry name (which is its directory name) and the value is the id in the registry_index table.

§git_keys: HashMap<InternedString, ParentId>

Cache of git keys, used for faster fetching.

The key is the git db name (which is its directory name) and the value is the id in the git_db table.

§registry_index_timestamps: HashMap<RegistryIndex, u64>

New registry index entries to insert.

§registry_crate_timestamps: HashMap<RegistryCrate, u64>

New registry .crate entries to insert.

§registry_src_timestamps: HashMap<RegistrySrc, u64>

New registry src directory entries to insert.

§git_db_timestamps: HashMap<GitDb, u64>

New git db entries to insert.

§git_checkout_timestamps: HashMap<GitCheckout, u64>

New git checkout entries to insert.

§save_err_has_warned: bool

This is used so that a warning about failing to update the database is only displayed once.

§now: u64

The current time, used to improve performance to avoid accessing the clock hundreds of times.

Implementations§

Source§

impl DeferredGlobalLastUse

Source

pub fn new() -> DeferredGlobalLastUse

Source

pub fn is_empty(&self) -> bool

Source

fn clear(&mut self)

Source

pub fn mark_registry_index_used(&mut self, registry_index: RegistryIndex)

Indicates the given RegistryIndex has been used right now.

Source

pub fn mark_registry_crate_used(&mut self, registry_crate: RegistryCrate)

Indicates the given RegistryCrate has been used right now.

Also implicitly marks the index used, too.

Source

pub fn mark_registry_src_used(&mut self, registry_src: RegistrySrc)

Indicates the given RegistrySrc has been used right now.

Also implicitly marks the index used, too.

Source

pub fn mark_git_checkout_used(&mut self, git_checkout: GitCheckout)

Indicates the given GitCheckout has been used right now.

Also implicitly marks the git db used, too.

Source

pub fn mark_registry_index_used_stamp( &mut self, registry_index: RegistryIndex, timestamp: Option<&SystemTime>, )

Indicates the given RegistryIndex has been used with the given time (or “now” if None).

Source

pub fn mark_registry_crate_used_stamp( &mut self, registry_crate: RegistryCrate, timestamp: Option<&SystemTime>, )

Indicates the given RegistryCrate has been used with the given time (or “now” if None).

Also implicitly marks the index used, too.

Source

pub fn mark_registry_src_used_stamp( &mut self, registry_src: RegistrySrc, timestamp: Option<&SystemTime>, )

Indicates the given RegistrySrc has been used with the given time (or “now” if None).

Also implicitly marks the index used, too.

Source

pub fn mark_git_checkout_used_stamp( &mut self, git_checkout: GitCheckout, timestamp: Option<&SystemTime>, )

Indicates the given GitCheckout has been used with the given time (or “now” if None).

Also implicitly marks the git db used, too.

Source

pub fn save(&mut self, tracker: &mut GlobalCacheTracker) -> CargoResult<()>

Saves all of the deferred information to the database.

This will also clear the state of self.

Source

pub fn save_no_error(&mut self, gctx: &GlobalContext)

Variant of DeferredGlobalLastUse::save that does not return an error.

This will log or display a warning to the user.

Source

fn save_with_gctx(&mut self, gctx: &GlobalContext) -> CargoResult<()>

Source

fn insert_registry_index_from_cache( &mut self, conn: &Connection, ) -> CargoResult<()>

Flushes all of the registry_index_timestamps to the database, clearing registry_index_timestamps.

Source

fn insert_git_db_from_cache(&mut self, conn: &Connection) -> CargoResult<()>

Flushes all of the git_db_timestamps to the database, clearing registry_index_timestamps.

Source

fn insert_registry_crate_from_cache( &mut self, conn: &Connection, ) -> CargoResult<()>

Flushes all of the registry_crate_timestamps to the database, clearing registry_index_timestamps.

Source

fn insert_registry_src_from_cache( &mut self, conn: &Connection, ) -> CargoResult<()>

Flushes all of the registry_src_timestamps to the database, clearing registry_index_timestamps.

Source

fn insert_git_checkout_from_cache( &mut self, conn: &Connection, ) -> CargoResult<()>

Flushes all of the git_checkout_timestamps to the database, clearing registry_index_timestamps.

Source

fn registry_id( &mut self, conn: &Connection, encoded_registry_name: InternedString, ) -> CargoResult<ParentId>

Returns the numeric ID of the registry, either fetching from the local cache, or getting it from the database.

It is an error if the registry does not exist.

Source

fn git_id( &mut self, conn: &Connection, encoded_git_name: InternedString, ) -> CargoResult<ParentId>

Returns the numeric ID of the git db, either fetching from the local cache, or getting it from the database.

It is an error if the git db does not exist.

Trait Implementations§

Source§

impl Debug for DeferredGlobalLastUse

Source§

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

Formats the value using the given formatter. 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, 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: 352 bytes