Skip to main content

Module text

Module text 

Source
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 Quoted value.

Enums§

Word
token / quoted-string: the value form of parameters and directives.

Functions§

is_ows
Whether b is optional whitespace: SP or HTAB only.
is_token
Whether s is a token: non-empty, every byte tchar (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 when s starts with ", a token otherwise.
skip_ows
The number of leading SP and HTAB bytes in s.
trim_ows
s without leading and trailing SP and HTAB.