#redis #serialization #protocols #encode #value

resp

RESP(REdis Serialization Protocol) Serialization for Rust

21 releases (4 stable)

Uses old Rust 2015

1.0.3 Aug 19, 2022
1.0.2 Apr 11, 2017
1.0.0 Mar 26, 2017
0.4.0 Jun 5, 2016
0.3.5 Mar 27, 2016

#800 in Database interfaces

Download history 49/week @ 2023-12-15 55/week @ 2023-12-22 32/week @ 2023-12-29 58/week @ 2024-01-05 26/week @ 2024-01-12 34/week @ 2024-01-19 24/week @ 2024-01-26 6/week @ 2024-02-02 8/week @ 2024-02-09 47/week @ 2024-02-16 100/week @ 2024-02-23 84/week @ 2024-03-01 36/week @ 2024-03-08 24/week @ 2024-03-15 27/week @ 2024-03-22 60/week @ 2024-03-29

149 downloads per month
Used in 5 crates

MIT/Apache

40KB
749 lines

RESP

RESP(REdis Serialization Protocol) Serialization for Rust.

Crates version Build Status Coverage Status Crates downloads Docs Status

Implementations:

API

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

RESP Values

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>),
}

value.is_null() -> bool

value.is_error() -> bool

value.encode() -> Vec<u8>

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

value.to_beautify_string() -> String

encode

fn encode(value: &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>

No runtime deps