To ensure a smooth onboarding experience and consistent development practices, follow the instructions below to set up your Rust development environment. This guide lists the essential tools and recommended Visual Studio Code (VS Code) extensions for working with this standardized Rust API template.
1. Install Rust Toolchain
- Rustup: The official Rust toolchain installer.
Install by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- This will install
rustc(the compiler),cargo(the package manager), and other core tools.
Below is a table of recommended Visual Studio Code extensions for your Rust API project, each with a direct link to its Marketplace page for easy installation:
| Extension Name | Marketplace Link | Purpose |
|---|---|---|
| Rust Analyzer | rust-lang.rust-analyzer | Core Rust language support: code navigation, completion, diagnostics, and more. |
| Dependi | fill-labs.dependi | Dependency management and visualization. |
| Dotenv (mikestead) | mikestead.dotenv | Syntax highlighting and support for .env files[4]. |
| Dotenv Official (with Vault) | dotenv.dotenv-vscode | Advanced .env file management and syncing[5]. |
| Even Better TOML | tamasfe.even-better-toml | TOML file syntax highlighting and validation[6]. |
| GitHub Actions | GitHub.vscode-github-actions | View/manage GitHub Actions and build status. |
| GitHub Copilot | GitHub.copilot | AI code completion and suggestions. |
| GitHub Copilot Chat | GitHub.copilot-chat | Chat-based prompts AI coding assistant. |
| GitHub Pull Requests & Issues | GitHub.vscode-pull-request-github | Manage pull requests and issues from within VS Code without commands. |
| Codium | Codium.codium | AI coding assistant alternative to copilot. |
Install these extensions by searching for their names in the VS Code Extensions Marketplace or by clicking the provided links. This setup will help ensure a robust and productive Rust development environment.
3. Project Conventions
- Please refer to our Rust API Conventions Document for standardized API design, naming, and best practices.
To enable automated pre-commit checks (including running cargo clippy), you need to set up Git hooks:
- The hook scripts are stored in the
git-hooksfolder at the root of the repo. - A setup script is provided to configure Git to use these hooks automatically.
After cloning the repository, run the setup once:
- Via PowerShell:
.\git-hooks\git_hooks_setup.ps1-
Or (Windows only) via one-click executable:
-
Locate and double-click the executable at:
git-hooks\git_hooks_setup.exe
-
- Configures Git to use the
git-hooksdirectory as its hooks folder. - All git hooks added henceforth will be tracked by git
-
Formatting: Use rustfmt to format your code:
cargo fmt
5. Quick Start
- Clone the repository and open it in VS Code.
- Ensure all recommended extensions are installed.
- Build and run the project:
cargo build cargo run
- Use
cargo clippyandcargo fmtregularly to maintain code quality.
6. Additional Resources
By following these steps and using the listed tools, you will have a robust and productive Rust development environment tailored for standardized API projects.
This project and its accompanying installation documentation are provided "as is" without any warranties or guarantees of any kind, either express or implied. While we have made every effort to ensure the accuracy and functionality of the code and instructions provided, we cannot guarantee that this solution will work in all environments or configurations. Use of this project is at your own risk. We are not responsible for any issues, damages, or data loss that may occur as a result of using this project or following the installation instructions. It is strongly recommended that you thoroughly test the solution in a non-production environment before deploying it to your production systems. Additionally, ensure that your environment meets all prerequisites and that you have the appropriate expertise to manage and troubleshoot any issues that may arise. By using this project, you acknowledge and agree to the terms of this disclaimer.