pub enum ValidationResult {
Success {
metrics: ValidationMetrics,
report: ValidationReport,
},
Failure {
report: ValidationReport,
},
}Expand description
The result of running a validation suite.
Variants§
Success
Validation completed successfully with no critical issues
Fields
metrics: ValidationMetricsValidation metrics
report: ValidationReportDetailed report (may contain warnings or info)
Failure
Validation failed due to one or more critical issues
Fields
report: ValidationReportDetailed report containing the issues
Implementations§
Source§impl ValidationResult
impl ValidationResult
Sourcepub fn success(metrics: ValidationMetrics, report: ValidationReport) -> Self
pub fn success(metrics: ValidationMetrics, report: ValidationReport) -> Self
Creates a successful validation result.
Sourcepub fn failure(report: ValidationReport) -> Self
pub fn failure(report: ValidationReport) -> Self
Creates a failed validation result.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the validation succeeded.
Sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
Returns true if the validation failed.
Sourcepub fn report(&self) -> &ValidationReport
pub fn report(&self) -> &ValidationReport
Returns the validation report.
Sourcepub fn metrics(&self) -> Option<&ValidationMetrics>
pub fn metrics(&self) -> Option<&ValidationMetrics>
Returns the validation metrics if available (only for success).
Sourcepub fn to_json(&self) -> Result<String>
pub fn to_json(&self) -> Result<String>
Formats the validation result as JSON.
This is a convenience method that uses the JsonFormatter to output
the result as structured JSON.
§Examples
let json_output = result.to_json().unwrap();
println!("{}", json_output);Sourcepub fn to_json_pretty(&self) -> Result<String>
pub fn to_json_pretty(&self) -> Result<String>
Formats the validation result as JSON with pretty printing.
§Examples
let pretty_json = result.to_json_pretty().unwrap();
println!("{}", pretty_json);Sourcepub fn to_human(&self) -> Result<String>
pub fn to_human(&self) -> Result<String>
Formats the validation result in a human-readable format.
This is a convenience method that uses the HumanFormatter to output
the result in a format suitable for console display.
§Examples
let human_output = result.to_human().unwrap();
println!("{}", human_output);Sourcepub fn to_markdown(&self) -> Result<String>
pub fn to_markdown(&self) -> Result<String>
Formats the validation result as Markdown.
This is a convenience method that uses the MarkdownFormatter to output
the result in Markdown format suitable for documentation.
§Examples
let markdown_output = result.to_markdown().unwrap();
println!("{}", markdown_output);Sourcepub fn format_with<F: ResultFormatter>(&self, formatter: &F) -> Result<String>
pub fn format_with<F: ResultFormatter>(&self, formatter: &F) -> Result<String>
Formats the validation result using a custom formatter.
§Arguments
formatter- The formatter to use
§Examples
use term_guard::formatters::{ResultFormatter, HumanFormatter, FormatterConfig};
let config = FormatterConfig::minimal();
let formatter = HumanFormatter::with_config(config);
let output = result.format_with(&formatter).unwrap();
println!("{}", output);Trait Implementations§
Source§impl Clone for ValidationResult
impl Clone for ValidationResult
Source§fn clone(&self) -> ValidationResult
fn clone(&self) -> ValidationResult
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 ValidationResult
impl Debug for ValidationResult
Source§impl<'de> Deserialize<'de> for ValidationResult
impl<'de> Deserialize<'de> for ValidationResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ValidationResult
impl RefUnwindSafe for ValidationResult
impl Send for ValidationResult
impl Sync for ValidationResult
impl Unpin for ValidationResult
impl UnsafeUnpin for ValidationResult
impl UnwindSafe for ValidationResult
Blanket Implementations§
impl<T> Allocation for T
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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