Skip to content

Commit d7c8c11

Browse files
authored
Conform ValkeyCommand to Hashable (#108)
1 parent 5e1cc6f commit d7c8c11

19 files changed

+171
-171
lines changed

Sources/Valkey/Commands/BitmapCommands.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Foundation
2424

2525
/// Counts the number of set bits (population counting) in a string.
2626
public struct BITCOUNT: ValkeyCommand {
27-
public enum RangeEndUnitBlockUnit: RESPRenderable, Sendable {
27+
public enum RangeEndUnitBlockUnit: RESPRenderable, Sendable, Hashable {
2828
case byte
2929
case bit
3030

@@ -39,7 +39,7 @@ public struct BITCOUNT: ValkeyCommand {
3939
}
4040
}
4141
}
42-
public struct RangeEndUnitBlock: RESPRenderable, Sendable {
42+
public struct RangeEndUnitBlock: RESPRenderable, Sendable, Hashable {
4343
@usableFromInline let end: Int
4444
@usableFromInline let unit: RangeEndUnitBlockUnit?
4545

@@ -59,7 +59,7 @@ public struct BITCOUNT: ValkeyCommand {
5959
unit.encode(into: &commandEncoder)
6060
}
6161
}
62-
public struct Range: RESPRenderable, Sendable {
62+
public struct Range: RESPRenderable, Sendable, Hashable {
6363
@usableFromInline let start: Int
6464
@usableFromInline let endUnitBlock: RangeEndUnitBlock?
6565

@@ -98,7 +98,7 @@ public struct BITCOUNT: ValkeyCommand {
9898

9999
/// Performs arbitrary bitfield integer operations on strings.
100100
public struct BITFIELD: ValkeyCommand {
101-
public struct OperationGetBlock: RESPRenderable, Sendable {
101+
public struct OperationGetBlock: RESPRenderable, Sendable, Hashable {
102102
@usableFromInline let encoding: String
103103
@usableFromInline let offset: Int
104104

@@ -118,7 +118,7 @@ public struct BITFIELD: ValkeyCommand {
118118
offset.encode(into: &commandEncoder)
119119
}
120120
}
121-
public enum OperationWriteOverflowBlock: RESPRenderable, Sendable {
121+
public enum OperationWriteOverflowBlock: RESPRenderable, Sendable, Hashable {
122122
case wrap
123123
case sat
124124
case fail
@@ -135,7 +135,7 @@ public struct BITFIELD: ValkeyCommand {
135135
}
136136
}
137137
}
138-
public struct OperationWriteWriteOperationSetBlock: RESPRenderable, Sendable {
138+
public struct OperationWriteWriteOperationSetBlock: RESPRenderable, Sendable, Hashable {
139139
@usableFromInline let encoding: String
140140
@usableFromInline let offset: Int
141141
@usableFromInline let value: Int
@@ -158,7 +158,7 @@ public struct BITFIELD: ValkeyCommand {
158158
value.encode(into: &commandEncoder)
159159
}
160160
}
161-
public struct OperationWriteWriteOperationIncrbyBlock: RESPRenderable, Sendable {
161+
public struct OperationWriteWriteOperationIncrbyBlock: RESPRenderable, Sendable, Hashable {
162162
@usableFromInline let encoding: String
163163
@usableFromInline let offset: Int
164164
@usableFromInline let increment: Int
@@ -181,7 +181,7 @@ public struct BITFIELD: ValkeyCommand {
181181
increment.encode(into: &commandEncoder)
182182
}
183183
}
184-
public enum OperationWriteWriteOperation: RESPRenderable, Sendable {
184+
public enum OperationWriteWriteOperation: RESPRenderable, Sendable, Hashable {
185185
case setBlock(OperationWriteWriteOperationSetBlock)
186186
case incrbyBlock(OperationWriteWriteOperationIncrbyBlock)
187187

@@ -201,7 +201,7 @@ public struct BITFIELD: ValkeyCommand {
201201
}
202202
}
203203
}
204-
public struct OperationWrite: RESPRenderable, Sendable {
204+
public struct OperationWrite: RESPRenderable, Sendable, Hashable {
205205
@usableFromInline let overflowBlock: OperationWriteOverflowBlock?
206206
@usableFromInline let writeOperation: OperationWriteWriteOperation
207207

@@ -221,7 +221,7 @@ public struct BITFIELD: ValkeyCommand {
221221
writeOperation.encode(into: &commandEncoder)
222222
}
223223
}
224-
public enum Operation: RESPRenderable, Sendable {
224+
public enum Operation: RESPRenderable, Sendable, Hashable {
225225
case getBlock(OperationGetBlock)
226226
case write(OperationWrite)
227227

@@ -260,7 +260,7 @@ public struct BITFIELD: ValkeyCommand {
260260

261261
/// Performs arbitrary read-only bitfield integer operations on strings.
262262
public struct BITFIELDRO: ValkeyCommand {
263-
public struct GetBlock: RESPRenderable, Sendable {
263+
public struct GetBlock: RESPRenderable, Sendable, Hashable {
264264
@usableFromInline let encoding: String
265265
@usableFromInline let offset: Int
266266

@@ -299,7 +299,7 @@ public struct BITFIELDRO: ValkeyCommand {
299299

300300
/// Performs bitwise operations on multiple strings, and stores the result.
301301
public struct BITOP: ValkeyCommand {
302-
public enum Operation: RESPRenderable, Sendable {
302+
public enum Operation: RESPRenderable, Sendable, Hashable {
303303
case and
304304
case or
305305
case xor
@@ -339,7 +339,7 @@ public struct BITOP: ValkeyCommand {
339339

340340
/// Finds the first set (1) or clear (0) bit in a string.
341341
public struct BITPOS: ValkeyCommand {
342-
public enum RangeEndUnitBlockUnit: RESPRenderable, Sendable {
342+
public enum RangeEndUnitBlockUnit: RESPRenderable, Sendable, Hashable {
343343
case byte
344344
case bit
345345

@@ -354,7 +354,7 @@ public struct BITPOS: ValkeyCommand {
354354
}
355355
}
356356
}
357-
public struct RangeEndUnitBlock: RESPRenderable, Sendable {
357+
public struct RangeEndUnitBlock: RESPRenderable, Sendable, Hashable {
358358
@usableFromInline let end: Int
359359
@usableFromInline let unit: RangeEndUnitBlockUnit?
360360

@@ -374,7 +374,7 @@ public struct BITPOS: ValkeyCommand {
374374
unit.encode(into: &commandEncoder)
375375
}
376376
}
377-
public struct Range: RESPRenderable, Sendable {
377+
public struct Range: RESPRenderable, Sendable, Hashable {
378378
@usableFromInline let start: Int
379379
@usableFromInline let endUnitBlock: RangeEndUnitBlock?
380380

Sources/Valkey/Commands/ClusterCommands.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public enum CLUSTER {
3939

4040
/// Assigns new hash slot ranges to a node.
4141
public struct ADDSLOTSRANGE: ValkeyCommand {
42-
public struct Range: RESPRenderable, Sendable {
42+
public struct Range: RESPRenderable, Sendable, Hashable {
4343
@usableFromInline let startSlot: Int
4444
@usableFromInline let endSlot: Int
4545

@@ -125,7 +125,7 @@ public enum CLUSTER {
125125

126126
/// Sets hash slot ranges as unbound for a node.
127127
public struct DELSLOTSRANGE: ValkeyCommand {
128-
public struct Range: RESPRenderable, Sendable {
128+
public struct Range: RESPRenderable, Sendable, Hashable {
129129
@usableFromInline let startSlot: Int
130130
@usableFromInline let endSlot: Int
131131

@@ -158,7 +158,7 @@ public enum CLUSTER {
158158

159159
/// Forces a replica to perform a manual failover of its primary.
160160
public struct FAILOVER: ValkeyCommand {
161-
public enum Options: RESPRenderable, Sendable {
161+
public enum Options: RESPRenderable, Sendable, Hashable {
162162
case force
163163
case takeover
164164

@@ -350,7 +350,7 @@ public enum CLUSTER {
350350

351351
/// Resets a node.
352352
public struct RESET: ValkeyCommand {
353-
public enum ResetType: RESPRenderable, Sendable {
353+
public enum ResetType: RESPRenderable, Sendable, Hashable {
354354
case hard
355355
case soft
356356

@@ -401,7 +401,7 @@ public enum CLUSTER {
401401

402402
/// Binds a hash slot to a node.
403403
public struct SETSLOT: ValkeyCommand {
404-
public enum Subcommand: RESPRenderable, Sendable {
404+
public enum Subcommand: RESPRenderable, Sendable, Hashable {
405405
case importing(String)
406406
case migrating(String)
407407
case node(String)
@@ -469,7 +469,7 @@ public enum CLUSTER {
469469

470470
/// Return an array of slot usage statistics for slots assigned to the current node.
471471
public struct SLOTSTATS: ValkeyCommand {
472-
public struct FilterSlotsrange: RESPRenderable, Sendable {
472+
public struct FilterSlotsrange: RESPRenderable, Sendable, Hashable {
473473
@usableFromInline let startSlot: Int
474474
@usableFromInline let endSlot: Int
475475

@@ -489,7 +489,7 @@ public enum CLUSTER {
489489
endSlot.encode(into: &commandEncoder)
490490
}
491491
}
492-
public enum FilterOrderbyOrder: RESPRenderable, Sendable {
492+
public enum FilterOrderbyOrder: RESPRenderable, Sendable, Hashable {
493493
case asc
494494
case desc
495495

@@ -504,7 +504,7 @@ public enum CLUSTER {
504504
}
505505
}
506506
}
507-
public struct FilterOrderby: RESPRenderable, Sendable {
507+
public struct FilterOrderby: RESPRenderable, Sendable, Hashable {
508508
@usableFromInline let metric: String
509509
@usableFromInline let limit: Int?
510510
@usableFromInline let order: FilterOrderbyOrder?
@@ -527,7 +527,7 @@ public enum CLUSTER {
527527
order.encode(into: &commandEncoder)
528528
}
529529
}
530-
public enum Filter: RESPRenderable, Sendable {
530+
public enum Filter: RESPRenderable, Sendable, Hashable {
531531
case slotsrange(FilterSlotsrange)
532532
case orderby(FilterOrderby)
533533

Sources/Valkey/Commands/ConnectionCommands.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Foundation
2525
extension CLIENT {
2626
/// Instructs the server whether to track the keys in the next request.
2727
public struct CACHING: ValkeyCommand {
28-
public enum Mode: RESPRenderable, Sendable {
28+
public enum Mode: RESPRenderable, Sendable, Hashable {
2929
case yes
3030
case no
3131

@@ -114,7 +114,7 @@ extension CLIENT {
114114

115115
/// Mark this client as an import source when server is in import mode.
116116
public struct IMPORTSOURCE: ValkeyCommand {
117-
public enum Enabled: RESPRenderable, Sendable {
117+
public enum Enabled: RESPRenderable, Sendable, Hashable {
118118
case on
119119
case off
120120

@@ -152,7 +152,7 @@ extension CLIENT {
152152

153153
/// Terminates open connections.
154154
public struct KILL: ValkeyCommand {
155-
public enum FilterNewFormatClientType: RESPRenderable, Sendable {
155+
public enum FilterNewFormatClientType: RESPRenderable, Sendable, Hashable {
156156
case normal
157157
case master
158158
case primary
@@ -175,7 +175,7 @@ extension CLIENT {
175175
}
176176
}
177177
}
178-
public enum FilterNewFormatSkipme: RESPRenderable, Sendable {
178+
public enum FilterNewFormatSkipme: RESPRenderable, Sendable, Hashable {
179179
case yes
180180
case no
181181

@@ -190,7 +190,7 @@ extension CLIENT {
190190
}
191191
}
192192
}
193-
public enum FilterNewFormat: RESPRenderable, Sendable {
193+
public enum FilterNewFormat: RESPRenderable, Sendable, Hashable {
194194
case clientId([Int])
195195
case clientType(FilterNewFormatClientType?)
196196
case username(String?)
@@ -225,7 +225,7 @@ extension CLIENT {
225225
}
226226
}
227227
}
228-
public enum Filter: RESPRenderable, Sendable {
228+
public enum Filter: RESPRenderable, Sendable, Hashable {
229229
case oldFormat(String)
230230
case newFormat([FilterNewFormat])
231231

@@ -260,7 +260,7 @@ extension CLIENT {
260260

261261
/// Lists open connections.
262262
public struct LIST: ValkeyCommand {
263-
public enum ClientType: RESPRenderable, Sendable {
263+
public enum ClientType: RESPRenderable, Sendable, Hashable {
264264
case normal
265265
case master
266266
case replica
@@ -279,7 +279,7 @@ extension CLIENT {
279279
}
280280
}
281281
}
282-
public enum Skipme: RESPRenderable, Sendable {
282+
public enum Skipme: RESPRenderable, Sendable, Hashable {
283283
case yes
284284
case no
285285

@@ -319,7 +319,7 @@ extension CLIENT {
319319

320320
/// Sets the client eviction mode of the connection.
321321
public struct NOEVICT: ValkeyCommand {
322-
public enum Enabled: RESPRenderable, Sendable {
322+
public enum Enabled: RESPRenderable, Sendable, Hashable {
323323
case on
324324
case off
325325

@@ -347,7 +347,7 @@ extension CLIENT {
347347

348348
/// Controls whether commands sent by the client affect the LRU/LFU of accessed keys.
349349
public struct NOTOUCH: ValkeyCommand {
350-
public enum Enabled: RESPRenderable, Sendable {
350+
public enum Enabled: RESPRenderable, Sendable, Hashable {
351351
case on
352352
case off
353353

@@ -375,7 +375,7 @@ extension CLIENT {
375375

376376
/// Suspends commands processing.
377377
public struct PAUSE: ValkeyCommand {
378-
public enum Mode: RESPRenderable, Sendable {
378+
public enum Mode: RESPRenderable, Sendable, Hashable {
379379
case write
380380
case all
381381

@@ -405,7 +405,7 @@ extension CLIENT {
405405

406406
/// Instructs the server whether to reply to commands.
407407
public struct REPLY: ValkeyCommand {
408-
public enum Action: RESPRenderable, Sendable {
408+
public enum Action: RESPRenderable, Sendable, Hashable {
409409
case on
410410
case off
411411
case skip
@@ -435,7 +435,7 @@ extension CLIENT {
435435

436436
/// Sets information specific to the client or connection.
437437
public struct SETINFO: ValkeyCommand {
438-
public enum Attr: RESPRenderable, Sendable {
438+
public enum Attr: RESPRenderable, Sendable, Hashable {
439439
case libname(String)
440440
case libver(String)
441441

@@ -481,7 +481,7 @@ extension CLIENT {
481481

482482
/// Controls server-assisted client-side caching for the connection.
483483
public struct TRACKING: ValkeyCommand {
484-
public enum Status: RESPRenderable, Sendable {
484+
public enum Status: RESPRenderable, Sendable, Hashable {
485485
case on
486486
case off
487487

@@ -533,7 +533,7 @@ extension CLIENT {
533533

534534
/// Unblocks a client blocked by a blocking command from a different connection.
535535
public struct UNBLOCK: ValkeyCommand {
536-
public enum UnblockType: RESPRenderable, Sendable {
536+
public enum UnblockType: RESPRenderable, Sendable, Hashable {
537537
case timeout
538538
case error
539539

@@ -615,7 +615,7 @@ public struct ECHO<Message: RESPStringRenderable>: ValkeyCommand {
615615

616616
/// Handshakes with the server.
617617
public struct HELLO: ValkeyCommand {
618-
public struct ArgumentsAuth: RESPRenderable, Sendable {
618+
public struct ArgumentsAuth: RESPRenderable, Sendable, Hashable {
619619
@usableFromInline let username: String
620620
@usableFromInline let password: String
621621

@@ -635,7 +635,7 @@ public struct HELLO: ValkeyCommand {
635635
password.encode(into: &commandEncoder)
636636
}
637637
}
638-
public struct Arguments: RESPRenderable, Sendable {
638+
public struct Arguments: RESPRenderable, Sendable, Hashable {
639639
@usableFromInline let protover: Int
640640
@usableFromInline let auth: ArgumentsAuth?
641641
@usableFromInline let clientname: String?

0 commit comments

Comments
 (0)