Publish My Own Rust Crate
Through my previous post, I completed the basic structure of the rust_rts crate. While there are still many areas that need further development, such as discrete systems, boundary-located targets, and active searchers, the core framework is now in place and only requires filling in specific components. However, due to the relatively basic structure of the crate, detailed documentation is essential to ensure proper usage over time. Therefore, I would like to document the process of adding comprehensive comments to the crate and publishing it. Detailed information about crate publishing can be found in the book1.
API token
The first step is obtaining an API login token to allow cargo to access and manage crates on crate.io.
This can be obtained by logging into crate.io with a GitHub account and accessing the account settings.
After receiving the token, execute the following command to store the login information in the ~/.cargo/credentials file:
$ cargo login abcdefghijklmnopqrstuvwxyz012345
It is recommended to complete the email verification on crate.io during this process.
Metadata
The next step involves verifying that the crate metadata is properly documented. The book suggests including the following metadata: authors, license, description, homepage, documentation, repository, and README. Additional fields such as keywords and categories can be added, with the caveat that spaces should be avoided and categories must match the category slugs. I have currently included basic information such as author details, license, and repository information, with plans to update the remaining content progressively.
Packaging
The final step is testing whether the crate compiles correctly and is ready for upload. The following two commands serve the same purpose, and the crate is ready for upload only when these commands execute without any issues:
$ cargo publish --dry-run
$ cargo package
Since the rust_rts crate contains a sub-package that declares procedural macros, it must be published first, and the Cargo.toml of rust_rts needs to be updated accordingly to ensure the crate functions properly for other users.
After completing these tests and ensuring all recent changes are committed to git, the crate can be published using the cargo publish command.