Struct spirit::validation::Result
source · pub struct Result { /* private fields */ }
Expand description
A validation result.
The validator (see config_validator
) is
supposed to return an arbitrary number of these results. Each one can hold a message (with
varying severity) and optionally a success and failure actions.
Implementations§
source§impl Result
impl Result
sourcepub fn new<S: Into<String>>(level: Level, s: S) -> Self
pub fn new<S: Into<String>>(level: Level, s: S) -> Self
Creates a result with given level and message.
sourcepub fn error<S: Into<String>>(s: S) -> Self
pub fn error<S: Into<String>>(s: S) -> Self
Creates an error result.
An error result not only gets to the logs, it also marks the whole config as invalid.
sourcepub fn from_error(e: FError) -> Self
pub fn from_error(e: FError) -> Self
Creates an error result from an actual Error
.
The error then is logged with additional information.
sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Returns the message texts.
sourcepub fn detailed_error(&self) -> &Option<FError>
pub fn detailed_error(&self) -> &Option<FError>
Returns an associated error if there’s one.
Note that the error text is already part of the description
.
sourcepub fn on_success<F: FnOnce() + 'static>(self, f: F) -> Self
pub fn on_success<F: FnOnce() + 'static>(self, f: F) -> Self
Attaches (replaces) the success action.