Skip to main content

parse_request_bytes

Function parse_request_bytes 

Source
pub fn parse_request_bytes(
    body: &[u8],
    max_calls: usize,
) -> Result<JmapRequest, JmapError>
Expand description

Parse and validate a JMAP request from the raw HTTP request body.

Runs serde_json::from_slice on body and hands the result to parse_request. Prefer this over parse_request when the body comes straight off the wire: it produces the notJSON request error itself and parses with serde_json’s recursion limit (128 levels), so no hand-built Value reaches the JMAP layer.

The body-size cap described on parse_request is still the caller’s job: apply it before reading the body into memory.

§Errors

Returns JmapError::not_json() if body does not parse as JSON (RFC 8620 §3.6.1 notJSON), and otherwise any error parse_request returns.