#[non_exhaustive]pub enum LoadError {
Io(Error),
Env(VarError),
}Expand description
A possible error value while loading a Secret from a SecretLoader
Produced by the TryFrom<SecretLoader> implementation for SecretString
§Examples
use std::convert::TryFrom;
use std::convert::TryInto;
use secrecy::SecretString;
use secret_loader::LoadError;
use secret_loader::SecretLoader;
let plain_cred = SecretLoader::new("insecurepassword");
let secret: SecretString = plain_cred.try_into().expect("Plaintext credentials always convert");
// Env var may be missing
let env_cred = SecretLoader::new("env:MISSING_KEY");
let env_error = SecretString::try_from(env_cred).expect_err("Env var is not set");
assert!(matches!(env_error, LoadError::Env(_)));
// File may not available
let file_cred = SecretLoader::new("file:/does/not/exist");
let file_error = SecretString::try_from(file_cred).expect_err("File is missing");
assert!(matches!(file_error, LoadError::Io(_)));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.
Io(Error)
An IO error was encountered while attempting to read from a file
Env(VarError)
A VarError was encountered while attempting to read from the environment
Trait Implementations§
Source§impl Error for LoadError
impl Error for LoadError
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()
Auto Trait Implementations§
impl Freeze for LoadError
impl !RefUnwindSafe for LoadError
impl Send for LoadError
impl Sync for LoadError
impl Unpin for LoadError
impl !UnwindSafe for LoadError
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