Skip to main content

IriReport

Struct IriReport 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn is_empty(&self) -> bool

Nothing invalid was seen.

Source

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).

Source

pub fn occurrences(&self) -> u64

Invalid IRI term occurrences — the same IRI in a million statements counts a million times.

Source

pub fn repaired(&self) -> u64

Occurrences IriReport::sanitize actually rewrote.

Source

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.

Source

pub fn repairable(&self) -> u64

Occurrences escaping can repair. Complements IriReport::unrepairable — the two partition IriReport::occurrences.

Source

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.

Source

pub fn count(&self, defect: IriDefect) -> u64

Per-class occurrence count.

Source

pub fn sample(&self, defect: IriDefect) -> Option<&str>

The first term seen in this class, if any.

Source

pub fn classes(&self) -> impl Iterator<Item = (IriDefect, u64, Option<&str>)>

The non-empty classes, in declaration order, with their count and example — the rows of a warning block.

Source

pub fn merge(&mut self, other: &IriReport)

Fold another report in — used to total the per-input audits of a multi-input build.

Trait Implementations§

Source§

impl Clone for IriReport

Source§

fn clone(&self) -> IriReport

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IriReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for IriReport

Source§

fn default() -> IriReport

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V