1 unstable release

0.1.0 Aug 11, 2025

#969 in Rust patterns

Download history 3484/week @ 2025-11-13 2708/week @ 2025-11-20 1448/week @ 2025-11-27 4309/week @ 2025-12-04 3820/week @ 2025-12-11 2433/week @ 2025-12-18 1023/week @ 2025-12-25 1461/week @ 2026-01-01 3449/week @ 2026-01-08 3050/week @ 2026-01-15 4684/week @ 2026-01-22 5665/week @ 2026-01-29 6275/week @ 2026-02-05 4490/week @ 2026-02-12 7219/week @ 2026-02-19 4671/week @ 2026-02-26

23,602 downloads per month

Apache-2.0

16KB
102 lines

Environment Variables Provider

This Rust library provides a feature flag provider that resolves feature flags from environment variables.

Supported Types

The provider supports the following types:

  • Int
  • Float
  • String
  • Bool

Please note that Struct type is not currently supported yet.

Error Handling

The provider will return EvaluationResult::Err(EvaluationError) if the flag is not found or if the value is not of the expected type.

Usage

Add this to your Cargo.toml:

[dependencies]
open-feature-env-var = "0.1.0"

Example


let mut api = OpenFeature::singleton_mut().await;
let provider  = EnvVarProvider::default();
api.set_provider(provider).await;
let client = api.create_named_client("env-var-client");

let mut message =  "Hello rustaceans!";
let is_feature_enabled = client.get_bool_value("env-flag-key", &EvaluationContext::default(), None).await.unwrap_or(false);

if is_feature_enabled {
    message = "Hello rustaceans from feature flag!";
}

Testing

Run cargo test to execute tests.

Maintainers

License

Apache 2.0 - See LICENSE for more information.

Dependencies

~3.5–5MB
~82K SLoC