pub struct ConfigErrors(pub NonEmptyVec<ConfigError>);Expand description
A non-empty collection of configuration errors.
Uses NonEmptyVec from stillwater to guarantee at least one error exists.
This prevents the “empty error list” anti-pattern and enables safe first().
Tuple Fields§
§0: NonEmptyVec<ConfigError>Implementations§
Source§impl ConfigErrors
impl ConfigErrors
Sourcepub fn single(error: ConfigError) -> Self
pub fn single(error: ConfigError) -> Self
Create from a single error.
Sourcepub fn from_nonempty(errors: NonEmptyVec<ConfigError>) -> Self
pub fn from_nonempty(errors: NonEmptyVec<ConfigError>) -> Self
Create from a non-empty vec.
Sourcepub fn from_vec(errors: Vec<ConfigError>) -> Option<Self>
pub fn from_vec(errors: Vec<ConfigError>) -> Option<Self>
Try to create from a vec, returning None if empty.
Sourcepub fn first(&self) -> &ConfigError
pub fn first(&self) -> &ConfigError
Get the first error (always exists).
Sourcepub fn as_slice(&self) -> Vec<&ConfigError>
pub fn as_slice(&self) -> Vec<&ConfigError>
Get all errors as a slice.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if empty (always false, but required for API consistency).
Sourcepub fn iter(&self) -> impl Iterator<Item = &ConfigError>
pub fn iter(&self) -> impl Iterator<Item = &ConfigError>
Iterate over errors.
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
Add context to all errors.
Sourcepub fn with_path_prefix(self, prefix: &str) -> Self
pub fn with_path_prefix(self, prefix: &str) -> Self
Add a path prefix to all error paths.
This is used for nested validation to add parent context to error paths. For example, if an error has path “port” and prefix is “database”, the resulting path will be “database.port”.
Source§impl ConfigErrors
impl ConfigErrors
Sourcepub fn pretty_print(&self, options: &PrettyPrintOptions)
pub fn pretty_print(&self, options: &PrettyPrintOptions)
Pretty print errors to stderr.
§Stillwater Integration
ConfigErrors wraps NonEmptyVec<ConfigError>, guaranteeing at least
one error exists. This eliminates empty-error-list edge cases.
Sourcepub fn format(&self, options: &PrettyPrintOptions) -> String
pub fn format(&self, options: &PrettyPrintOptions) -> String
Pretty print to a string (for testing).
Sourcepub fn pretty_print_default(&self)
pub fn pretty_print_default(&self)
Pretty print with default options.
Trait Implementations§
Source§impl Clone for ConfigErrors
impl Clone for ConfigErrors
Source§fn clone(&self) -> ConfigErrors
fn clone(&self) -> ConfigErrors
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more