pub struct CacheSnapshot {
pub version: u32,
pub toolchain_version: String,
pub dependency_hash: u64,
pub cells: HashMap<String, CachedCell>,
pub created_at: u64,
}Expand description
Snapshot of Salsa DB state that can be persisted to disk.
This captures the essential compilation state needed for instant resume:
- Which cells have been compiled
- Where their dylibs are located
- What source code produced them (via hash)
Note: This does NOT store Salsa’s internal memoization state. Salsa queries will be recomputed on load, but since compiled dylibs are preserved, compilation (the slow part) is skipped.
Fields§
§version: u32Cache format version for compatibility checking.
toolchain_version: StringRust toolchain version string (e.g., “rustc 1.76.0-nightly (abc123 2024-01-15)”).
Cache is invalidated if toolchain changes, since compiled dylibs may have ABI incompatibilities.
dependency_hash: u64Hash of external dependencies from //! [dependencies] block.
If this changes, the universe dylib needs recompilation and all cells must be recompiled against the new universe.
cells: HashMap<String, CachedCell>Compilation results keyed by cell name.
created_at: u64Unix timestamp when cache was created.
Implementations§
Source§impl CacheSnapshot
impl CacheSnapshot
Sourcepub fn new(toolchain_version: String, dependency_hash: u64) -> Self
pub fn new(toolchain_version: String, dependency_hash: u64) -> Self
Create a new cache snapshot.
Sourcepub fn add_cell(&mut self, cell: CachedCell)
pub fn add_cell(&mut self, cell: CachedCell)
Add a compiled cell to the snapshot.
Sourcepub fn get_cell(&self, name: &str) -> Option<&CachedCell>
pub fn get_cell(&self, name: &str) -> Option<&CachedCell>
Get a cached cell by name.
Sourcepub fn is_cell_valid(&self, name: &str, current_source_hash: u64) -> bool
pub fn is_cell_valid(&self, name: &str, current_source_hash: u64) -> bool
Check if a cell’s source has changed.
Returns true if the cell exists in cache with the same source hash.
Sourcepub fn is_dependency_valid(&self, current_hash: u64) -> bool
pub fn is_dependency_valid(&self, current_hash: u64) -> bool
Check if dependency hash matches.
Trait Implementations§
Source§impl Archive for CacheSnapshot
impl Archive for CacheSnapshot
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedCacheSnapshot
type Archived = ArchivedCacheSnapshot
Source§type Resolver = CacheSnapshotResolver
type Resolver = CacheSnapshotResolver
Source§impl Clone for CacheSnapshot
impl Clone for CacheSnapshot
Source§fn clone(&self) -> CacheSnapshot
fn clone(&self) -> CacheSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CacheSnapshot
impl Debug for CacheSnapshot
Source§impl<__D: Fallible + ?Sized> Deserialize<CacheSnapshot, __D> for Archived<CacheSnapshot>where
u32: Archive,
<u32 as Archive>::Archived: Deserialize<u32, __D>,
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
u64: Archive,
<u64 as Archive>::Archived: Deserialize<u64, __D>,
HashMap<String, CachedCell>: Archive,
<HashMap<String, CachedCell> as Archive>::Archived: Deserialize<HashMap<String, CachedCell>, __D>,
impl<__D: Fallible + ?Sized> Deserialize<CacheSnapshot, __D> for Archived<CacheSnapshot>where
u32: Archive,
<u32 as Archive>::Archived: Deserialize<u32, __D>,
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
u64: Archive,
<u64 as Archive>::Archived: Deserialize<u64, __D>,
HashMap<String, CachedCell>: Archive,
<HashMap<String, CachedCell> as Archive>::Archived: Deserialize<HashMap<String, CachedCell>, __D>,
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<CacheSnapshot, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<CacheSnapshot, <__D as Fallible>::Error>
Auto Trait Implementations§
impl Freeze for CacheSnapshot
impl RefUnwindSafe for CacheSnapshot
impl Send for CacheSnapshot
impl Sync for CacheSnapshot
impl Unpin for CacheSnapshot
impl UnwindSafe for CacheSnapshot
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> CellOutput for Twhere
T: for<'a> Serialize<Strategy<Serializer<AlignedVec, ArenaHandle<'a>, Share>, Error>> + Send + Sync + 'static,
impl<T> CellOutput for Twhere
T: for<'a> Serialize<Strategy<Serializer<AlignedVec, ArenaHandle<'a>, Share>, Error>> + Send + Sync + 'static,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.