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
impl IriDefect
Sourcepub const ALL: [IriDefect; 6]
pub const ALL: [IriDefect; 6]
Every class, in declaration order — the iteration order of a report.
Sourcepub fn reason(self) -> &'static str
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.
Sourcepub fn repairable(self) -> bool
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§
impl Copy for IriDefect
impl Eq for IriDefect
Source§impl Ord for IriDefect
impl Ord for IriDefect
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for IriDefect
impl PartialOrd for IriDefect
impl StructuralPartialEq for IriDefect
Auto Trait Implementations§
impl Freeze for IriDefect
impl RefUnwindSafe for IriDefect
impl Send for IriDefect
impl Sync for IriDefect
impl Unpin for IriDefect
impl UnsafeUnpin for IriDefect
impl UnwindSafe for IriDefect
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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