Module cache

Source
Expand description

Provides functionality for reading and writing cargo compatible .cache entries that can be wrapped by another index that has logic for fetching entries that aren’t in the cache

Cargo creates small cache entries for crates when they are accessed during any cargo operation that accesses a registry index (update/add/etc). Initially this was to accelerate accessing the contents of a bare clone of a git registry index as it skips accessing git blobs.

Now with sparse HTTP indices, these .cache files are even more important as they allow skipping network access if in offline mode, as well as allowing responses from servers to tell the client they have the latest version if that crate has not been changed since it was last accessed.

+-------------------+---------------------------+------------------+---+
| cache version :u8 | index format version :u32 | revision :string | 0 |
+-------------------+---------------------------+------------------+---+

followed by 1+

+----------------+---+-----------+---+
| semver version | 0 | JSON blob | 0 |
+----------------+---+-----------+---+

Structs§

IndexCache
The IndexCache allows access to the local cache entries for a remote index
ValidCacheEntry
A wrapper around a byte buffer that has been (partially) validated to be a valid cache entry

Constants§

CURRENT_CACHE_VERSION
The current (cargo 1.54.0+) cache version for cache entries.
INDEX_V_MAX
The maximum version of the v field in the index this crate supports

Functions§

split
Gives an iterator over the specified buffer, where each item is split by the specified needle value