grapple_redis_macros

Crates.iograpple_redis_macros
lib.rsgrapple_redis_macros
version0.2.0
created_at2025-06-08 14:59:53.305676+00
updated_at2025-06-10 13:02:02.692644+00
descriptionHelper macros for `grapple_db` Redis Client
homepage
repositoryhttps://github.com/grapple228/rust_redis_macros.git
max_upload_size
id1704953
size33,530
Green Apple (Grapple228)

documentation

README

grapple_redis_macros

grapple_redis_macros is a procedural macro library designed to simplify the deserialization of Redis values into Rust structs for use with the grapple_db Redis Client. This library provides a convenient way to automatically implement the FromRedisValue trait for your structs, enabling seamless integration with Redis data stored in JSON format.

Features

  • Automatic Trait Derivation: Automatically derive the FromRedisValue trait for your structs, simplifying the process of deserializing Redis values.
  • Integration with Serde: Leverage the power of Serde for serialization and deserialization, ensuring compatibility with JSON data.
  • Easy to Use: Simplifies the process of converting Redis values into Rust structs with minimal boilerplate code.

Requirements

To use this library, your model must implement the serde::Serialize and serde::Deserialize traits.

Installation

Add the following to your Cargo.toml:

[dependencies]
grapple_redis_macros = "0.2"
serde_json = "1"

Example

// Or any library that re-imports redis-rs
use redis::{self, FromRedisValue};
use grapple_redis_macros::FromRedisValue;

// Add `FromRedisValue` macros
#[derive(serde::Serialize, serde::Deserialize, FromRedisValue)]
struct MyStruct{
    field1: String,
    field2: i32,
}

fn example(redis_value: &redis::Value) -> Result<MyStruct, redis::RedisError> {
     MyStruct::from_redis_value(redis_value)
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Commit count: 0

cargo fmt