#redis #serialization #protocols #encode

resp

RESP(REedis Serialization Protocol) Rust序列化库

21个版本 (4个稳定版)

使用旧的Rust 2015

1.0.3 2022年8月19日
1.0.2 2017年4月11日
1.0.0 2017年3月26日
0.4.0 2016年6月5日
0.3.5 2016年3月27日

#860数据库接口

Download history 24/week @ 2024-04-22 10/week @ 2024-04-29 10/week @ 2024-05-06 23/week @ 2024-05-13 30/week @ 2024-05-20 39/week @ 2024-05-27 25/week @ 2024-06-03 23/week @ 2024-06-10 22/week @ 2024-06-17 18/week @ 2024-06-24 8/week @ 2024-07-08 24/week @ 2024-07-15 44/week @ 2024-07-22 13/week @ 2024-07-29 22/week @ 2024-08-05

每月104 次下载
用于 5 个包

MIT/Apache

40KB
749

RESP

RESP(REedis Serialization Protocol) Rust序列化库。

Crates version Build Status Coverage Status Crates downloads Docs Status

实现

API

extern crate resp;
use resp::{Value, encode, encode_slice, Decoder};

RESP值

enum Value {
    /// Null bulk reply, $-1\r\n
    Null,
    /// Null array reply, *-1\r\n
    NullArray,
    /// For Simple Strings the first byte of the reply is "+"
    String(String),
    /// For Errors the first byte of the reply is "-"
    Error(String),
    /// For Integers the first byte of the reply is ":"
    Integer(i64),
    /// For Bulk Strings the first byte of the reply is "$"
    Bulk(String),
    /// For Bulk <binary> Strings the first byte of the reply is "$"
    BufBulk(Vec<u8>),
    /// For Arrays the first byte of the reply is "*"
    Array(Vec<Value>),
}

.is_null() -> bool

.is_error() -> bool

.encode() -> Vec<u8>

.to_encoded_string() -> io::Result<String>

.to_beautify_string() ->String

encode

fn encode(: &Value) -> Vec<u8>

fn encode_slice(array: &[&str]) -> Vec<u8>

Decoder

Decoder.new(reader: BufReader<R>) -> Self

Decoder.with_buf_bulk(reader: BufReader<R>) -> Self

decoder.decode() -> Result<Value>

无运行时依赖