resp-protocol 0.0.4

REdis Serialization Protocol
Documentation
resp-protocol-0.0.4 has been yanked.

rust-resp-protocol

REdis Serialization Protocol

Install

add resp-protocol to Cargo.toml

[dependencies]
resp-protocol = "0.0.4"

Usage

use resp_protocol;

Types

  • Simple string
  • Error
  • Integer
  • Bulk string
  • Array

Simple string

Examples

Value
"+OK\r\n"
Build
use resp_protocol::SimpleString;

let simple_string: SimpleString = SimpleString::new(b"OK");
Parse
use resp_protocol::SimpleString;

let string: &str = "+OK\r\n";
let simple_string: SimpleString = SimpleString::parse(string.as_bytes(), &mut 0, &string.len()).unwrap();

Error

Examples

Value
"-ERROR\r\n"
Build
use resp_protocol::Error;

let error: Error = Error::new(b"ERROR");
Parse
use resp_protocol::Error;

let string: &str = "-ERROR\r\n";
let error: Error = Error::parse(string.as_bytes(), &mut 0, &string.len()).unwrap();

Integer

Examples

Value
":100\r\n"
Build
use resp_protocol::Integer;

let integer: Integer = Integer::new(-100i64);
Parse
use resp_protocol::Integer;

let string: &str = ":-100\r\n";
let integer: Integer = Integer::parse(string.as_bytes(), &mut 0, &string.len()).unwrap();

Bulk string

Examples

Value
"$6\r\nfoobar\r\n"
Build
use resp_protocol::BulkString;

let bulk_string: BulkString = BulkString::new(b"foobar");
Parse
use resp_protocol::BulkString;

let string: &str = "$6\r\nfoobar\r\n";
let bulk_string: BulkString = BulkString::parse(string.as_bytes(), &mut 0, &string.len()).unwrap();