#[non_exhaustive]pub enum SettingsError {
Parse {
key: String,
value_kind: &'static str,
},
OutOfRange {
key: String,
message: &'static str,
},
}Expand description
Why a *Settings::from_env call failed. OutboxSettings::from_env (reliar-outbox) was the
first caller; every provider’s own from_env returns this same type, so a host wiring
several from_env calls handles one error type for the whole family.
use reliar_core::SettingsError;
let err = SettingsError::parse("RELIAR_OUTBOX_BATCH_SIZE", "u32");
assert_eq!(err.key(), "RELIAR_OUTBOX_BATCH_SIZE");
assert!(err.to_string().contains("could not be parsed"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse
A present variable could not be parsed as its declared type. The value is never echoed — it may carry an operator’s typo of something sensitive.
Fields
OutOfRange
A present variable parsed but violated a documented bound.
Implementations§
Source§impl SettingsError
Public constructors, because every provider’s from_env returns this type.
SettingsError is #[non_exhaustive], so a crate other than the one defining a given
Settings type — e.g. reliar-store-postgres — cannot build a variant with struct-literal
syntax; without these a provider is forced into a parallel, unrelated error type, and a host
wiring two from_env calls ends up handling two different errors for the same class of
failure (ADR 0019).
impl SettingsError
Public constructors, because every provider’s from_env returns this type.
SettingsError is #[non_exhaustive], so a crate other than the one defining a given
Settings type — e.g. reliar-store-postgres — cannot build a variant with struct-literal
syntax; without these a provider is forced into a parallel, unrelated error type, and a host
wiring two from_env calls ends up handling two different errors for the same class of
failure (ADR 0019).
Sourcepub fn parse(key: impl Into<String>, value_kind: &'static str) -> SettingsError
pub fn parse(key: impl Into<String>, value_kind: &'static str) -> SettingsError
The variable was present but did not parse. value_kind names the expected shape
("u32", "milliseconds"); the offending value is never carried.
use reliar_core::SettingsError;
let err = SettingsError::parse("RELIAR_OUTBOX_BATCH_SIZE", "u32");
assert_eq!(err.key(), "RELIAR_OUTBOX_BATCH_SIZE");Sourcepub fn out_of_range(
key: impl Into<String>,
message: &'static str,
) -> SettingsError
pub fn out_of_range( key: impl Into<String>, message: &'static str, ) -> SettingsError
The variable parsed but is outside the range the setting accepts.
use reliar_core::SettingsError;
let err = SettingsError::out_of_range("RELIAR_OUTBOX_LEASE_SECS", "must be at least 1");
assert!(err.to_string().contains("out of range"));Trait Implementations§
Source§impl Clone for SettingsError
impl Clone for SettingsError
Source§fn clone(&self) -> SettingsError
fn clone(&self) -> SettingsError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SettingsError
impl Debug for SettingsError
Source§impl Display for SettingsError
impl Display for SettingsError
Source§impl Error for SettingsError
impl Error for SettingsError
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()
Source§impl PartialEq for SettingsError
impl PartialEq for SettingsError
impl StructuralPartialEq for SettingsError
Auto Trait Implementations§
impl Freeze for SettingsError
impl RefUnwindSafe for SettingsError
impl Send for SettingsError
impl Sync for SettingsError
impl Unpin for SettingsError
impl UnsafeUnpin for SettingsError
impl UnwindSafe for SettingsError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more