Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Rust
  3. envy

envy

MITRust

A Rust library for deserializing environment variables into type-safe structs using Serde.

GitHubGitHub
978 stars44 forks0 contributors

What is envy?

Envy is a Rust crate that simplifies configuration management by automatically deserializing environment variables into strongly-typed Rust structs. It leverages Serde's deserialization framework to provide a safe and ergonomic way to handle application configuration from the environment, preventing runtime errors through compile-time type checking.

Target Audience

Rust developers building applications that require configuration via environment variables, particularly those using the Serde ecosystem for serialization and deserialization.

Value Proposition

Developers choose Envy for its seamless integration with Serde, offering type safety and flexibility with features like optional fields, vector support, and prefixed variables, all while adhering to Rust's philosophy of safety and explicitness.

Overview

deserialize env vars into typesafe structs with rust

Use Cases

Best For

  • Deserializing environment variables into type-safe Rust structs with compile-time validation.
  • Managing application configuration in Rust projects that use Serde for serialization.
  • Handling optional configuration fields where environment variables may be absent.
  • Parsing comma-separated environment variable values into Vec types.
  • Namespacing environment variables with custom prefixes to avoid naming conflicts in multi-service applications.
  • Setting sensible default values for configuration fields when environment variables are not provided.

Not Ideal For

  • Applications requiring dynamic configuration reloading without restarting, as Envy only deserializes at startup.
  • Projects that prefer configuration via TOML or JSON files without environment variable management overhead.
  • Teams already using comprehensive configuration crates like config-rs that support multiple sources and formats.

Pros & Cons

Pros

Type Safety and Compile-Time Checks

Envy deserializes environment variables into Rust structs with compile-time validation, preventing runtime errors as shown in examples where mismatched types cause deserialization failures.

Seamless Serde Integration

Built on Serde, it supports all Serde attributes for custom deserialization, such as using #[serde(default="function")] to specify defaults, enhancing flexibility.

Handles Optional and Vector Fields

Automatically manages missing env vars for Option types and parses comma-separated values into Vec, simplifying common configuration patterns without extra code.

Prefix Support for Namespacing

Provides envy::prefixed(prefix) to namespace env vars, avoiding conflicts in multi-service apps as demonstrated with the APP_ prefix example.

Cons

Limited Configuration Sources

Only deserializes from environment variables, so projects needing mixed sources like files or command-line arguments must integrate additional crates.

Static Deserialization Only

Configuration is loaded once at startup; Envy doesn't support hot-reloading of environment variables without manual reinitialization or external tools.

Serde Dependency Overhead

Heavy reliance on Serde adds compile-time complexity and requires familiarity with Serde's attributes for advanced customization, which can be a barrier.

Frequently Asked Questions

Quick Stats

Stars978
Forks44
Contributors0
Open Issues13
Last commit2 years ago
CreatedSince 2016

Tags

#environment-variables#serde#12-factor#type-safety#configuration#deserialization#configuration-management#rust#no-std#cli-tools#env

Built With

s
serde
R
Rust

Included in

Rust56.6k
Auto-fetched 17 hours ago

Related Projects

config-rsconfig-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).

Stars3,192
Forks264
Last commit4 days ago
FigmentFigment

A hierarchical configuration library so con-free, it's unreal.

Stars905
Forks51
Last commit1 year ago
configure_meconfigure_me

A Rust library for processing application configuration easily

Stars70
Forks19
Last commit1 year ago
cfg-rscfg-rs

A Configuration Library for Rust Applications

Stars55
Forks7
Last commit5 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub