#[non_exhaustive]pub enum ApplyError {
EmptyKey,
InvalidKey {
key: String,
},
InvalidValue {
key: String,
},
DuplicateKey {
key: String,
},
ValueTooLong {
key: String,
limit: usize,
},
}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
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.
DuplicateKey
Two keys collide on a case-insensitive platform.
Windows environment variable names are case-insensitive. This variant is returned only on Windows.
ValueTooLong
A value is too long for the platform.
Windows accepts at most 32,767 UTF-16 code units per value. This variant is returned only on Windows.
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()