iri-rs-core
Core types and parser for the iri-rs workspace. Fork of iref by Timothée Haudebourg. URI and IRI parsing, component access, in-place mutation, reference resolution, normalization, equivalence.
foo://user@example.com:8042/over/there?name=ferret#nose
└┬┘ └──────────┬────────┘└────┬────┘└────┬─────┘└┬─┘
│ │ │ │ │
scheme authority path query fragment
Most users should depend on the facade crate iri-rs instead. Depend on iri-rs-core directly only if you want none of the optional features from the facade — or if you're building another crate on top (the iri-rs-static and iri-rs-enum proc-macros emit paths against ::iri_rs_core, so downstream crates using them must have this crate as a direct dependency).
use ;
let iri = parse?;
assert_eq!;
let mut buf = new?;
buf.set_path?;
assert_eq!;
Install
Feature flags
| Flag | Default | Enables |
|---|---|---|
serde |
Serialize / Deserialize for borrowed and owned types |
|
bytewise |
Compare, hash and order byte-wise instead of RFC 3987 normalization |
bytewise changes comparison, not just hashing
bytewise swaps the PartialEq, Eq, Hash, PartialOrd and Ord impls of Iri, IriRef, Uri and UriRef for byte-wise ones. Without it, those impls compare and hash the RFC 3987 normalized form, so http://example.com/%7Ea and http://example.com/~a are equal and hash alike. With it, they are two different IRIs. Byte-wise is considerably cheaper, and it is the right choice when the IRIs you hold are already in the form you want to compare, but it is a semantic change and not only a speed one.
Cargo unifies features across a dependency graph, which makes this a global switch: one dependency enabling bytewise changes IRI equality for every crate in the build, including crates that never asked for it. Enable it in an application, or in a library whose whole graph you control, rather than in a library published for others to combine.
What's inside
Iri/IriBuf,IriRef/IriRefBuf— IRIs and IRI references (RFC 3987).Uri/UriBuf,UriRef/UriRefBuf— URIs and URI references (RFC 3986).Positions— pre-computed component ends. Used byfrom_raw_partsfor const construction iniri-rs-staticandiri-rs-enum.- Strict RFC 3986 §5 reference resolution with Errata 4547.
- Path normalization, protocol-agnostic equivalence, percent-decoding-aware comparison via
pct.
Performance notes
simdutf8for fast UTF-8 validation.memchrfor%and delimiter scans.- SWAR / byte-level fast paths on
new,eq,ord,hash,len. smallvecfor small-path accumulation in resolution / normalization.
Benchmarks
Covers parse, accessors, resolve, normalize, mutate, normalize_eq, validate. Criterion output: target/criterion/.
Workspace
Part of the iri-rs workspace. See the root README for the overall picture, motivation, and fork attribution.
MSRV
Rust 1.85 (edition 2024).
License
Dual-licensed: