1 unstable release
| 0.1.0 | Aug 11, 2025 |
|---|
#969 in Rust patterns
23,602 downloads per month
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