pub trait RegistryData {
    fn prepare(&self) -> CargoResult<()>;
    fn index_path(&self) -> &Filesystem;
    fn load(
        &mut self,
        root: &Path,
        path: &Path,
        index_version: Option<&str>
    ) -> Poll<CargoResult<LoadResponse>>; fn config(&mut self) -> Poll<CargoResult<Option<RegistryConfig>>>; fn invalidate_cache(&mut self); fn is_updated(&self) -> bool; fn download(
        &mut self,
        pkg: PackageId,
        checksum: &str
    ) -> CargoResult<MaybeLock>; fn finish_download(
        &mut self,
        pkg: PackageId,
        checksum: &str,
        data: &[u8]
    ) -> CargoResult<File>; fn assert_index_locked<'a>(&self, path: &'a Filesystem) -> &'a Path; fn block_until_ready(&mut self) -> CargoResult<()>; fn is_crate_downloaded(&self, _pkg: PackageId) -> bool { ... } }
Expand description

An abstract interface to handle both a local (see local::LocalRegistry) and remote (see remote::RemoteRegistry) registry.

This allows RegistrySource to abstractly handle both registry kinds.

Required Methods

Performs initialization for the registry.

This should be safe to call multiple times, the implementation is expected to not do any work if it is already prepared.

Returns the path to the index.

Note that different registries store the index in different formats (remote=git, local=files).

Loads the JSON for a specific named package from the index.

  • root is the root path to the index.
  • path is the relative path to the package to load (like ca/rg/cargo).
  • index_version is the version of the requested crate data currently in cache.

Loads the config.json file and returns it.

Local registries don’t have a config, and return None.

Invalidates locally cached data.

Is the local cached data up-to-date?

Prepare to start downloading a .crate file.

Despite the name, this doesn’t actually download anything. If the .crate is already downloaded, then it returns MaybeLock::Ready. If it hasn’t been downloaded, then it returns MaybeLock::Download which contains the URL to download. The crate::core::package::Downloads system handles the actual download process. After downloading, it calls Self::finish_download to save the downloaded file.

checksum is currently only used by local registries to verify the file contents (because local registries never actually download anything). Remote registries will validate the checksum in finish_download. For already downloaded .crate files, it does not validate the checksum, assuming the filesystem does not suffer from corruption or manipulation.

Finish a download by saving a .crate file to disk.

After crate::core::package::Downloads has finished a download, it will call this to save the .crate file. This is only relevant for remote registries. This should validate the checksum and save the given data to the on-disk cache.

Returns a File handle to the .crate file, positioned at the start.

Validates that the global package cache lock is held.

Given the Filesystem, this will make sure that the package cache lock is held. If not, it will panic. See Config::acquire_package_cache_lock for acquiring the global lock.

Returns the Path to the Filesystem.

Block until all outstanding Poll::Pending requests are Poll::Ready.

Provided Methods

Returns whether or not the .crate file is already downloaded.

Implementors