Skip to main content

Crate ferro_cargo_registry_server

Crate ferro_cargo_registry_server 

Source
Expand description

ferro-cargo-registry-server

Server-side primitives for the Cargo Alternative Registry Protocol (sparse-index variant, RFC 2789) for FerroRepo — sparse-index + publish / yank / owners / download endpoints. The Git-index protocol is wired with a 501 stub; Cargo defaults to sparse since 1.68 (CARGO_REGISTRIES_*_PROTOCOL=sparse), so the stub is a no-op for the client flows we target.

§Library quick start

Mount the router() over any ferro_blob_store::BlobStore inside a service you already run:

use std::sync::Arc;
use ferro_blob_store::FsBlobStore;
use ferro_cargo_registry_server::{router, CargoState};

let store = Arc::new(FsBlobStore::new("/var/lib/cargo-registry")?);
let state = CargoState::new(store, "http://127.0.0.1:8081");
let app = router(state);
let listener = tokio::net::TcpListener::bind("0.0.0.0:8081").await?;
axum::serve(listener, app).await?;

§Runnable binary

The crate also ships a ferro-cargo-registry-server binary that boots the router over a filesystem blob store and adds /live, /ready, /healthz probes:

FERRO_CARGO_REGISTRY_LISTEN=0.0.0.0:8081 \
FERRO_CARGO_REGISTRY_DATA=./registry-data \
  cargo run --bin ferro-cargo-registry-server

Point cargo at it with index = "sparse+http://127.0.0.1:8081/" in ~/.cargo/config.toml. See tests/e2e-results.md for the real-cargo round-trip results.

§Spec references

Re-exports§

pub use config::IndexConfig;
pub use error::CargoError;
pub use index::IndexDep;
pub use index::IndexEntry;
pub use index::PublishDep;
pub use index::PublishManifest;
pub use index::entry_from_manifest;
pub use index::parse_lines;
pub use index::render_lines;
pub use metrics::Metrics;
pub use metrics::MetricsState;
pub use metrics::instrument;
pub use metrics::metrics_routes;
pub use name::MAX_NAME_LEN;
pub use name::canonical_name;
pub use name::index_path;
pub use name::is_valid_name;
pub use name::names_collide;
pub use name::validate_name;
pub use owners::Owner;
pub use owners::OwnersMutationResponse;
pub use owners::OwnersRequest;
pub use owners::OwnersResponse;
pub use publish::PublishRequest;
pub use publish::encode as encode_publish_body;
pub use publish::parse as parse_publish_body;
pub use router::CargoState;
pub use router::CrateRecord;
pub use router::MAX_PUBLISH_BODY_BYTES;
pub use router::router;
pub use serve::Config;
pub use serve::build_app;
pub use serve::build_state;
pub use serve::init_tracing;
pub use serve::probe_routes;
pub use serve::serve;
pub use version::is_valid_semver;
pub use yank::YankResponse;

Modules§

config
Sparse-index config.json representation.
error
Cargo registry protocol errors.
handlers
Axum handlers for the Cargo registry.
index
Sparse-index line-oriented JSON format.
metrics
Prometheus instrumentation for ferro-cargo-registry-server.
name
Cargo crate name validator.
owners
Owner-management response shapes.
persist
Durable persistence for the in-memory crate index (DD R2-6).
publish
Publish request body parser.
router
Axum router for the Cargo registry protocol.
serve
Runnable-server assembly: environment configuration, app wiring, and the bind+serve loop with graceful shutdown.
version
Lightweight semver validator for Cargo registry versions.
yank
Yank / unyank response shapes.

Constants§

CRATE_NAME
Crate name, exposed for diagnostics and /metrics labelling.