Renvar
renvar is a library to deserialize environment variables into Rust data structures.
Huge thanks to softprops for envy, as this library is inspired by it and borrows much of the code from there.
Installation
Add it to your Cargo.toml
[]
= "0.1"
Usage
use ;
use Deserialize;
use env;
let env_content = r#"
name=renvar
type=Library
dependencies=serde
"#;
let actual = Renvar ;
// we can read from strings
let value = .unwrap;
assert_eq!;
// directly from the environment
let envs = vec!;
for in envs.clone.into_iter
let value = .unwrap;
assert_eq!;
// or from iterables
let value = .unwrap;
assert_eq!;
Feature flags
Renvar has the following feature flags:
prefixed
prefixed gives you the prefixed function, that accepts a prefix. The prefixes will be stripped away
before deserialization.
postfixed
postfix is exactly the same as prefix, just with postfixes
case_insensitive_prefixed
Case insensitive variant of prefixed
case_insensitive_postfixed
Case insensitive variant of postfixed
with_trimmer
Finally, the with_trimmer feature flag gives you *_with_trimmer variants for all of the above,
where you can strip extraneous characters off of the beginning and end of envrironment variables
by passing a closure.
Supported datatypes
StringsandstrsenumssequencesUnit structs
Development
Tests
If you have just, you run just test,
otherwise cargo test --all-features