redis-serde 0.15.0

Serde serialization and deserialization for redis-rs.
Documentation

redis-serde

serde serialization and deserialization of redis-rs values

About

This crate is a fork of OneSignal/serde-redis with full serialization support added.

Status

  • ✅ Deserialization: Fully implemented and working
  • ✅ Serialization: Fully implemented and working

Summary

This crate provides automatic serialization and deserialization of values for use with redis-rs.

Deserialization

use redis_serde::RedisDeserialize;

#[derive(Debug, Deserialize, PartialEq)]
struct Simple {
    a: String,
    b: String,
}

let s: Simple = redis.hgetall("simple_hash")?
                     .deserialize()?;

Serialization

use redis_serde::Serializer;
use serde::Serialize;

#[derive(Debug, Serialize, PartialEq)]
struct Simple {
    a: String,
    b: String,
}

let data = Simple {
    a: "value1".to_string(),
    b: "value2".to_string(),
};

let redis_value = data.serialize(Serializer)?;
// Use redis_value with redis-rs commands

Features

  • Deserialization: Convert redis::Value types into Rust types using serde
  • Serialization: Convert Rust types into redis::Value types using serde
  • Support for all common Rust types (primitives, structs, enums, collections, etc.)
  • Compatible with redis-rs 0.32+

License

Licensed under either of

at your option.

Contribution

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.