Crates.io | respirator |
lib.rs | respirator |
version | 0.1.1 |
source | src |
created_at | 2021-12-05 15:26:10.962603 |
updated_at | 2021-12-05 18:55:42.721093 |
description | RESP (Redis Serialization Protocol) parser. |
homepage | https://github.com/pawelkobojek/respirator |
repository | https://github.com/pawelkobojek/respirator |
max_upload_size | |
id | 492722 |
size | 24,508 |
Respirator is nom based Redis Serialization Protocol (resp) parser. Currently only "complete" parsing (i.e. works only when all data to parse is available) works, yet an aim is to cover streaming parsing as well.
use respirator::{Resp, resp};
use std::matches;
let input = &b"*2\r\n$2\r\nOK\r\n$4\r\nResp\r\n"[..];
let (_, parsed) = resp(input).unwrap();
if let Resp::Array(Some(values)) = parsed {
let simple_string = &values[0];
let bulk_string = &values[1];
assert!(matches!(Resp::SimpleString(b"OK".to_vec()), simple_string));
assert!(matches!(Resp::BulkString(Some(b"Resp".to_vec())), bulk_string));
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.