Skip to main content

parse_request

Function parse_request 

Source
pub fn parse_request(line: &str) -> Result<Request, RequestError>
Expand description

Parses one request line, telling a malformed line from an unrecognised command from bad arguments, each of which the spec answers with a different code.

Not JSON, not an object, or missing id or cmd is ErrorCode::InvalidRequest with id null; an unrecognised cmd.type is ErrorCode::UnknownCommand; anything else is ErrorCode::InvalidParams.