Expand description
Parameters: *( OWS ";" OWS [ parameter ] ) (RFC 9110 section 5.6.6).
parse_optional reads the RFC 6455 form, where a value may be left out.
§Examples
use parse_net::{param, Limits};
let (p, used) = param::parse(b"; charset=utf-8;format=\"flowed\" , next", &Limits::DEFAULT)?;
assert_eq!(used, 31);
assert!(p.get("Charset").is_some_and(|v| v.eq_bytes(b"utf-8")));
assert_eq!(format!("{p:?}"), "Params([\"charset\", \"format\"])");Structs§
- Optional
Param - One parameter of
parse_optional: a name and, when one was sent, a value. - Optional
Param Iter - The parameters of a validated
OptionalParams. - Optional
Params - Validated parameters from
parse_optional. Iterating them cannot fail. - Param
- One parameter: a name and a value.
- Param
Iter - The parameters of a validated
Params. - Params
- Validated parameters. Iterating them cannot fail.
Constants§
- MAX_
CHECKED_ PARAMS - The most parameters one element may have when repeated names are
refused: RFC 9110 parameters under
DuplicatePolicy::Refuse, authentication parameters, and MIME parameters. Their name offsets are kept on the stack, so a repeat is found by comparing names in place, never by reading the parameters again (D-072). Without it, the check for a repeat reads every earlier parameter, values included, and a field of many parameters costs the square of its length.
Functions§
- parse
- Parses parameters at the start of
s. - parse_
optional - Parses parameters whose value may be left out, at the start of
s:*( OWS ";" OWS [ token [ "=" ( token / quoted-string ) ] ] ), theextension-paramof RFC 6455 section 9.1. permessage-deflate (RFC 7692) sendsclient_max_window_bitsandserver_no_context_takeoverthis way.