RESP parser and validator
Since
v1.0.0, the crate is published asio_respand no more.squall_dot_io_resp
A RESP (REdis Serialization Protocol) parser implementation, written with edge performance in mind.
If you are not familiar with RESP, consider starting here with RESP specs. RESP is a binary safe serialization protocol. Initially developed for the ReDiS project, it is injection safe (needs no escaping) and is fast-forward as it requires no look-back in parsing.
This crate aims to parse and validate your RESP strings. Since the protocol can be used beyond its initial scope, to a general-purpose communication scheme.
To do so, its reuses Rust TryInto trait to try and parse your &str
as a valid RESP. Implemented on a Value enum of RESP tokens, it
returns a Rust Result<Value, Error>.
Usage
Add dependency to your project:
; Cargo.toml
[dependecies]
io_resp = "0.1.2"
Here are example with code:
use ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
use ;
// JSON: null
assert_eq!;
// JSON: 10
assert_eq!;
// JSON: "Nina Simone"
assert_eq!;
// JSON: "Lorem ipsum...\r\nDolor sit amet..."
assert_eq!;
// JavaScript: [null, 447, new Error("Oh oh!"), "Hourly", "Si vis pacem,\r\npara bellum"]
assert_eq!;
// NOTE: Even recursive arrays - we leave that for you to try out.
License
MIT
Contributions
Should you find some issues, please report on GitHub project, or consider opening a pull-request.