#parser #redis #protocols #zero-copy #resp3 #resp2 #parse2

redis-parser

A zero-copy parser for the RESP2 and RESP3 protocols, used by Redis

3 releases

0.1.2 Nov 15, 2020
0.1.1 Nov 15, 2020
0.1.0 Nov 15, 2020

#139 in #zero-copy

MIT license

19KB
479 lines

Redis Protocol Parser

Crates.io Docs Run Tests

This library provides a high-performance, zero-copy parser for the RESP2 and RESP3 protocols.

Usage

There are two simple parse functions depending on the protocol you want. This library uses the nom parsing library and is built around streaming data into the parser.

use redis_parser::resp2::{parse as parse2, Resp2Type};
use redis_parser::resp3::{parse as parse3, Resp3Type};

assert_eq!(parse2("+test\r\n".as_bytes()), Ok((&b""[..], Resp2Type::String("test"))));
assert_eq!(parse3("#f\r\n".as_bytes()), Ok((&b""[..], Resp3Type::Boolean(false))));

Dependencies

~2.5MB
~53K SLoC