pub struct IriReport { /* private fields */ }Expand description
A bounded tally of invalid IRIs — the shape both the build-time audit and the export-time sanitizer report.
Memory is constant, not proportional to the damage: per-class occurrence counters plus at most one example string per class. A graph where the same bad IRI appears ten million times costs five sample strings, not ten million.
Implementations§
Source§impl IriReport
impl IriReport
Sourcepub fn observe_term(&mut self, token: &str) -> Option<IriDefect>
pub fn observe_term(&mut self, token: &str) -> Option<IriDefect>
Classify one term token and record every defect it carries — an RDF-star quoted triple holds three IRIs and can be broken in three ways. Returns the first, so a strict caller can fail on the spot.
Sourcepub fn observe_quad(
&mut self,
s: &str,
p: &str,
o: &str,
g: Option<&str>,
) -> Option<IriDefect>
pub fn observe_quad( &mut self, s: &str, p: &str, o: &str, g: Option<&str>, ) -> Option<IriDefect>
Classify a whole statement — subject, predicate, object and (for N-Quads) the graph — recording every offending term and counting the statement once. Returns the first defect found.
Sourcepub fn sanitize<'a>(&mut self, token: &'a str) -> Cow<'a, str>
pub fn sanitize<'a>(&mut self, token: &'a str) -> Cow<'a, str>
Repair one term for export: percent-encode what escaping can fix, record what it found, and return the token to emit. An unrepairable IRI is counted and returned unchanged — the caller is told, and the data is not silently dropped or invented.
Sourcepub fn statements(&self) -> u64
pub fn statements(&self) -> u64
Statements carrying at least one invalid IRI (build audit only; the export sanitizer works term by term and leaves this at zero).
Sourcepub fn occurrences(&self) -> u64
pub fn occurrences(&self) -> u64
Invalid IRI term occurrences — the same IRI in a million statements counts a million times.
Sourcepub fn repaired(&self) -> u64
pub fn repaired(&self) -> u64
Occurrences IriReport::sanitize actually rewrote.
Sourcepub fn unrepairable(&self) -> u64
pub fn unrepairable(&self) -> u64
Occurrences no escaping can repair — every class for which
IriDefect::repairable is false, asked class by class rather than
named one at a time.
This is the number a publication gate must look at. > 0 means the dump
contains an IRI that is still invalid after everything the sanitizer
could do, so a strict loader will reject it. Gating on one specific class
instead is how an unrecognised defect gets published.
Sourcepub fn repairable(&self) -> u64
pub fn repairable(&self) -> u64
Occurrences escaping can repair. Complements IriReport::unrepairable
— the two partition IriReport::occurrences.
Sourcepub fn unclassified(&self) -> u64
pub fn unclassified(&self) -> u64
Occurrences the RFC 3987 parser rejected that no repair class
recognised — IriDefect::Unclassified.
Reported separately because it is the number that says the taxonomy has a
gap. It is already inside IriReport::unrepairable, so a gate that
reads that one does not need this; it is for the human who has to decide
whether a new class is worth adding.
Sourcepub fn sample(&self, defect: IriDefect) -> Option<&str>
pub fn sample(&self, defect: IriDefect) -> Option<&str>
The first term seen in this class, if any.