iri-rs-core 3.3.3

Core types, parser, resolver and normalizer for URIs/IRIs (RFC 3986/3987). Borrowed and owned, allocation-conscious, SIMD/SWAR-accelerated.
Documentation

iri-rs-core

Crate Docs MSRV License

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 iri_rs_core::{Iri, IriBuf};

let iri = Iri::parse("https://www.rust-lang.org/foo?q#f")?;
assert_eq!(iri.scheme(), "https");

let mut buf = IriBuf::new("https://rust-lang.org")?;
buf.set_path("/foo")?;
assert_eq!(buf, "https://rust-lang.org/foo");

Install

cargo add iri-rs-core

Feature flags

Flag Default Enables
serde Serialize / Deserialize for borrowed and owned types
fast-hash Skip re-parse on Hash — trades stricter invariants for speed

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 by from_raw_parts for const construction in iri-rs-static and iri-rs-enum.
  • Strict RFC 3986 §5 reference resolution with Errata 4547.
  • Path normalization, protocol-agnostic equivalence, percent-decoding-aware comparison via pct.

Performance notes

  • simdutf8 for fast UTF-8 validation.
  • memchr for % and delimiter scans.
  • SWAR / byte-level fast paths on new, eq, ord, hash, len.
  • smallvec for small-path accumulation in resolution / normalization.

Benchmarks

cargo bench -p iri-rs-core

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: