Crate repackage[][src]

Repackage .crate files under a different crate name.

This crate provides repackage::dot_crate, which repackages a .crate file so that it exports the same crate under a different name. It replaces the name attribute in Cargo.toml, and also rewrites references to the old name in the various .rs files that live outside of src/ (those in src/ use crate::).

Rewriting .rs files

Normally, rewriting the name in Cargo.toml should be sufficient for most use-cases. Consumers of a .crate file likely only care about the exported library, which only ever refers to itself using paths starting with crate:: or ::, not including the name. Tests and binaries do have to name the library crate, but are usually not used by downstream consumers of the .crate. But, just in case, this crate tries to modify those files as well using some simple string replacement. It's brittle though, so you might only get so far with that approach if you make heavy use of non-library artifacts in the produced .crate files.

Functions

dot_crate

Repackage the crate contained in the .crate tarball at dot_crate as new_name.