Skip to main content

parse_request

Function parse_request 

Source
pub fn parse_request(text: &str) -> Result<ClassifyRequest, Refusal>
Expand description

Decode a classify.run request from its JSON text, refusing a malformed one invalid_params naming the first malformed field. Decoding from the text keeps the order of the questions and of each choice’s options.

The refusal names params only when no narrower path applies: the text is not JSON, or not an object. A problem deep inside an otherwise well-formed request names its own path (items[2].images[0], say), never params.