pub struct ValidationReport { /* private fields */ }Expand description
A collection of validation results: errors, warnings, and info.
Enables batch validation where all issues are collected instead of failing on the first error.
Implementations§
Source§impl ValidationReport
impl ValidationReport
Sourcepub fn errors(&self) -> &[ValidationIssue]
pub fn errors(&self) -> &[ValidationIssue]
Returns all error-level ValidationIssues in this report.
Sourcepub fn errors_mut(&mut self) -> &mut [ValidationIssue]
pub fn errors_mut(&mut self) -> &mut [ValidationIssue]
Returns all error-level ValidationIssues mutably.
Sourcepub fn warnings(&self) -> &[ValidationIssue]
pub fn warnings(&self) -> &[ValidationIssue]
Returns all warning-level ValidationIssues in this report.
Sourcepub fn warnings_mut(&mut self) -> &mut [ValidationIssue]
pub fn warnings_mut(&mut self) -> &mut [ValidationIssue]
Returns all warning-level ValidationIssues mutably.
Sourcepub fn infos(&self) -> &[ValidationIssue]
pub fn infos(&self) -> &[ValidationIssue]
Returns all informational ValidationIssues in this report.
Sourcepub fn infos_mut(&mut self) -> &mut [ValidationIssue]
pub fn infos_mut(&mut self) -> &mut [ValidationIssue]
Returns all informational ValidationIssues mutably.
Sourcepub fn add_error(&mut self, issue: ValidationIssue)
pub fn add_error(&mut self, issue: ValidationIssue)
Add an error to the report.
Sourcepub fn add_warning(&mut self, issue: ValidationIssue)
pub fn add_warning(&mut self, issue: ValidationIssue)
Add a warning to the report.
Sourcepub fn add_info(&mut self, issue: ValidationIssue)
pub fn add_info(&mut self, issue: ValidationIssue)
Add an info message to the report.
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Check if the report has any errors.
Sourcepub fn has_warnings(&self) -> bool
pub fn has_warnings(&self) -> bool
Check if the report has any warnings.
Sourcepub fn total_issues(&self) -> usize
pub fn total_issues(&self) -> usize
Get the total count of all issues.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if the validation passed (no errors, but may have warnings).
Sourcepub fn result(self) -> Result<Self, Self>
pub fn result(self) -> Result<Self, Self>
Convert to a Result.
Returns Ok(self) when there are no errors. Returns Err(self) when
there is at least one error-level issue, preserving warnings and infos
in the Err variant so callers can inspect the full report.
Sourcepub fn iter_issues(&self) -> impl Iterator<Item = &ValidationIssue>
pub fn iter_issues(&self) -> impl Iterator<Item = &ValidationIssue>
Iterate over all issues in severity buckets: errors, warnings, then infos.
Sourcepub fn has_any_issues(&self) -> bool
pub fn has_any_issues(&self) -> bool
Return true if the report contains any issues (errors, warnings, or infos).
Sourcepub fn merge(&mut self, other: ValidationReport)
pub fn merge(&mut self, other: ValidationReport)
Drain all issues from other into self.
Issues are appended in severity order: errors, warnings, infos.
other is left empty after this call.
Sourcepub fn issues_for_rule_id<'a>(
&'a self,
rule_id: &'a str,
) -> impl Iterator<Item = &'a ValidationIssue> + 'a
pub fn issues_for_rule_id<'a>( &'a self, rule_id: &'a str, ) -> impl Iterator<Item = &'a ValidationIssue> + 'a
Iterate over all issues matching an exact profile/MIG rule identifier.
Searches errors, warnings, and infos in that order. Returns a lazy
iterator; collect into Vec if you need random access.
Sourcepub fn filter_by_rule_id(&self, rule_id: &str) -> Self
pub fn filter_by_rule_id(&self, rule_id: &str) -> Self
Return a cloned report containing only issues with an exact rule identifier.
Sourcepub fn filter_by_rule_prefix(&self, prefix: &str) -> Self
pub fn filter_by_rule_prefix(&self, prefix: &str) -> Self
Return a cloned report containing only issues whose rule identifier starts with prefix.
Sourcepub fn for_segment(&self, segment_tag: &str) -> Self
pub fn for_segment(&self, segment_tag: &str) -> Self
Return a cloned report containing only issues that reference segment_tag.
Issues whose segment_tag field does not match are dropped; the severity
buckets (errors / warnings / infos) are preserved.
§Example
use edifact_rs::{ValidationReport, ValidationIssue, ValidationSeverity};
let mut report = ValidationReport::default();
report.add_error(
ValidationIssue::new(ValidationSeverity::Error, "BGM missing")
.with_segment("BGM"),
);
report.add_error(
ValidationIssue::new(ValidationSeverity::Error, "NAD missing")
.with_segment("NAD"),
);
let bgm_issues = report.for_segment("BGM");
assert_eq!(bgm_issues.errors().len(), 1);
assert_eq!(bgm_issues.errors()[0].segment_tag.as_deref(), Some("BGM"));Sourcepub fn render_deterministic(&self) -> String
pub fn render_deterministic(&self) -> String
Return a deterministic, stable text representation for snapshots and logs.
Trait Implementations§
Source§impl Clone for ValidationReport
impl Clone for ValidationReport
Source§fn clone(&self) -> ValidationReport
fn clone(&self) -> ValidationReport
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 ValidationReport
impl Debug for ValidationReport
Source§impl Default for ValidationReport
impl Default for ValidationReport
Source§fn default() -> ValidationReport
fn default() -> ValidationReport
Source§impl Diagnostic for ValidationReport
Available on crate feature diagnostics only.
impl Diagnostic for ValidationReport
diagnostics only.Source§fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz) is recommended, but more classic codes like
E0123 or enums will work just fine.Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read moreSource§fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s Diagnostic::labels to.Source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s Diagnostic::source_codeDiagnostics.Source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§impl Display for ValidationReport
impl Display for ValidationReport
Source§impl Error for ValidationReport
impl Error for ValidationReport
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 ValidationReport
impl PartialEq for ValidationReport
Source§fn eq(&self, other: &ValidationReport) -> bool
fn eq(&self, other: &ValidationReport) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ValidationReport
impl Serialize for ValidationReport
impl StructuralPartialEq for ValidationReport
Auto Trait Implementations§
impl Freeze for ValidationReport
impl RefUnwindSafe for ValidationReport
impl Send for ValidationReport
impl Sync for ValidationReport
impl Unpin for ValidationReport
impl UnsafeUnpin for ValidationReport
impl UnwindSafe for ValidationReport
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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more