@@ -63,6 +63,11 @@ pub enum Rule {
63
63
/// Performs the following actions: `resetpass`, `resetkeys`, `off`, `-@all`.
64
64
/// The user returns to the same state it has immediately after its creation.
65
65
Reset ,
66
+
67
+ /// Raw text of [`ACL rule`][1] that not enumerated above.
68
+ ///
69
+ /// [1]: https://redis.io/docs/manual/security/acl
70
+ Other ( String ) ,
66
71
}
67
72
68
73
impl ToRedisArgs for Rule {
@@ -95,6 +100,8 @@ impl ToRedisArgs for Rule {
95
100
ResetKeys => out. write_arg ( b"resetkeys" ) ,
96
101
97
102
Reset => out. write_arg ( b"reset" ) ,
103
+
104
+ Other ( rule) => out. write_arg ( rule. as_bytes ( ) ) ,
98
105
} ;
99
106
}
100
107
}
@@ -162,7 +169,7 @@ impl FromRedisValue for AclInfo {
162
169
b"allkeys" => Ok ( Rule :: AllKeys ) ,
163
170
b"allcommands" => Ok ( Rule :: AllCommands ) ,
164
171
b"nopass" => Ok ( Rule :: NoPass ) ,
165
- _ => Err ( not_convertible_error ! ( flag , "Expect a valid ACL flag" ) ) ,
172
+ other => Ok ( Rule :: Other ( String :: from_utf8_lossy ( other ) . into_owned ( ) ) ) ,
166
173
} ,
167
174
_ => Err ( not_convertible_error ! (
168
175
flag,
@@ -269,13 +276,17 @@ mod tests {
269
276
assert_args ! ( AllKeys , b"allkeys" ) ;
270
277
assert_args ! ( ResetKeys , b"resetkeys" ) ;
271
278
assert_args ! ( Reset , b"reset" ) ;
279
+ assert_args ! ( Other ( "resetchannels" . to_owned( ) ) , b"resetchannels" ) ;
272
280
}
273
281
274
282
#[ test]
275
283
fn test_from_redis_value ( ) {
276
284
let redis_value = Value :: Bulk ( vec ! [
277
285
Value :: Data ( "flags" . into( ) ) ,
278
- Value :: Bulk ( vec![ Value :: Data ( "on" . into( ) ) ] ) ,
286
+ Value :: Bulk ( vec![
287
+ Value :: Data ( "on" . into( ) ) ,
288
+ Value :: Data ( "allchannels" . into( ) ) ,
289
+ ] ) ,
279
290
Value :: Data ( "passwords" . into( ) ) ,
280
291
Value :: Bulk ( vec![ ] ) ,
281
292
Value :: Data ( "commands" . into( ) ) ,
@@ -288,7 +299,7 @@ mod tests {
288
299
assert_eq ! (
289
300
acl_info,
290
301
AclInfo {
291
- flags: vec![ Rule :: On ] ,
302
+ flags: vec![ Rule :: On , Rule :: Other ( "allchannels" . into ( ) ) ] ,
292
303
passwords: vec![ ] ,
293
304
commands: vec![
294
305
Rule :: RemoveCategory ( "all" . to_owned( ) ) ,
0 commit comments