pub(crate) fn parse_jsonrpc_request(req: Vec<u8>) -> std::result::Result<JsonRpcRequest, String> {
    let req_payload = match String::from_utf8(req) {
        Ok(payload) => payload,
        Err(err) => {
            let err_str = serialised_jsonrpc_error(
                "Request payload is a malformed UTF-8 string".to_string(),
                err.to_string(),
                JSONRPC_PARSE_ERROR,
                None,
            )?;
            return Err(err_str);
        }
    };

    let jsonrpc_req: JsonRpcRequest = match serde_json::from_str(&req_payload) {
        Ok(jsonrpc) => jsonrpc,
        Err(err) => {
            let err_str = serialised_jsonrpc_error(
                "Failed to deserialise request payload as a JSON-RPC message".to_string(),
                err.to_string(),
                JSONRPC_INVALID_REQUEST,
                None,
            )?;
            return Err(err_str);
        }
    };

    Ok(jsonrpc_req)
}
// It parses the request bytes an returns a JsonRpcRequest, or a
// serialised JSON-RPC error response ready to send back to the origin
It parses the request bytes an returns a JsonRpcRequest, or a
serialised JSON-RPC error response ready to send back to the origin
It parses the request bytes an returns a JsonRpcRequest or a serialised JSON - RPC error response ready to send back to the origin
pub(crate) fn parse_jsonrpc_request(req: Vec<u8>) -> std::result::Result<JsonRpcRequest, String> {
    let req_payload = match String::from_utf8(req) {
        Ok(payload) => payload,
        Err(err) => {
            let err_str = serialised_jsonrpc_error(
                "Request payload is a malformed UTF-8 string".to_string(),
                err.to_string(),
                JSONRPC_PARSE_ERROR,
                None,
            )?;
            return Err(err_str);
        }
    };
    let jsonrpc_req: JsonRpcRequest = match serde_json::from_str(&req_payload) {
        Ok(jsonrpc) => jsonrpc,
        Err(err) => {
            let err_str = serialised_jsonrpc_error(
                "Failed to deserialise request payload as a JSON-RPC message".to_string(),
                err.to_string(),
                JSONRPC_INVALID_REQUEST,
                None,
            )?;
            return Err(err_str);
        }
    };
    Ok(jsonrpc_req)
}
pub ( crate ) fn parse_jsonrpc_request ( req : Vec < u8 > ) -> std :: result :: Result < JsonRpcRequest , String > { let req_payload = match String :: from_utf8 ( req ) { Ok ( payload ) => payload , Err ( err ) => { let err_str = serialised_jsonrpc_error ( " " . to_string ( ) , err . to_string ( ) , JSONRPC_PARSE_ERROR , None , ) ? ; return Err ( err_str ) ; } } ; let jsonrpc_req : JsonRpcRequest = match serde_json :: from_str ( & req_payload ) { Ok ( jsonrpc ) => jsonrpc , Err ( err ) => { let err_str = serialised_jsonrpc_error ( " " . to_string ( ) , err . to_string ( ) , JSONRPC_INVALID_REQUEST , None , ) ? ; return Err ( err_str ) ; } } ; Ok ( jsonrpc_req ) }
It parses the request bytes an returns a JsonRpcRequest, or a
serialised JSON-RPC error response ready to send back to the origin
It parses the request bytes an returns a JsonRpcRequest or a serialised JSON - RPC error response ready to send back to the origin
req
Vec<u8>