pub struct NetworkRegistry { /* private fields */ }Expand description
A network-backed registry that fetches metadata and tarballs over HTTPS.
Hydrate into a PackageRegistry via Self::hydrate before running
resolution, since resolution is driven by the in-memory provider.
Implementations§
Source§impl NetworkRegistry
impl NetworkRegistry
Sourcepub fn new(
base_url: impl Into<String>,
cache_dir: impl Into<PathBuf>,
) -> Result<Self, PkgError>
pub fn new( base_url: impl Into<String>, cache_dir: impl Into<PathBuf>, ) -> Result<Self, PkgError>
Build a client pointed at base_url with tarballs cached under cache_dir.
The cache directory is created if it does not exist.
Sourcepub fn with_fallback(self, fallback: PackageRegistry) -> Self
pub fn with_fallback(self, fallback: PackageRegistry) -> Self
Attach an in-memory PackageRegistry to serve entries the network
does not know about (or cannot be reached for).
Sourcepub fn with_auth_token(self, token: Option<String>) -> Self
pub fn with_auth_token(self, token: Option<String>) -> Self
Override the Bearer auth token used for registry requests.
Pass None to clear the token (useful for tests that want to skip the
environment-provided value). By default, the value of the
AUTH_TOKEN_ENV environment variable is used.
Sourcepub fn auth_token(&self) -> Option<&str>
pub fn auth_token(&self) -> Option<&str>
The Bearer auth token currently in effect, if any.
Sourcepub fn fetch_versions(&self, name: &str) -> Result<VersionsResponse, PkgError>
pub fn fetch_versions(&self, name: &str) -> Result<VersionsResponse, PkgError>
Fetch the list of versions available for name.
Sourcepub fn fetch_version_meta(
&self,
name: &str,
version: &str,
) -> Result<VersionMetaResponse, PkgError>
pub fn fetch_version_meta( &self, name: &str, version: &str, ) -> Result<VersionMetaResponse, PkgError>
Fetch the metadata for a specific version of name.
Sourcepub fn download_package(
&self,
name: &str,
version: &str,
) -> Result<PathBuf, PkgError>
pub fn download_package( &self, name: &str, version: &str, ) -> Result<PathBuf, PkgError>
Download a package tarball, verifying its checksum, and cache it.
Returns the path of the cached tarball. If the file already exists in the cache, it is returned without re-fetching or re-verifying — the tarball name embeds the version, so the cache key is version-scoped.
Sourcepub fn fetch_package(
&self,
name: &str,
version: &str,
) -> Result<FetchedPackage, PkgError>
pub fn fetch_package( &self, name: &str, version: &str, ) -> Result<FetchedPackage, PkgError>
Fetch a package: resolve metadata, download (or reuse cached) tarball, and return the cached path together with the metadata response.
When the tarball is already cached, the checksum in the returned meta is still fetched from the registry to keep lockfile entries accurate.
Sourcepub fn hydrate(&self, names: &[&str]) -> Result<PackageRegistry, PkgError>
pub fn hydrate(&self, names: &[&str]) -> Result<PackageRegistry, PkgError>
Hydrate an in-memory PackageRegistry by fetching metadata for each
of the named packages.
If a fallback was attached, it seeds the returned registry and absorbs
any packages the network layer could not resolve (offline or not found).
Per-package network errors are swallowed when a fallback is present so
offline operation can continue; otherwise they propagate.