Skip to main content

Crate sorug

Crate sorug 

Source
Expand description

sorug — a blazingly fast, zero-allocation-preferred, WHATWG-compliant URL parser.

§Design

  • Index-based record: component boundaries live as u32 offsets into the WHATWG href serialization, keeping the struct small and cache-friendly.
  • Lazy / CoW serialization: when the input is already canonical ASCII, Url borrows it with zero heap allocations; the first required mutation upgrades to an owned buffer.
  • Cow on demand: percent-decoding helpers allocate only when needed.
  • SIMD delimiter scans: memchr on hot path segments.
  • Strict WHATWG state machine: transitions follow the URL Living Standard.

§Crate features

  • std (default): enables std::error::Error for ParseError, memchr’s std backend, and file-path / socket helpers.
  • serde: serialize / deserialize Url as an href string.
  • http: convert between Url and http::Uri (implies std).

§Migration from 0.4

Additive (non-breaking):

§Migration from 0.3

§API stability (pre-1.0)

  • Url<'a> borrows the input serialization when it is already canonical; call Url::into_owned before storing across mutations of the source.
  • Backing is public for advanced introspection; prefer Url::as_str.
  • [State] is #[doc(hidden)] and non_exhaustive — not part of the stability promise.
  • See the README Semver and MSRV policy and 1.0 freeze checklist.

§Migration from 0.2

Structs§

OpaqueOrigin
Opaque identifier for non-tuple origins (file:, data:, failed blob:, …).
PathSegmentsMut
Exposes methods to manipulate the path of a URL that is not cannot-be-a-base.
QueryPairsMut
Mutable view of a URL’s query as name/value pairs.
SearchParams
A list of name/value pairs in application/x-www-form-urlencoded syntax.
SearchParamsIter
Iterator over borrowed (name, value) pairs from SearchParams.
Url
A parsed URL record backed by its WHATWG serialization (href).
UrlFlags
Compact boolean attributes of a parsed URL record.

Enums§

Backing
Storage for the WHATWG href serialization.
Host
A parsed URL host: domain name, IPv4, or IPv6.
Origin
A URL origin: either an opaque origin or a (scheme, host, port) tuple.
ParseError
Failure modes of Url::parse / the basic URL parser.

Functions§

parse_urlencoded
Parse application/x-www-form-urlencoded bytes into decoded name/value pairs.
serialize_urlencoded
Serialize pairs as application/x-www-form-urlencoded.
uri_to_urlhttp
Parse an http::Uri into an owned Url.