pub struct Violation {
pub path: Option<Arc<Path>>,
pub message: Cow<'static, str>,
pub line: Option<usize>,
pub column: Option<usize>,
pub is_note: bool,
}Expand description
A single linting violation produced by a rule.
path holds an Arc<Path>; rules clone the Arc from
FileEntry::path (a cheap
atomic refcount bump) rather than copying the path bytes. At
100k violations this saves 100k path-byte allocations.
message is a Cow<'static, str>; per-match templated
messages live as Cow::Owned(String) (no change in cost),
while fixed messages can live as Cow::Borrowed("…") if a
rule chooses to construct them that way. Public API on the
struct is unchanged at the byte level — Display and serde
Serialize impls go through the inner &str / &Path.
Fields§
§path: Option<Arc<Path>>§message: Cow<'static, str>§line: Option<usize>§column: Option<usize>§is_note: boolTransient flag: when true, this is an informational note
(a non-violation finding — e.g. an entry a rule skipped rather
than failed on), not a real violation. Defaults to false.
The engine partitions notes out of RuleResult::violations
into RuleResult::notes at result-assembly time, so the flag
never reaches a formatter and pass/fail logic is unaffected.
Implementations§
Source§impl Violation
impl Violation
pub fn new(message: impl Into<Cow<'static, str>>) -> Self
Sourcepub fn as_note(self) -> Self
pub fn as_note(self) -> Self
Mark this finding as an informational note rather than a
violation. See Violation::is_note.
Sourcepub fn with_path(self, path: impl Into<Arc<Path>>) -> Self
pub fn with_path(self, path: impl Into<Arc<Path>>) -> Self
Attach a path to the violation. Accepts anything convertible
into Arc<Path> — the canonical caller is
.with_path(entry.path.clone()) where entry.path is the
Arc<Path> already owned by the FileIndex; this clones
the Arc (atomic refcount bump) rather than the bytes.
PathBuf, &Path, and Box<Path> are also accepted via
std’s From impls; for an ad-hoc &str use
Path::new("a.rs") to convert first.
pub fn with_location(self, line: usize, column: usize) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Violation
impl RefUnwindSafe for Violation
impl Send for Violation
impl Sync for Violation
impl Unpin for Violation
impl UnsafeUnpin for Violation
impl UnwindSafe for Violation
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<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