pub struct CratesIoResolver { /* private fields */ }Expand description
crates.io-style artifact resolver owned by the CLI layer.
The default resolver performs no network access. It resolves a spec only
from an already-seeded local cache or an explicitly registered registry
artifact. With the registry feature, callers can install GitRegistryResolver
so unresolved specs fetch from an explicit git registry artifact endpoint and
then enter the same cache layout.
Implementations§
Source§impl CratesIoResolver
impl CratesIoResolver
Sourcepub fn new(cache_dir: PathBuf) -> Self
pub fn new(cache_dir: PathBuf) -> Self
Builds a cache-only resolver rooted at a cache directory.
Sourcepub fn default_cache_dir() -> PathBuf
pub fn default_cache_dir() -> PathBuf
Returns the default cache directory.
Honors SIM_CLI_CACHE_DIR, then XDG_CACHE_HOME, then HOME, and
falls back to the system temporary directory.
Sourcepub fn add_registry_artifact(
&mut self,
package: impl Into<String>,
version: impl Into<String>,
artifact: impl Into<PathBuf>,
)
pub fn add_registry_artifact( &mut self, package: impl Into<String>, version: impl Into<String>, artifact: impl Into<PathBuf>, )
Registers an in-memory registry artifact available for resolution.
Sourcepub fn with_registry_artifact(
self,
package: impl Into<String>,
version: impl Into<String>,
artifact: impl Into<PathBuf>,
) -> Self
pub fn with_registry_artifact( self, package: impl Into<String>, version: impl Into<String>, artifact: impl Into<PathBuf>, ) -> Self
Registers an in-memory registry artifact, returning self.
Sourcepub fn resolve(
&self,
spec: &CratesIoSpec,
) -> Result<ResolvedCratesIoSource, CliError>
pub fn resolve( &self, spec: &CratesIoSpec, ) -> Result<ResolvedCratesIoSource, CliError>
Resolves a spec to a cached artifact, seeding the cache when needed.
Prefers an already-cached artifact, then a registered registry artifact.
With the registry feature and an installed git registry resolver, misses
can fetch through that resolver. Otherwise misses fail closed with a
clear cache-only error rather than pretending to fetch one.
Trait Implementations§
Source§impl Clone for CratesIoResolver
impl Clone for CratesIoResolver
Source§fn clone(&self) -> CratesIoResolver
fn clone(&self) -> CratesIoResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more