Expand description
Zero-copy response parser: parse_response.
Recursive-descent parser for IMAP4rev1 / IMAP4rev2 server responses.
The parser operates on a byte slice and returns borrowed AST nodes pointing back into that slice (zero-copy). It is deliberately tolerant of trailing garbage on a line: anything after a recognized response that still ends in CRLF is consumed and the response is returned. This keeps the framer robust against minor server quirks.
§DoS guard
Literals ({n}\r\n) are capped at [MAX_LITERAL_SIZE] to prevent a
hostile server from forcing the client to allocate an arbitrarily large
buffer. The cap applies to a single literal; pipelined responses are
independent.
§Limitations
Quoted-string escape sequences (\\, \") are not unescaped — the raw
bytes are returned. ENVELOPE / BODY / BODYSTRUCTURE are returned as raw
parenthesized byte slices for callers to parse on demand.
Constants§
- MAX_
LITERAL_ SIZE - Hard cap on a single literal’s declared length, in octets.
A server attempting to send a larger literal causes the parser to fail
with
ParseError::LiteralTooLargebefore any buffer growth occurs.
Functions§
- parse_
response - Parse a single IMAP server response from
input.
Type Aliases§
- IResult
- Result returned by the parser API.