redis_om/
lib.rs

1#![deny(missing_docs, unstable_features)]
2#![doc = include_str!("../README.md")]
3mod hash_model;
4#[cfg(feature = "json")]
5mod json_model;
6mod redis_model;
7mod redissearch_model;
8mod stream_model;
9
10pub use redis;
11pub use redis::{Client, FromRedisValue, RedisError, RedisResult, ToRedisArgs};
12
13pub use redis_om_macros::HashModel;
14#[cfg(feature = "json")]
15pub use redis_om_macros::JsonModel;
16pub use redis_om_macros::RedisModel;
17pub use redis_om_macros::StreamModel;
18
19/// Derive procedural macro that automatically generate implementation for
20///
21/// [`RedisTransportValue`](), which requires implementation of the following:
22///
23/// - [`ToRedisArgs`](redis::ToRedisArgs),
24/// - [`FromRedisValue`](redis::FromRedisValue)
25///
26/// # Example
27///
28/// ```
29/// #[derive(redis_om::RedisTransportValue)]
30/// struct Test {
31///     #[redis(primary_key)] // required if no `id` field exists
32///     field_one: String,
33///     field_two: i32,
34///     field_three: Vec<u8>,
35/// }
36/// ```
37///
38/// # Attributes
39///
40/// ## `rename_all = "some_case"`
41///
42/// This attribute sets the default casing to be used for field names when generating Redis command arguments.
43/// Possible values are:
44///
45/// - `"snake_case"`: field names will be converted to `snake_case`
46/// - `"kebab-case"`: field names will be converted to `kebab-case`
47/// - `"camelCase"`: field names will be converted to `camelCase`
48/// - `"PascalCase"`: field names will be converted to `PascalCase`
49///
50/// This attribute can be overridden for individual fields using the `rename` attribute.
51///
52/// ## `rename = "some_field"`
53///
54/// This attribute sets the Redis key name to be used for a field when generating Redis command arguments.
55/// This attribute takes precedence over the `rename_all` attribute.
56///
57/// # Restrictions
58///
59/// - Enums with fields are not supported
60/// - Generics are not supported
61/// - Public fields are required
62/// - Fields with types that do not implement `ToRedisArgs` and `FromRedisValue` are not supported
63pub use redis_om_macros::RedisTransportValue;
64
65pub use hash_model::HashModel;
66#[cfg(feature = "json")]
67pub use json_model::*;
68pub use redis_model::RedisModel;
69pub use redissearch_model::RedisSearchModel;
70pub use stream_model::StreamModel;
71
72#[cfg(feature = "aio")]
73pub use async_trait::async_trait;