To create a crate, you only need a Cargo.toml manifest file and an entrypoint in the project’s src subdirectory. However, most crates include libraries, tests, documentation, and more. To quickly create a scaffold that includes these, we recommend using Cargo’s generator:
cargo new CRATE_NAME
This will create a directory CRATE_NAME with the initial crate structure including the Cargo.toml manifest and src/main.rs entrypoint.
Once it’s ready, build and test it with the cargo command:
cd CRATE_NAME
cargo build
cargo test
Building a crate will compile source to a binary target, but it isn’t yet ready to distribute. To create the actual .crate file, package it with this cargo command:
cargo package
Upon success, the crate will be in the following directory.
target/package/<CRATE_NAME>-<VERSION>.crate
Now you can install this crate locally or upload into your Gemfury account.