Expand description
The #rule lists of RFC 9110 section 5.6.1, including several field lines
read as one list (section 5.3).
A comma ends an element only outside quoted strings and comments, so
a="x,y", b is two elements. Elements are yielded trimmed of OWS, as raw
bytes; the grammar of each element (a token, token;params, a media
range) is the caller’s.
§Examples
use parse_net::{self as pn, Limits};
let l = pn::list(b"a, \"b,c\" , , (d, e) f,")?;
let all: Vec<&[u8]> = l.iter().collect();
assert_eq!(all, [&b"a"[..], b"\"b,c\"", b"(d, e) f"]);
let lines: [&[u8]; 3] = [b"gzip", b"", b"br, zstd"];
let c = pn::list::combined(lines, &Limits::DEFAULT)?;
assert_eq!(c.iter().collect::<Vec<_>>(), [&b"gzip"[..], b"br", b"zstd"]);Structs§
- Combined
Elements - The elements of a
CombinedList. - Combined
List - Several validated field lines read as one list.
- Elements
- The elements of a validated list.
- List
- A validated list. Iterating it cannot fail.
Functions§
- combined
- Validates several field lines of one name as one list (RFC 9110 section
5.3), as if joined by
", ", without joining them. - contains_
token - Whether any element of any line equals
token, ignoring ASCII case. - for_
each - Validates
valueand callsffor each element in the same pass, then returns the element count. - list
- Parses
valueas a list with the defaultLimits. - parse
- Parses
valueas a list.