Expand description
The lexical forms of RFC 9110 section 5.6: tokens, optional whitespace,
quoted strings, words (token / quoted-string), and comments.
§Examples
use parse_net::text;
assert!(text::is_token(b"no-cache") && !text::is_token(b"no cache"));
assert_eq!(text::trim_ows(b" \t gzip \t"), b"gzip");
let (q, used) = text::parse_quoted(b"\"a \\\"b\\\" c\"; x")?;
assert_eq!(used, 11);
assert!(q.eq_bytes(b"a \"b\" c"));Structs§
- Comment
- A validated comment: the text without the outer parentheses, and the deepest nesting reached.
- Quoted
- A validated quoted string: the bytes between the quotes, and whether any quoted pair occurs.
- Unescape
- The unescaped bytes of a
Quotedvalue.
Enums§
- Word
token / quoted-string: the value form of parameters and directives.
Functions§
- is_ows
- Whether
bis optional whitespace: SP or HTAB only. - is_
token - Whether
sis a token: non-empty, every bytetchar(RFC 9110 section 5.6.2). - parse_
comment - Parses the comment at the start of
s(RFC 9110 section 5.6.5), nested comments included, counted and never recursed. - parse_
quoted - Parses the quoted string at the start of
s(RFC 9110 section 5.6.4). - parse_
token - The longest token prefix of
s, and its length. - parse_
word - Parses a word at the start of
s: a quoted string whensstarts with", a token otherwise. - skip_
ows - The number of leading SP and HTAB bytes in
s. - trim_
ows swithout leading and trailing SP and HTAB.