redis-args 0.22.1

Derive macro for reading and writing types for redis usage, either through serde or format args
Documentation
// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
//
// SPDX-License-Identifier: MIT OR Apache-2.0

/// Can be derived by structs or enums in order to allow conversion from redis values.
///
/// This can be used in different variants, either using `FromStr` or the `serde` deserialization.
///
/// # FromStr
///
/// The item must implement the [`std::str::FromStr`] trait.
///
/// ## Example
///
/// ```
/// # use redis_args::FromRedisValue;
/// #[derive(FromRedisValue)]
/// #[from_redis_value(FromStr)]
/// struct IdValue {
///    id: String,
///    value: u32,
///    count: usize,
/// }
///
/// # impl std::str::FromStr for IdValue {
/// #     type Err = String;
/// #     fn from_str(s: &str)->Result<Self, Self::Err> {
/// #         unimplemented!()
/// #     }
/// # }
/// ```
///
// # Serde
///
/// Deserializes from JSON using the serde deserialization of any item. The item
/// must derive `serde::Deserialize`.
///
/// ## Example
///
/// ```
/// # use redis_args::FromRedisValue;
/// # use serde::Deserialize;
/// #[derive(FromRedisValue, Deserialize)]
/// #[from_redis_value(serde)]
/// struct IdValue {
///     id: String,
///     value: u32,
///     count: usize,
/// }
/// ```
pub use redis_args_impl::FromRedisValue;
/// Can be derived by structs or enums in order to allow conversion to redis args.
///
/// This can be used in different variants, either using a format string or the `serde` serialization.
///
/// # Format string
///
/// The format string is limited to plain `{name}` arguments, no extra formatting allowed.
/// This restriction is currently necessary, because detecting which fields should be
/// formatted would be significantly more difficult otherwise.
///
/// This variant can only be used with structs, either named or anonymous.
///
/// ## Examples
///
/// ### Struct with named fields
///
/// ```
/// # use redis_args::ToRedisArgs;
/// #[derive(ToRedisArgs)]
/// #[to_redis_args(fmt = "path:to:id={id}:with:value:{value}")]
/// struct IdValue {
///    id: String,
///    value: u32,
///    count: usize,
/// }
/// ```
///
/// ### Struct with unnamed fields
///
/// ```
/// # use redis_args::ToRedisArgs;
/// # #[macro_use] extern crate serde;
/// #[derive(ToRedisArgs)]
/// #[to_redis_args(fmt = "path:to:{0}:with:{1}")]
/// struct Example(u32, String);
/// ````
///
/// # Serde
///
/// Serializes to JSON using the serde serialization of any item. The item
/// must derive `serde::Serialize`.
///
/// ## Examples
///
/// ```
/// # use redis_args::ToRedisArgs;
/// # use serde::Serialize;
/// #[derive(ToRedisArgs, Serialize)]
/// #[to_redis_args(serde)]
/// struct IdValue {
///     id: String,
///     value: u32,
///     count: usize,
/// }
/// ```
pub use redis_args_impl::ToRedisArgs;

#[doc(hidden)]
pub mod __exports {
    pub use redis;
    pub use serde_json;
}