pub struct ValidationIssue {
pub severity: ValidationSeverity,
pub line: Option<usize>,
pub column: Option<usize>,
pub message: String,
pub rule: String,
pub suggestion: Option<String>,
}Expand description
A validation issue found in the document
Fields§
§severity: ValidationSeveritySeverity of the issue
line: Option<usize>Line number where the issue occurs (1-indexed)
column: Option<usize>Column number where the issue occurs (1-indexed)
message: StringHuman-readable description of the issue
rule: StringRule or check that generated this issue
suggestion: Option<String>Suggested fix for the issue (if available)
Implementations§
Source§impl ValidationIssue
impl ValidationIssue
Sourcepub fn new(severity: ValidationSeverity, message: String, rule: String) -> Self
pub fn new(severity: ValidationSeverity, message: String, rule: String) -> Self
Create a new validation issue
§Examples
use ass_editor::utils::validator::{ValidationIssue, ValidationSeverity};
let issue = ValidationIssue::new(
ValidationSeverity::Warning,
"Missing subtitle end time".to_string(),
"timing_check".to_string()
)
.at_location(10, 25)
.with_suggestion("Add explicit end time".to_string());
assert_eq!(issue.line, Some(10));
assert_eq!(issue.column, Some(25));
assert!(!issue.is_error());Sourcepub fn at_location(self, line: usize, column: usize) -> Self
pub fn at_location(self, line: usize, column: usize) -> Self
Set the location of this issue
Sourcepub fn with_suggestion(self, suggestion: String) -> Self
pub fn with_suggestion(self, suggestion: String) -> Self
Add a suggestion for fixing this issue
Sourcepub const fn is_warning_or_higher(&self) -> bool
pub const fn is_warning_or_higher(&self) -> bool
Check if this is a warning or higher
Trait Implementations§
Source§impl Clone for ValidationIssue
impl Clone for ValidationIssue
Source§fn clone(&self) -> ValidationIssue
fn clone(&self) -> ValidationIssue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidationIssue
impl Debug for ValidationIssue
Source§impl PartialEq for ValidationIssue
impl PartialEq for ValidationIssue
impl Eq for ValidationIssue
impl StructuralPartialEq for ValidationIssue
Auto Trait Implementations§
impl Freeze for ValidationIssue
impl RefUnwindSafe for ValidationIssue
impl Send for ValidationIssue
impl Sync for ValidationIssue
impl Unpin for ValidationIssue
impl UnwindSafe for ValidationIssue
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
Mutably borrows from an owned value. Read more