#cargo

bin+lib reg-index

Library to manage a registry index

7 unstable releases

0.4.0 Apr 6, 2021
0.3.0 Dec 28, 2019
0.2.2 Jul 28, 2019
0.2.0 Apr 18, 2019
0.1.0 Dec 24, 2018

#158 in #cargo

Download history 14/week @ 2021-01-03 32/week @ 2021-01-10 44/week @ 2021-01-17 25/week @ 2021-01-24 42/week @ 2021-01-31 32/week @ 2021-02-07 37/week @ 2021-02-14 45/week @ 2021-02-21 42/week @ 2021-02-28 15/week @ 2021-03-07 23/week @ 2021-03-14 69/week @ 2021-03-21 28/week @ 2021-03-28 60/week @ 2021-04-04 59/week @ 2021-04-11 37/week @ 2021-04-18

150 downloads per month
Used in cargo-index

MIT/Apache

41KB
905 lines

Cargo registry index library.

crates.io docs

An experimental library for managing a Cargo registry index. See cargo-index for the CLI command that uses this library.


lib.rs:

This library is for accessing and manipulating a Cargo registry index.

A very basic example:

# fn main() -> Result<(), failure::Error> {
# std::env::set_var("GIT_AUTHOR_NAME", "Index Admin");
# std::env::set_var("GIT_AUTHOR_EMAIL", "admin@example.com");
# let tmp_dir = tempfile::tempdir().unwrap();
# let index_path = tmp_dir.path().join("index");
# let index_url = "https://example.com/";
# let project = tmp_dir.path().join("foo");
# let status = std::process::Command::new("cargo")
#     .args(&["new", "--vcs=none", project.to_str().unwrap()])
#     .status()?;
# assert!(status.success());
# let manifest_path = project.join("Cargo.toml");
// Initialize a new index.
reg_index::init(&index_path, "https://example.com", None)?;
// Add a package to the index.
reg_index::add(&index_path, index_url, Some(&manifest_path), None, None)?;
// Packages can be yanked.
reg_index::yank(&index_path, "foo", "0.1.0")?;
// Get the metadata for the new entry.
let pkgs = reg_index::list(&index_path, "foo", None)?;
// Displays something like:
// {"name":"foo","vers":"0.1.0","deps":[],"features":{},"cksum":"d87f097fcc13ae97736a7d8086fb70a0499f3512f0fe1fe82e6422f25f567c83","yanked":true,"links":null}
println!("{}", serde_json::to_string(&pkgs[0])?);
# Ok(())
# }

See https://doc.rust-lang.org/cargo/reference/registries.html for documentation about Cargo registries.

Locking

The functions here perform simple filesystem locking to ensure multiple commands running at the same time do not interfere with one another. This requires that the filesystem supports locking.

Dependencies

~13MB
~316K SLoC