Skip to content

Guides

Rust Crates

Stout implements the Cargo sparse registry protocol. Configure your registry once and cargo add works out of the box.

Configure Your Client

Add the Stout registry to your Cargo config:

# .cargo/config.toml
[registries.stout]
index = "sparse+https://registry.stout.io/rust/myorg/"

Install a Crate

cargo add my-crate --registry stout

Publish a Crate

Stout builds from source. Submit a build via the API:

curl -X POST https://registry.stout.io/api/v1/builds \
  -H "Authorization: Bearer $STOUT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "format": "rust",
    "repo": "https://github.com/myorg/my-crate",
    "version": "1.2.0"
  }'

Authentication

For private crates, add credentials to .cargo/credentials.toml:

# .cargo/credentials.toml
[registries.stout]
token = "Bearer your-stout-token"

Or set the environment variable:

export CARGO_REGISTRIES_STOUT_TOKEN="Bearer $STOUT_TOKEN"

Endpoints

Method Path Description
GET /rust/:owner/config.json Cargo registry config
GET /rust/:owner/:p1/:p2/:name Sparse index entry
GET /rust/:owner/api/v1/crates/:name/:version/download Download crate