1 个不稳定版本
使用旧的 Rust 2015
0.0.1 | 2016年7月8日 |
---|
#38 在 #syslog
7KB
RESP
RESP (Redis 序列化协议) Rust 的序列化。
实现
- redis-cli Redis CLI。
API
文档 https://iorust.github.io/resp/resp
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() -> Self
Decoder.with_buf_bulk() -> Self
decoder.feed(buf: &[u8]) -> Result<(), io:Error>
decoder.read() -> Option<Value>
decoder.buffer_len() -> usize
decoder.result_len() -> usize
依赖项
~705KB