Expand description
Built-in data: driver — inline byte literals embedded in the URI.
Implements RFC 2397 (dataurl := "data:" [ mediatype ] [ ";base64" ] "," data). The driver returns a BytesSource backed by an in-memory
Cursor — no IO, no allocation past the payload, no external state.
Useful for:
- Fixture URIs embedded in tests or CLI flags without a temp file.
- Single-shot transports where the entire payload fits in the URI (small icons, calibration tones, RTP-payload trace dumps).
- Configuration knobs that take a URI and would otherwise need a
sentinel like
--no-inputto mean “use these bytes literally”.
Grammar (RFC 2397 §3, abbreviated):
dataurl = "data:" [ mediatype ] [ ";base64" ] "," data
mediatype = [ type "/" subtype ] *( ";" parameter )
parameter = attribute "=" value
data = *urlcharWhen mediatype is absent the RFC defaults it to
text/plain;charset=US-ASCII. The driver does not interpret the
media type — it only carries the bytes — but parse surfaces the
parsed string so callers can route based on it.
Encodings:
;base64present: payload is base64-decoded per RFC 4648 §4 (“standard” alphabet with+/). Whitespace in the payload is tolerated and skipped. Padding is required to make the input length a multiple of four.- Otherwise: payload is percent-decoded (
%HH→ byte0xHH). Non-%bytes pass through unchanged.
Clean-room note: RFC 2397 was read as the only reference. No
external data: URL implementation was consulted.
Structs§
- DataUri
- Parsed components of a
data:URI.
Functions§
- open_
data - Open a
data:URI as aBytesSource. Equivalent toparsefollowed by wrapping the decoded bytes in aCursor. - parse
- Parse a
data:URI into itsDataUricomponents.