@@ -17,7 +17,7 @@ macro_rules! implement_commands {
17
17
$(
18
18
$( #[ $attr: meta] ) +
19
19
fn $name: ident<$( $tyargs: ident : $ty: ident) ,* >(
20
- $self_ : ident$ ( , $argname: ident: $argty: ty) * ) $body: block
20
+ $( $argname: ident: $argty: ty) , * ) $body: block
21
21
) *
22
22
) =>
23
23
(
@@ -50,8 +50,8 @@ macro_rules! implement_commands {
50
50
$(
51
51
$( #[ $attr] ) *
52
52
fn $name<$( $tyargs: $ty, ) * RV : FromRedisValue >(
53
- & $self_ $( , $argname: $argty) * ) -> RedisResult <RV >
54
- { $self_ . perform( $body) }
53
+ & self $( , $argname: $argty) * ) -> RedisResult <RV >
54
+ { self . perform( $body) }
55
55
) *
56
56
}
57
57
@@ -65,8 +65,8 @@ macro_rules! implement_commands {
65
65
$(
66
66
$( #[ $attr] ) *
67
67
fn $name<' a $( , $tyargs: $ty) * >(
68
- & ' a mut $self_ $( , $argname: $argty) * ) -> & ' a mut Self
69
- { $self_ . perform( $body) }
68
+ & ' a mut self $( , $argname: $argty) * ) -> & ' a mut Self
69
+ { self . perform( $body) }
70
70
) *
71
71
}
72
72
)
@@ -76,85 +76,85 @@ implement_commands!(
76
76
// most common operations
77
77
78
78
#[ doc="Get the value of a key. If key is a vec this becomes an `MGET`." ]
79
- fn get<K : ToRedisArgs >( self , key: K ) {
79
+ fn get<K : ToRedisArgs >( key: K ) {
80
80
cmd( if key. is_single_arg( ) { "GET" } else { "MGET" } ) . arg( key)
81
81
}
82
82
83
83
#[ doc="Set the string value of a key." ]
84
- fn set<K : ToRedisArgs , V : ToRedisArgs >( self , key: K , value: V ) {
84
+ fn set<K : ToRedisArgs , V : ToRedisArgs >( key: K , value: V ) {
85
85
cmd( "SET" ) . arg( key) . arg( value)
86
86
}
87
87
88
88
#[ doc="Set the value and expiration of a key." ]
89
- fn set_ex<K : ToRedisArgs , V : ToRedisArgs >( self , key: K , value: V , seconds: uint) {
89
+ fn set_ex<K : ToRedisArgs , V : ToRedisArgs >( key: K , value: V , seconds: uint) {
90
90
cmd( "SETEX" ) . arg( key) . arg( value) . arg( seconds)
91
91
}
92
92
93
93
#[ doc="Set the value of a key, only if the key does not exist" ]
94
- fn set_nx<K : ToRedisArgs , V : ToRedisArgs >( self , key: K , value: V ) {
94
+ fn set_nx<K : ToRedisArgs , V : ToRedisArgs >( key: K , value: V ) {
95
95
cmd( "SETNX" ) . arg( key) . arg( value)
96
96
}
97
97
98
98
#[ doc="Set the string value of a key and return its old value." ]
99
- fn getset<K : ToRedisArgs , V : ToRedisArgs >( self , key: K , value: V ) {
99
+ fn getset<K : ToRedisArgs , V : ToRedisArgs >( key: K , value: V ) {
100
100
cmd( "GETSET" ) . arg( key) . arg( value)
101
101
}
102
102
103
103
#[ doc="Delete one or more keys." ]
104
- fn del<K : ToRedisArgs >( self , key: K ) {
104
+ fn del<K : ToRedisArgs >( key: K ) {
105
105
cmd( "DEL" ) . arg( key)
106
106
}
107
107
108
108
#[ doc="Determine if a key exists." ]
109
- fn exists<K : ToRedisArgs >( self , key: K ) {
109
+ fn exists<K : ToRedisArgs >( key: K ) {
110
110
cmd( "EXISTS" ) . arg( key)
111
111
}
112
112
113
113
#[ doc="Set a key's time to live in seconds." ]
114
- fn expire<K : ToRedisArgs >( self , key: K , seconds: uint) {
114
+ fn expire<K : ToRedisArgs >( key: K , seconds: uint) {
115
115
cmd( "EXPIRE" ) . arg( key) . arg( seconds)
116
116
}
117
117
118
118
#[ doc="Set the expiration for a key as a UNIX timestamp." ]
119
- fn expire_at<K : ToRedisArgs >( self , key: K , ts: uint) {
119
+ fn expire_at<K : ToRedisArgs >( key: K , ts: uint) {
120
120
cmd( "EXPIREAT" ) . arg( key) . arg( ts)
121
121
}
122
122
123
123
#[ doc="Set a key's time to live in milliseconds." ]
124
- fn pexpire<K : ToRedisArgs >( self , key: K , ms: uint) {
124
+ fn pexpire<K : ToRedisArgs >( key: K , ms: uint) {
125
125
cmd( "PEXPIRE" ) . arg( key) . arg( ms)
126
126
}
127
127
128
128
#[ doc="Set the expiration for a key as a UNIX timestamp in milliseconds." ]
129
- fn pexpire_at<K : ToRedisArgs >( self , key: K , ts: uint) {
129
+ fn pexpire_at<K : ToRedisArgs >( key: K , ts: uint) {
130
130
cmd( "PEXPIREAT" ) . arg( key) . arg( ts)
131
131
}
132
132
133
133
#[ doc="Remove the expiration from a key." ]
134
- fn persist<K : ToRedisArgs >( self , key: K ) {
134
+ fn persist<K : ToRedisArgs >( key: K ) {
135
135
cmd( "PERSIST" ) . arg( key)
136
136
}
137
137
138
138
#[ doc="Rename a key." ]
139
- fn rename<K : ToRedisArgs >( self , key: K , new_key: K ) {
139
+ fn rename<K : ToRedisArgs >( key: K , new_key: K ) {
140
140
cmd( "RENAME" ) . arg( key) . arg( new_key)
141
141
}
142
142
143
143
#[ doc="Rename a key, only if the new key does not exist." ]
144
- fn rename_nx<K : ToRedisArgs >( self , key: K , new_key: K ) {
144
+ fn rename_nx<K : ToRedisArgs >( key: K , new_key: K ) {
145
145
cmd( "RENAMENX" ) . arg( key) . arg( new_key)
146
146
}
147
147
148
148
// common string operations
149
149
150
150
#[ doc="Append a value to a key." ]
151
- fn append<K : ToRedisArgs , V : ToRedisArgs >( self , key: K , value: V ) {
151
+ fn append<K : ToRedisArgs , V : ToRedisArgs >( key: K , value: V ) {
152
152
cmd( "APPEND" ) . arg( key) . arg( value)
153
153
}
154
154
155
155
#[ doc="Increment the numeric value of a key by the given amount. This
156
156
issues a `INCR` or `INCRBYFLOAT` depending on the type." ]
157
- fn incr<K : ToRedisArgs , V : ToRedisArgs >( self , key: K , delta: V ) {
157
+ fn incr<K : ToRedisArgs , V : ToRedisArgs >( key: K , delta: V ) {
158
158
cmd( if delta. describe_numeric_behavior( ) == NumberIsFloat {
159
159
"INCRBYFLOAT"
160
160
} else {
@@ -163,28 +163,28 @@ implement_commands!(
163
163
}
164
164
165
165
#[ doc="Sets or clears the bit at offset in the string value stored at key." ]
166
- fn setbit<K : ToRedisArgs >( self , key: K , offset: uint, value: bool ) {
166
+ fn setbit<K : ToRedisArgs >( key: K , offset: uint, value: bool ) {
167
167
cmd( "SETBIT" ) . arg( key) . arg( offset) . arg( value)
168
168
}
169
169
170
170
#[ doc="Returns the bit value at offset in the string value stored at key." ]
171
- fn getbit<K : ToRedisArgs >( self , key: K , offset: uint) {
171
+ fn getbit<K : ToRedisArgs >( key: K , offset: uint) {
172
172
cmd( "GETBIT" ) . arg( key) . arg( offset)
173
173
}
174
174
175
175
#[ doc="Count set bits in a string." ]
176
- fn bitcount<K : ToRedisArgs >( self , key: K ) {
176
+ fn bitcount<K : ToRedisArgs >( key: K ) {
177
177
cmd( "BITCOUNT" ) . arg( key)
178
178
}
179
179
180
180
#[ doc="Count set bits in a string in a range." ]
181
- fn bitcount_range<K : ToRedisArgs >( self , key: K , start: uint, end: uint) {
181
+ fn bitcount_range<K : ToRedisArgs >( key: K , start: uint, end: uint) {
182
182
cmd( "BITCOUNT" ) . arg( key) . arg( start) . arg( end)
183
183
}
184
184
185
185
#[ doc="Perform a bitwise operation between multiple keys (containing string values)
186
186
and store the result in the destination key." ]
187
- fn bitop<K : ToRedisArgs >( self , op: BitOp , dstkey: K , srckeys: K ) {
187
+ fn bitop<K : ToRedisArgs >( op: BitOp , dstkey: K , srckeys: K ) {
188
188
cmd( "BITOP" ) . arg( match op {
189
189
BitAnd => "AND" ,
190
190
BitOr => "OR" ,
@@ -194,7 +194,7 @@ implement_commands!(
194
194
}
195
195
196
196
#[ doc="Get the length of the value stored in a key." ]
197
- fn strlen<K : ToRedisArgs >( self , key: K ) {
197
+ fn strlen<K : ToRedisArgs >( key: K ) {
198
198
cmd( "STRLEN" ) . arg( key)
199
199
}
200
200
)
0 commit comments