#[non_exhaustive]pub enum ApplyError {
EmptyKey,
InvalidKey {
key: String,
},
InvalidValue {
key: String,
},
}Expand description
A key or value that the process environment cannot hold.
Returned by validate, and by apply before it changes anything. It
reports the first problem, in key order. These are the inputs for which
std::env::set_var may panic. The error names the key but never includes
the value.
§Examples
Python dotenv lets a quoted key contain =. With 'APP=PORT'=8080 in
.env:
use adotenv::load::load_cascade_with;
use adotenv::Dialect;
use adotenv_process::{validate, ApplyError};
let loaded = load_cascade_with(&dir, "", Dialect::PYTHON_DOTENV)?;
match validate(&loaded) {
Err(ApplyError::InvalidKey { key }) => assert_eq!(key, "APP=PORT"),
other => panic!("expected an invalid key, got {other:?}"),
}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.
EmptyKey
A key is empty.
The adotenv loaders skip empty keys, so a loaded environment does not
produce this error; the check is a safeguard.
InvalidKey
A key contains NUL or =.
InvalidValue
A value contains NUL.
Trait Implementations§
Source§impl Clone for ApplyError
impl Clone for ApplyError
Source§impl Debug for ApplyError
impl Debug for ApplyError
Source§impl Display for ApplyError
impl Display for ApplyError
impl Eq for ApplyError
Source§impl Error for ApplyError
impl Error for ApplyError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for ApplyError
impl PartialEq for ApplyError
impl StructuralPartialEq for ApplyError
Auto Trait Implementations§
impl Freeze for ApplyError
impl RefUnwindSafe for ApplyError
impl Send for ApplyError
impl Sync for ApplyError
impl Unpin for ApplyError
impl UnsafeUnpin for ApplyError
impl UnwindSafe for ApplyError
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