Expand description
§rust-env
rust-env is a lightweight environment configuration library for Rust.
It helps you manage .env-style configuration files with support for:
- Key-value pairs
- Vector (list) values using
;separators - Runtime OS environment variables
- Reading and writing environment files
§Features
- Parse
.envfiles into structured data - Support for string and vector values
- Access local and global environment variables
- Modify and persist environment files
- Simple helper API for extracting values
§Value Model
Internally, rust-env represents data using:
Str(key, value)Vec(key, Vec<String>)Comment(String)
§Example
use rust_env::Env;
let mut env = Env::new("./.env");
let port = env.get_pair("PORT");
env.set(Str("PORT", "8080"));§Local vs Global
- Local: values loaded from
.envfile - Global: OS environment variables
When using merged lookup:
global > local§Notes
- All values are stored as strings internally
- Vector values are separated using
; - File writes occur immediately when using
set
§Version History
§v0.2.0
- Added
match_strandmatch_vechelpers - Refactored codebase into multiple files
- Fixed 3 known bugs
§Experimental
Experimental features such as a future markup language (RML) are not part of this crate.
They may be developed separately in the future.
Structs§
- Env
- The main environment container used by
rust-env.
Enums§
- Pair
- Wrapper
- This enum mainly rap two type of data
String and
Vec<String>See docs ofstruct Envof this package for learn more
Traits§
- EnvFrame
- A trait that defines the core behavior of an environment system.