pub fn parse<'a>(
value: &'a [u8],
limits: &Limits,
) -> Result<List<'a>, ParseError>Expand description
Parses value as a list.
The whole value is validated: every byte as a field value (RFC 9110
section 5.5), quoted strings terminated with valid quoted pairs, comments
balanced within the depth limit. Empty elements are skipped, up to
Limits::max_empty_elements (RFC 9110 section 5.6.1.2).
§Errors
ErrorKind::BareCr, ErrorKind::LineFeed, ErrorKind::Nul,
ErrorKind::Control; ErrorKind::UnterminatedQuote,
ErrorKind::InvalidQuotedPair; ErrorKind::UnbalancedComment,
ErrorKind::CommentTooDeep; ErrorKind::TooManyEmptyElements at the
separator that exceeded the budget; ErrorKind::TooManyMembers at the
element beyond Limits::max_list_members.
§Examples
use parse_net::{list, ErrorKind, Limits};
let l = list::parse(b"a, b", &Limits::DEFAULT)?;
assert_eq!(l.len(), 2);
assert_eq!(list::parse(b"a, \"b", &Limits::DEFAULT).unwrap_err().kind(), ErrorKind::UnterminatedQuote);