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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
use crate::{
commands,
error::Error,
interfaces::{ClientLike, FredResult},
types::{FromValue, MultipleStrings, MultipleValues, Value},
};
use bytes_utils::Str;
use fred_macros::rm_send_if;
use futures::Future;
/// Functions that implement the [ACL](https://redis.io/commandserver) interface.
#[rm_send_if(feature = "glommio")]
pub trait AclInterface: ClientLike + Sized {
/// Create an ACL user with the specified rules or modify the rules of an existing user.
///
/// <https://redis.io/commands/acl-setuser>
fn acl_setuser<S, V>(&self, username: S, rules: V) -> impl Future<Output = FredResult<()>> + Send
where
S: Into<Str> + Send,
V: TryInto<MultipleValues> + Send,
V::Error: Into<Error> + Send,
{
async move {
into!(username);
try_into!(rules);
commands::acl::acl_setuser(self, username, rules).await
}
}
/// When Redis is configured to use an ACL file (with the aclfile configuration option), this command will reload
/// the ACLs from the file, replacing all the current ACL rules with the ones defined in the file.
///
/// <https://redis.io/commands/acl-load>
fn acl_load(&self) -> impl Future<Output = FredResult<()>> + Send {
async move { commands::acl::acl_load(self).await }
}
/// When Redis is configured to use an ACL file (with the aclfile configuration option), this command will save the
/// currently defined ACLs from the server memory to the ACL file.
///
/// <https://redis.io/commands/acl-save>
fn acl_save(&self) -> impl Future<Output = FredResult<()>> + Send {
async move { commands::acl::acl_save(self).await }
}
/// The command shows the currently active ACL rules in the Redis server.
///
/// <https://redis.io/commands/acl-list>\
fn acl_list<R>(&self) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
{
async move { commands::acl::acl_list(self).await?.convert() }
}
/// The command shows a list of all the usernames of the currently configured users in the Redis ACL system.
///
/// <https://redis.io/commands/acl-users>
fn acl_users<R>(&self) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
{
async move { commands::acl::acl_users(self).await?.convert() }
}
/// The command returns all the rules defined for an existing ACL user.
///
/// <https://redis.io/commands/acl-getuser>
fn acl_getuser<R, U>(&self, username: U) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
U: TryInto<Value> + Send,
U::Error: Into<Error> + Send,
{
async move {
try_into!(username);
commands::acl::acl_getuser(self, username).await?.convert()
}
}
/// Delete all the specified ACL users and terminate all the connections that are authenticated with such users.
///
/// <https://redis.io/commands/acl-deluser>
fn acl_deluser<R, S>(&self, usernames: S) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
S: Into<MultipleStrings> + Send,
{
async move {
into!(usernames);
commands::acl::acl_deluser(self, usernames).await?.convert()
}
}
/// The command shows the available ACL categories if called without arguments. If a category name is given,
/// the command shows all the Redis commands in the specified category.
///
/// <https://redis.io/commands/acl-cat>
fn acl_cat<R>(&self, category: Option<Str>) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
{
async move { commands::acl::acl_cat(self, category).await?.convert() }
}
/// Generate a password with length `bits`, returning the password.
///
/// <https://redis.io/commands/acl-genpass>
fn acl_genpass<R>(&self, bits: Option<u16>) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
{
async move { commands::acl::acl_genpass(self, bits).await?.convert() }
}
/// Return the username the current connection is authenticated with. New connections are authenticated
/// with the "default" user.
///
/// <https://redis.io/commands/acl-whoami>
fn acl_whoami<R>(&self) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
{
async move { commands::acl::acl_whoami(self).await?.convert() }
}
/// Read `count` recent ACL security events.
///
/// <https://redis.io/commands/acl-log>
fn acl_log_count<R>(&self, count: Option<u32>) -> impl Future<Output = FredResult<R>> + Send
where
R: FromValue,
{
async move { commands::acl::acl_log_count(self, count).await?.convert() }
}
/// Clear the ACL security events logs.
///
/// <https://redis.io/commands/acl-log>
fn acl_log_reset(&self) -> impl Future<Output = FredResult<()>> + Send {
async move { commands::acl::acl_log_reset(self).await }
}
}