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
impl DeferredGlobalLastUse
pub fn new() -> DeferredGlobalLastUse
pub fn is_empty(&self) -> bool
fn clear(&mut self)
Sourcepub fn mark_registry_index_used(&mut self, registry_index: RegistryIndex)
pub fn mark_registry_index_used(&mut self, registry_index: RegistryIndex)
Indicates the given RegistryIndex
has been used right now.
Sourcepub fn mark_registry_crate_used(&mut self, registry_crate: RegistryCrate)
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.
Sourcepub fn mark_registry_src_used(&mut self, registry_src: RegistrySrc)
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.
Sourcepub fn mark_git_checkout_used(&mut self, git_checkout: GitCheckout)
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.
Sourcepub fn mark_registry_index_used_stamp(
&mut self,
registry_index: RegistryIndex,
timestamp: Option<&SystemTime>,
)
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
).
Sourcepub fn mark_registry_crate_used_stamp(
&mut self,
registry_crate: RegistryCrate,
timestamp: Option<&SystemTime>,
)
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.
Sourcepub fn mark_registry_src_used_stamp(
&mut self,
registry_src: RegistrySrc,
timestamp: Option<&SystemTime>,
)
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.
Sourcepub fn mark_git_checkout_used_stamp(
&mut self,
git_checkout: GitCheckout,
timestamp: Option<&SystemTime>,
)
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.
Sourcepub fn save(&mut self, tracker: &mut GlobalCacheTracker) -> CargoResult<()>
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
.
Sourcepub fn save_no_error(&mut self, gctx: &GlobalContext)
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.
fn save_with_gctx(&mut self, gctx: &GlobalContext) -> CargoResult<()>
Sourcefn insert_registry_index_from_cache(
&mut self,
conn: &Connection,
) -> CargoResult<()>
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
.
Sourcefn insert_git_db_from_cache(&mut self, conn: &Connection) -> CargoResult<()>
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
.
Sourcefn insert_registry_crate_from_cache(
&mut self,
conn: &Connection,
) -> CargoResult<()>
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
.
Sourcefn insert_registry_src_from_cache(
&mut self,
conn: &Connection,
) -> CargoResult<()>
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
.
Sourcefn insert_git_checkout_from_cache(
&mut self,
conn: &Connection,
) -> CargoResult<()>
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
.
Sourcefn registry_id(
&mut self,
conn: &Connection,
encoded_registry_name: InternedString,
) -> CargoResult<ParentId>
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.
Sourcefn git_id(
&mut self,
conn: &Connection,
encoded_git_name: InternedString,
) -> CargoResult<ParentId>
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§
Auto Trait Implementations§
impl Freeze for DeferredGlobalLastUse
impl RefUnwindSafe for DeferredGlobalLastUse
impl Send for DeferredGlobalLastUse
impl Sync for DeferredGlobalLastUse
impl Unpin for DeferredGlobalLastUse
impl UnwindSafe for DeferredGlobalLastUse
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: 352 bytes