#[non_exhaustive]pub enum Case {
Upper,
Preserve,
}Expand description
How the case of names maps onto keys.
use std::collections::BTreeMap;
use deser_env::{Case, DeserializerConfig, SerializerConfig};
let vars = [("APP_Server__Port", "80")];
let value: BTreeMap<String, BTreeMap<String, u16>> =
deser_env::from_vars("APP_", vars).unwrap();
assert_eq!(value["server"]["port"], 80);
let preserve = DeserializerConfig::builder().case(Case::Preserve).build();
let value: BTreeMap<String, BTreeMap<String, u16>> =
preserve.from_vars("APP_", vars).unwrap();
assert_eq!(value["Server"]["Port"], 80);
let vars = deser_env::to_vars("APP_", &value).unwrap();
assert_eq!(vars, [("APP_SERVER__PORT".to_string(), "80".to_string())]);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Upper
Names are upper case and keys lower case.
When deserializing names are lowercased (ASCII only), so
APP_SERVER__PORT (and APP_server__port) is server.port. When
serializing keys are uppercased. Keys of maps that are not lower
case do not read back the same.
Preserve
Names and keys are the same.
This is useful if the types have names in upper case, for instance
with #[deser(alias_all = "SCREAMING_SNAKE_CASE")].
Trait Implementations§
impl Copy for Case
impl Eq for Case
impl StructuralPartialEq for Case
Auto Trait Implementations§
impl Freeze for Case
impl RefUnwindSafe for Case
impl Send for Case
impl Sync for Case
impl Unpin for Case
impl UnsafeUnpin for Case
impl UnwindSafe for Case
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more