pub fn parse_comment<'a>(
s: &'a [u8],
limits: &Limits,
) -> Result<(Comment<'a>, usize), ParseError>Expand description
Parses the comment at the start of s (RFC 9110 section 5.6.5), nested
comments included, counted and never recursed.
Returns the view and the length used, both outer parentheses included.
§Errors
ErrorKind::InvalidByte at offset 0 when s does not start with (;
a control kind for a control byte; ErrorKind::InvalidQuotedPair;
ErrorKind::UnbalancedComment when the comment never closes;
ErrorKind::CommentTooDeep at the ( that exceeded
Limits::max_comment_depth.
§Examples
use parse_net::{text::parse_comment, Limits};
let (c, used) = parse_comment(b"(compatible; (nested)) rest", &Limits::DEFAULT)?;
assert_eq!((c.raw(), c.max_depth(), used), (&b"compatible; (nested)"[..], 2, 22));