Skip to content

Commit dc119fd

Browse files
committed
Upgrade code for version 1.0
1 parent e534be2 commit dc119fd

File tree

13 files changed

+251
-203
lines changed

13 files changed

+251
-203
lines changed

Cargo.lock

Lines changed: 37 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "redis-macros"
33
description = "Simple macros and wrappers to redis-rs to automatically serialize and deserialize structs with serde."
4-
version = "0.5.6"
4+
version = "1.0.0-rc.0"
55
edition = "2021"
66
authors = ["Daniel Grant"]
77
readme = "README.md"
@@ -11,8 +11,8 @@ license = "MIT"
1111
keywords = ["redis", "macro", "derive", "json"]
1212

1313
[dependencies]
14-
redis = { version = "0.32.0", optional = true }
15-
redis-macros-derive = { version = "0.5", optional = true, path = "./redis-macros-derive" }
14+
redis = { version = "1.0.0-rc", optional = true }
15+
redis-macros-derive = { version = "1.0.0-rc", optional = true, path = "./redis-macros-derive" }
1616
serde = { version = "1.0", features = ["derive"], optional = true }
1717
serde_json = { version = "1.0", optional = true }
1818

@@ -23,6 +23,7 @@ macros = ["dep:redis-macros-derive"]
2323

2424
[dev-dependencies]
2525
deadpool-redis = "0.22"
26-
redis = { version = "0.32.0", features = ["tokio-comp", "json"] }
26+
redis = { version = "1.0.0-rc", features = ["tokio-comp", "json"] }
2727
serde_yaml = "0.9"
2828
tokio = { version = "1.41", features = ["full"] }
29+

Changelog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22

33
## [Unreleased]
44

5+
## [1.0.0-rc.0]
6+
57
### Updated
68

7-
- Update dependencies
9+
- **Breaking change**: Update Redis version to 1.0.0-rc.0
10+
- This library mostly can be used without any changes, but read the [redis-rs breaking changes](https://github.com/redis-rs/redis-rs/blob/redis-1.0.0-rc.0/version1.md)
11+
- Implement `ToSingleRedisArg` for types deriving the `ToSingleRedis` macro (see [ToSingleRedisArg trait](https://github.com/redis-rs/redis-rs/blob/redis-1.0.0-rc.0/version1.md#tosingleredisarg-trait-breaking-change))
12+
- Change `FromRedisValue` to accept owned types (see [More efficient deserialization](https://github.com/redis-rs/redis-rs/blob/redis-1.0.0-rc.0/version1.md#more-efficient-deserialization-breaking-change))
13+
- Change `FromRedisValue` error from `RedisError` to `ParsingError` ([Better error messages](https://github.com/redis-rs/redis-rs/blob/redis-1.0.0-rc.0/version1.md#better-error-messages-potentially-breaking))
14+
- Update other dependencies
815

916
## [0.5.6] - 2025-07-20
1017

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ To install it, simply add the package `redis-macros`. This package is a helper f
88

99
```toml
1010
[dependencies]
11-
redis-macros = "0.5"
12-
redis = { version = "0.29" }
11+
redis-macros = "1.0.0-rc"
12+
redis = { version = "1.0.0-rc" }
1313
serde = { version = "1.0", features = ["derive"] }
1414
serde_json = { version = "1.0" }
1515
```

examples/derive_deadpool.rs

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,63 @@
1-
use deadpool_redis::{
2-
// Very important to import inner redis - otherwise macro expansion fails!
3-
redis,
4-
redis::{AsyncCommands, ErrorKind, RedisError, RedisResult},
5-
Config,
6-
Runtime,
7-
};
8-
use redis_macros::{FromRedisValue, ToRedisArgs};
9-
use serde::{Deserialize, Serialize};
1+
// TODO: COMMENTED OUT UNTIL DEADPOOL REDIS CATCHES UP WITH REDIS 1.0
2+
// use deadpool_redis::{
3+
// // Very important to import inner redis - otherwise macro expansion fails!
4+
// redis,
5+
// redis::{AsyncCommands, ErrorKind, RedisError, RedisResult},
6+
// Config,
7+
// Runtime,
8+
// };
9+
// use redis_macros::{FromRedisValue, ToRedisArgs};
10+
// use serde::{Deserialize, Serialize};
11+
use redis::RedisResult;
1012

11-
/// Define structs to hold the data
12-
/// Children structs don't have to implement FromRedisValue, ToRedisArgs, unless you want to use them as top level
13-
/// They have to implement serde traits though!
14-
#[derive(Debug, PartialEq, Serialize, Deserialize)]
15-
enum Address {
16-
Street(String),
17-
Road(String),
18-
}
13+
// /// Define structs to hold the data
14+
// /// Children structs don't have to implement FromRedisValue, ToRedisArgs, unless you want to use them as top level
15+
// /// They have to implement serde traits though!
16+
// #[derive(Debug, PartialEq, Serialize, Deserialize)]
17+
// enum Address {
18+
// Street(String),
19+
// Road(String),
20+
// }
1921

20-
/// Don't forget to implement serde traits and redis traits!
21-
#[derive(Debug, PartialEq, Serialize, Deserialize, FromRedisValue, ToRedisArgs)]
22-
struct User {
23-
id: u32,
24-
name: String,
25-
addresses: Vec<Address>,
26-
}
22+
// /// Don't forget to implement serde traits and redis traits!
23+
// #[derive(Debug, PartialEq, Serialize, Deserialize, FromRedisValue, ToRedisArgs)]
24+
// struct User {
25+
// id: u32,
26+
// name: String,
27+
// addresses: Vec<Address>,
28+
// }
2729

2830
/// Show a simple async usage of redis_macros traits
2931
/// Just derive the traits and forget them!
3032
#[tokio::main]
3133
async fn main() -> RedisResult<()> {
32-
// Open new async connection to localhost
33-
let cfg = Config::from_url("redis://localhost:6379");
34+
// // Open new async connection to localhost
35+
// let cfg = Config::from_url("redis://localhost:6379");
3436

35-
let pool = cfg.create_pool(Some(Runtime::Tokio1)).unwrap();
36-
let mut con = pool.get().await.map_err(|_| {
37-
RedisError::from((
38-
ErrorKind::InvalidClientConfig,
39-
"Cannot connect to localhost:6379. Try starting a redis-server process or container.",
40-
))
41-
})?;
37+
// let pool = cfg.create_pool(Some(Runtime::Tokio1)).unwrap();
38+
// let mut con = pool.get().await.map_err(|_| {
39+
// RedisError::from((
40+
// ErrorKind::InvalidClientConfig,
41+
// "Cannot connect to localhost:6379. Try starting a redis-server process or container.",
42+
// ))
43+
// })?;
4244

43-
// Define the data you want to store in Redis.
44-
let user = User {
45-
id: 1,
46-
name: "Ziggy".to_string(),
47-
addresses: vec![
48-
Address::Street("Downing".to_string()),
49-
Address::Road("Abbey".to_string()),
50-
],
51-
};
45+
// // Define the data you want to store in Redis.
46+
// let user = User {
47+
// id: 1,
48+
// name: "Ziggy".to_string(),
49+
// addresses: vec![
50+
// Address::Street("Downing".to_string()),
51+
// Address::Road("Abbey".to_string()),
52+
// ],
53+
// };
5254

53-
// Set and get back the user in Redis asynchronously, no problem
54-
let _: () = con.set("user_deadpool", &user).await?;
55-
let stored_user: User = con.get("user_deadpool").await?;
55+
// // Set and get back the user in Redis asynchronously, no problem
56+
// let _: () = con.set("user_deadpool", &user).await?;
57+
// let stored_user: User = con.get("user_deadpool").await?;
5658

57-
// You will get back the same data
58-
assert_eq!(user, stored_user);
59+
// // You will get back the same data
60+
// assert_eq!(user, stored_user);
5961

6062
Ok(())
6163
}

0 commit comments

Comments
 (0)