Skip to main content

Module param

Module param 

Source
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§

OptionalParam
One parameter of parse_optional: a name and, when one was sent, a value.
OptionalParamIter
The parameters of a validated OptionalParams.
OptionalParams
Validated parameters from parse_optional. Iterating them cannot fail.
Param
One parameter: a name and a value.
ParamIter
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 ) ] ] ), the extension-param of RFC 6455 section 9.1. permessage-deflate (RFC 7692) sends client_max_window_bits and server_no_context_takeover this way.