pub struct EnvVar { /* private fields */ }Expand description
The environment variable an error refers to.
Errors of values and keys that come from environment variables carry
this attachment. For keys that more than
one variable share (like server in APP_SERVER__HOST and
APP_SERVER__PORT) it’s the name up to the key (APP_SERVER). Errors
that do not come from a single variable (like missing fields) have none.
use deser_env::EnvVar;
#[derive(Debug, deser::Deserialize)]
struct Config {
server: Server,
}
#[derive(Debug, deser::Deserialize)]
#[deser(deny_unknown_fields)]
struct Server {
port: u16,
}
let err = deser_env::from_vars::<Config, _, _, _>(
"APP_",
[("APP_SERVER__PROT", "80")],
)
.unwrap_err();
assert_eq!(err.message(), "unknown field `prot`, expected `port`");
assert_eq!(
err.attachment::<EnvVar>().unwrap().name(),
"APP_SERVER__PROT"
);Implementations§
Trait Implementations§
impl Eq for EnvVar
Source§impl ErrorAttachment for EnvVar
impl ErrorAttachment for EnvVar
impl StructuralPartialEq for EnvVar
Auto Trait Implementations§
impl Freeze for EnvVar
impl RefUnwindSafe for EnvVar
impl Send for EnvVar
impl Sync for EnvVar
impl Unpin for EnvVar
impl UnsafeUnpin for EnvVar
impl UnwindSafe for EnvVar
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