Extension / Plugin / Library

[Featured Project]

1. Introduction

rust-env is a VSCode extension that brings auto-completion and type-safe access to .env keys directly in your Rust codebase.

While developing the backend for QPylon Video Downloader using Rust + Axum, I frequently encountered annoying bugs due to mistyped environment variable keys. Coming from a TypeScript world where I used hansf14-env-typings, I knew the solution: strong editor support.

So I built rust-env — a lightweight, automatic way to sync .env variables to a Rust module with IntelliSense-friendly constants.

Ideal For:
  • Anyone tired of mistyping std::env::var("MY_ENV_KEY").
Benefits:
  • No more typos.
  • Instant IntelliSense.
  • Zero runtime overhead.
Features:
  • Auto-generates Rust module for the Rust env file.
  • Tracks .env file changes on save.
  • Configurable output path via env.rust.json.
  • Lightweight & fast — 6ms startup
How It Works:
Just add a .env file and define your keys:
ini
API_SERVER_BASE_URL="https://api.example.com"
API_SERVER_HOST="api.example.com"
Then, in your project root, create a simple config file env.rust.json:
json
{
  "outPath": "./src/rust_env/mod.rs"
}
Whenever you save your .env file, the extension automatically generates the module with the env key constants:
rust
#[allow(dead_code)]
pub mod key {
  pub const API_SERVER_BASE_URL: &str = "API_SERVER_BASE_URL";
  pub const API_SERVER_HOST: &str = "API_SERVER_HOST";
}
And now you can safely reference them in code:
rust
use rust_env::key;

let url = std::env::var(key::API_SERVER_BASE_URL).unwrap();

2. Techs

  • Language / Script

  • API

  • IDE

  • VCS

  • Compiler / Transpiler / Bundler / Build Tool

  • Linter / Formatter

  • Package Manager / Dependency Manager

  • Etc.

3. Screenshots

© 2025 hansf14. All Rights Reserved.