1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! High-level, ergonomic client interfaces for Redis Stack modules.
//!
//! This crate is the dedicated home for typed, ergonomic clients over the
//! Redis Stack modules (RedisJSON, RediSearch, RedisTimeSeries, the
//! probabilistic data structures, and Vector Sets). Callers never see raw
//! [`Frame`](redis_tower::Frame) values or command structs; they work with
//! typed Rust values, with serialization and response parsing handled inside
//! each client.
//!
//! The lower-level command builders live in `redis-tower-commands`, and the
//! `redis-tower` crate exposes the connections and middleware these clients
//! wrap. This crate sits on top, trading a little flexibility for a much
//! friendlier surface.
//!
//! # Feature flags
//!
//! Each module client is gated behind a feature flag. The `full` feature
//! (enabled by default) turns them all on.
//!
//! | Feature | Enables |
//! |-----------------|----------------------------------------------------------------|
//! | `json` | [`json::JsonClient`] — RedisJSON |
//! | `search` | [`search::SearchClient`] — RediSearch |
//! | `timeseries` | [`timeseries::TimeSeriesClient`] — RedisTimeSeries |
//! | `probabilistic` | Bloom, Cuckoo, Count-Min Sketch, TopK, T-Digest clients |
//! | `vector` | [`vector::VectorSetClient`] — Vector Sets |
//! | `full` | All of the above (default) |
//!
//! # Quick start
//!
//! ```no_run
//! use redis_tower::RedisClient;
//! use redis_tower_modules::json::JsonClient;
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Serialize, Deserialize)]
//! struct User {
//! name: String,
//! age: u32,
//! }
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let client = RedisClient::connect_url("redis://127.0.0.1:6379").await?;
//! let mut json = JsonClient::new(client);
//!
//! let user = User { name: "Ada".into(), age: 36 };
//! json.set("user:1", "$", &user).await?;
//!
//! let fetched: Option<User> = json.get("user:1", "$").await?;
//! assert_eq!(fetched.expect("user:1 was just written").name, "Ada");
//! # Ok(())
//! # }
//! ```
//!
//! # Binary data
//!
//! Module keys, Bloom/Cuckoo/sketch items, Search suggestions and payloads,
//! TimeSeries labels, and Vector Set elements accept binary-safe
//! [`CommandArg`](redis_tower::commands::CommandArg) inputs. Corresponding
//! opaque response positions use [`bytes::Bytes`]. JSONPath, serialized JSON,
//! Search query/schema syntax, timestamps, and Vector Set filter expressions
//! remain structured text or numeric inputs.