How do I share common code between Rust projects without publishing to crates.io? -
there may not answer question, have code share between 2 different rust projects without publishing crate crates.io.
the code proprietary , don't want put out wild.
but it's proprietary code , don't want put out wild.
you don't have publish crate. specifically, create crate (cargo new shared_stuff
) specify path common crate(s) in dependent project's cargo.toml
:
[dependency.shared_stuff] path = "path/to/shared/crate"
the cargo documentation has entire section on types of dependencies:
- specifying dependencies crates.io
- specifying dependencies git repositories
- specifying path dependencies
i believe cargo allow fetch private git repository (such on github or privately hosted service, such gitlab), haven't tried personally. based on searching, need have authenticated or otherwise configured git not require interactive password entry.
it's theoretically possible create own crate registry. i've not attempted this, machinery present in cargo handle it.