Expand description
Generic sparse-index registry client.
Implements Cargo’s sparse index wire protocol (RFC 2789), shared by crates.io itself
and any alternate/private registry declared through .cargo/config.toml. Extracted
from registry.rs so crate::registry::CratesIoRegistry and the alternate-registry
router (CargoRegistry) both delegate to one implementation instead of duplicating the
index-path computation, JSON-lines parsing, and crate-name safety gate.
§Examples
use deps_cargo::config::{IndexTrust, RegistryIndex};
use deps_cargo::sparse::SparseIndexClient;
use deps_core::HttpCache;
use deps_core::net_policy::RegistryAccessPolicy;
use std::sync::Arc;
#[tokio::main]
async fn main() {
let cache = Arc::new(HttpCache::new());
let policy = RegistryAccessPolicy::default();
let index = RegistryIndex::new("https://index.crates.io", IndexTrust::Trusted, &policy).unwrap();
let client = SparseIndexClient::new(index, cache);
let versions = client.get_versions("serde").await.unwrap();
println!("Latest serde: {}", versions[0].num);
}Structs§
- Sparse
Index Client - Client for one sparse-index registry — crates.io’s own index or an alternate/private
one resolved from
.cargo/config.toml.