Skip to main content

IriDefect

Enum IriDefect 

Source
pub enum IriDefect {
    NotAbsolute,
    ForbiddenChar,
    Bracket,
    ExtraHash,
    BadPercent,
    Unclassified,
}
Expand description

Why an IRI is not one — a repair classification, not the validity verdict. iri_content_defect decides validity with an RFC 3987 parser and uses these only to say what, if anything, can be done about it.

The classes are ordered by how they are found, not by severity; IriDefect::NotAbsolute is checked first because it is a property of the whole IRI, and IriDefect::Unclassified last because it is what is left when no other class explains a parser rejection.

Variants§

§

NotAbsolute

No scheme: prefix, so the IRIREF is relative. N-Triples requires an absolute IRI. Not repairable — see the module docs.

§

ForbiddenChar

A character the IRIREF production excludes outright: U+0000–U+0020 (space and the controls), U+007F, and < > " { } | ^ `. A backslash that opens a well-formed UCHAR (\uXXXX / \UXXXXXXXX) is fine.

§

Bracket

[ or ] outside an IP-literal host. RFC 3987 reserves the brackets for http://[::1]/…; anywhere else — a path, a query — they must be percent-encoded. The single largest class in the field data (unescaped brackets in harvested PDF URLs).

§

ExtraHash

More than one #. The first starts the fragment; a # inside a fragment is not a pchar and must be %23.

§

BadPercent

A % not followed by two hex digits, so it is not a pct-encoded triplet. Often the trace of a broken string template rather than an escaping mistake (%x, %p) — escaping it makes the dump loadable without making the IRI right, which is the publisher’s bug to fix.

§

Unclassified

The RFC 3987 parser rejected it and no class above explains why. Either the defect is a shape this taxonomy has never seen (https://::1 — an IPv6 literal in the authority without its brackets, the case this bucket was added for), or escaping the shape that was recognised still leaves an IRI the parser refuses.

Not repairable — we do not know what is wrong, so we cannot claim to have fixed it. It is counted and it blocks, which is the whole point: a gap in the taxonomy must never read as a clean bill of health. Adding a class later only moves occurrences out of here; it never turns an invalid IRI into a valid one.

Implementations§

Source§

impl IriDefect

Source

pub const ALL: [IriDefect; 6]

Every class, in declaration order — the iteration order of a report.

Source

pub fn index(self) -> usize

Index into a report’s per-class counters.

Source

pub fn reason(self) -> &'static str

A short human reason, for a warning line.

These strings are parsed downstream — scripts/export_scholar_nquads.sh matches a stable fragment of each to fill state.tsv. Changing one means changing that parser in the same commit.

Source

pub fn repairable(self) -> bool

Can percent-encoding repair it without inventing information?

Everything except IriDefect::NotAbsolute, which needs a base IRI the file does not carry, and IriDefect::Unclassified, where we do not know what is wrong.

Callers deciding whether a dump may be published must ask this, over every class — never whether a particular class is present. Hardcoding one class is how <https://::1> got through.

Trait Implementations§

Source§

impl Clone for IriDefect

Source§

fn clone(&self) -> IriDefect

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 Copy for IriDefect

Source§

impl Debug for IriDefect

Source§

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

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

impl Eq for IriDefect

Source§

impl Hash for IriDefect

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for IriDefect

Source§

fn cmp(&self, other: &IriDefect) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for IriDefect

Source§

fn eq(&self, other: &IriDefect) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for IriDefect

Source§

fn partial_cmp(&self, other: &IriDefect) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for IriDefect

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