pub fn parse_weighted<'a>(
value: &'a [u8],
limits: &Limits,
) -> Result<WeightedList<'a>, ParseError>Expand description
Parses token *( OWS ";" OWS parameter ) members with weights, as in
Accept-Encoding, Accept-Charset, and Accept-Language.
§Errors
The list errors; ErrorKind::NotToken for a member that does not start
with a token; the parameter errors; ErrorKind::InvalidQValue.
§Examples
use parse_net::{negotiate::parse_weighted, Limits};
let w = parse_weighted(b"gzip;q=0.8, br", &Limits::DEFAULT)?;
let all: Vec<_> = w.iter().map(|m| (m.value, m.weight.thousandths())).collect();
assert_eq!(all, [(&b"gzip"[..], 800), (&b"br"[..], 1000)]);