Skip to main content

parse_quoted

Function parse_quoted 

Source
pub fn parse_quoted(s: &[u8]) -> Result<(Quoted<'_>, usize), ParseError>
Expand description

Parses the quoted string at the start of s (RFC 9110 section 5.6.4).

Returns the view and the length used, both quotes included.

§Errors

ErrorKind::InvalidByte at offset 0 when s does not start with "; ErrorKind::BareCr, ErrorKind::LineFeed, ErrorKind::Nul, or ErrorKind::Control for a control byte inside; ErrorKind::InvalidQuotedPair when the byte after \ is not HTAB / SP / VCHAR / obs-text; ErrorKind::UnterminatedQuote at the end of input.

§Examples

use parse_net::text::parse_quoted;

let (q, used) = parse_quoted(b"\"say \\\"hi\\\"\" rest")?;
assert_eq!(used, 12);
assert_eq!(q.raw(), b"say \\\"hi\\\"");