Skip to main content

ruststream_fred/pipeline/
commands.rs

1// Generated by scripts/gen_pipeline_commands.py from fred's command interfaces; regenerate rather
2// than edit.
3
4//! The commands a handler queues into its delivery's segment, one per fred command method.
5
6// The summaries are fred's own prose, copied as it is written.
7#![allow(
8    clippy::too_many_arguments,
9    clippy::missing_errors_doc,
10    clippy::doc_markdown
11)]
12
13use fred::bytes::Bytes;
14use fred::bytes_utils::Str;
15use fred::error::Error;
16use fred::interfaces::{
17    FunctionInterface, HashesInterface, KeysInterface, ListInterface, PubsubInterface,
18    SetsInterface, SortedSetsInterface, StreamsInterface,
19};
20use fred::types::lists::{LMoveDirection, ListLocation};
21use fred::types::scripts::FnPolicy;
22use fred::types::sorted_sets::{
23    AggregateOptions, MultipleWeights, MultipleZaddValues, Ordering, ZCmp, ZRange, ZSort,
24};
25use fred::types::streams::{MultipleIDs, MultipleOrderedPairs, XCap, XID, XPendingArgs};
26use fred::types::{
27    Expiration, ExpireOptions, Key, Limit, Map, MultipleKeys, MultipleStrings, MultipleValues,
28    SetOptions, SortOrder, Value,
29};
30
31use super::{RedisPipeline, Segment};
32
33impl RedisPipeline {
34    /// Return a random key from the currently selected database.
35    ///
36    /// Queued into this delivery's segment; it runs after the handler returns, when
37    /// the delivery is acknowledged.
38    pub async fn randomkey(&self) -> Result<(), Error> {
39        match self.segment().await? {
40            Segment::Plain(segment) => segment.randomkey::<()>().await,
41            Segment::Atomic(segment) => segment.randomkey::<()>().await,
42        }
43    }
44
45    /// This command copies the value stored at the source key to the destination key.
46    ///
47    /// Queued into this delivery's segment; it runs after the handler returns, when
48    /// the delivery is acknowledged.
49    pub async fn copy<S, D>(
50        &self,
51        source: S,
52        destination: D,
53        db: Option<u8>,
54        replace: bool,
55    ) -> Result<(), Error>
56    where
57        S: Into<Key> + Send,
58        D: Into<Key> + Send,
59    {
60        match self.segment().await? {
61            Segment::Plain(segment) => {
62                segment
63                    .copy::<(), S, D>(source, destination, db, replace)
64                    .await
65            }
66            Segment::Atomic(segment) => {
67                segment
68                    .copy::<(), S, D>(source, destination, db, replace)
69                    .await
70            }
71        }
72    }
73
74    /// Serialize the value stored at `key` in a Redis-specific format and return it as bulk string.
75    ///
76    /// Queued into this delivery's segment; it runs after the handler returns, when
77    /// the delivery is acknowledged.
78    pub async fn dump<K>(&self, key: K) -> Result<(), Error>
79    where
80        K: Into<Key> + Send,
81    {
82        match self.segment().await? {
83            Segment::Plain(segment) => segment.dump::<(), K>(key).await,
84            Segment::Atomic(segment) => segment.dump::<(), K>(key).await,
85        }
86    }
87
88    /// Returns the string representation of the type of the value stored at key.
89    ///
90    /// Queued into this delivery's segment; it runs after the handler returns, when
91    /// the delivery is acknowledged.
92    pub async fn r#type<K>(&self, key: K) -> Result<(), Error>
93    where
94        K: Into<Key> + Send,
95    {
96        match self.segment().await? {
97            Segment::Plain(segment) => segment.r#type::<(), K>(key).await,
98            Segment::Atomic(segment) => segment.r#type::<(), K>(key).await,
99        }
100    }
101
102    /// Create a key associated with a value that is obtained by deserializing the provided serialized value
103    ///
104    /// Queued into this delivery's segment; it runs after the handler returns, when
105    /// the delivery is acknowledged.
106    pub async fn restore<K>(
107        &self,
108        key: K,
109        ttl: i64,
110        serialized: Value,
111        replace: bool,
112        absttl: bool,
113        idletime: Option<i64>,
114        frequency: Option<i64>,
115    ) -> Result<(), Error>
116    where
117        K: Into<Key> + Send,
118    {
119        match self.segment().await? {
120            Segment::Plain(segment) => {
121                segment
122                    .restore::<(), K>(key, ttl, serialized, replace, absttl, idletime, frequency)
123                    .await
124            }
125            Segment::Atomic(segment) => {
126                segment
127                    .restore::<(), K>(key, ttl, serialized, replace, absttl, idletime, frequency)
128                    .await
129            }
130        }
131    }
132
133    /// Set a value with optional NX|XX, EX|PX|EXAT|PXAT|KEEPTTL, and GET arguments.
134    ///
135    /// Queued into this delivery's segment; it runs after the handler returns, when
136    /// the delivery is acknowledged.
137    pub async fn set<K, V>(
138        &self,
139        key: K,
140        value: V,
141        expire: Option<Expiration>,
142        options: Option<SetOptions>,
143        get: bool,
144    ) -> Result<(), Error>
145    where
146        K: Into<Key> + Send,
147        V: TryInto<Value> + Send,
148        V::Error: Into<Error> + Send,
149    {
150        match self.segment().await? {
151            Segment::Plain(segment) => {
152                segment
153                    .set::<(), K, V>(key, value, expire, options, get)
154                    .await
155            }
156            Segment::Atomic(segment) => {
157                segment
158                    .set::<(), K, V>(key, value, expire, options, get)
159                    .await
160            }
161        }
162    }
163
164    /// Sets `key` to `value` if `key` does not exist.
165    ///
166    /// Queued into this delivery's segment; it runs after the handler returns, when
167    /// the delivery is acknowledged.
168    pub async fn setnx<K, V>(&self, key: K, value: V) -> Result<(), Error>
169    where
170        K: Into<Key> + Send,
171        V: TryInto<Value> + Send,
172        V::Error: Into<Error> + Send,
173    {
174        match self.segment().await? {
175            Segment::Plain(segment) => segment.setnx::<(), K, V>(key, value).await,
176            Segment::Atomic(segment) => segment.setnx::<(), K, V>(key, value).await,
177        }
178    }
179
180    /// Read a value from the server.
181    ///
182    /// Queued into this delivery's segment; it runs after the handler returns, when
183    /// the delivery is acknowledged.
184    pub async fn get<K>(&self, key: K) -> Result<(), Error>
185    where
186        K: Into<Key> + Send,
187    {
188        match self.segment().await? {
189            Segment::Plain(segment) => segment.get::<(), K>(key).await,
190            Segment::Atomic(segment) => segment.get::<(), K>(key).await,
191        }
192    }
193
194    /// Returns the substring of the string value stored at `key` with offsets `start` and `end` (both inclusive).
195    ///
196    /// Queued into this delivery's segment; it runs after the handler returns, when
197    /// the delivery is acknowledged.
198    pub async fn getrange<K>(&self, key: K, start: usize, end: usize) -> Result<(), Error>
199    where
200        K: Into<Key> + Send,
201    {
202        match self.segment().await? {
203            Segment::Plain(segment) => segment.getrange::<(), K>(key, start, end).await,
204            Segment::Atomic(segment) => segment.getrange::<(), K>(key, start, end).await,
205        }
206    }
207
208    /// Overwrites part of the string stored at `key`, starting at the specified `offset`, for the entire length of `value`.
209    ///
210    /// Queued into this delivery's segment; it runs after the handler returns, when
211    /// the delivery is acknowledged.
212    pub async fn setrange<K, V>(&self, key: K, offset: u32, value: V) -> Result<(), Error>
213    where
214        K: Into<Key> + Send,
215        V: TryInto<Value> + Send,
216        V::Error: Into<Error> + Send,
217    {
218        match self.segment().await? {
219            Segment::Plain(segment) => segment.setrange::<(), K, V>(key, offset, value).await,
220            Segment::Atomic(segment) => segment.setrange::<(), K, V>(key, offset, value).await,
221        }
222    }
223
224    /// Atomically sets `key` to `value` and returns the old value stored at `key`.
225    ///
226    /// Queued into this delivery's segment; it runs after the handler returns, when
227    /// the delivery is acknowledged.
228    pub async fn getset<K, V>(&self, key: K, value: V) -> Result<(), Error>
229    where
230        K: Into<Key> + Send,
231        V: TryInto<Value> + Send,
232        V::Error: Into<Error> + Send,
233    {
234        match self.segment().await? {
235            Segment::Plain(segment) => segment.getset::<(), K, V>(key, value).await,
236            Segment::Atomic(segment) => segment.getset::<(), K, V>(key, value).await,
237        }
238    }
239
240    /// Get the value of key and delete the key.
241    ///
242    /// Queued into this delivery's segment; it runs after the handler returns, when
243    /// the delivery is acknowledged.
244    pub async fn getdel<K>(&self, key: K) -> Result<(), Error>
245    where
246        K: Into<Key> + Send,
247    {
248        match self.segment().await? {
249            Segment::Plain(segment) => segment.getdel::<(), K>(key).await,
250            Segment::Atomic(segment) => segment.getdel::<(), K>(key).await,
251        }
252    }
253
254    /// Returns the length of the string value stored at key.
255    ///
256    /// Queued into this delivery's segment; it runs after the handler returns, when
257    /// the delivery is acknowledged.
258    pub async fn strlen<K>(&self, key: K) -> Result<(), Error>
259    where
260        K: Into<Key> + Send,
261    {
262        match self.segment().await? {
263            Segment::Plain(segment) => segment.strlen::<(), K>(key).await,
264            Segment::Atomic(segment) => segment.strlen::<(), K>(key).await,
265        }
266    }
267
268    /// Removes the specified keys.
269    ///
270    /// Queued into this delivery's segment; it runs after the handler returns, when
271    /// the delivery is acknowledged.
272    pub async fn del<K>(&self, keys: K) -> Result<(), Error>
273    where
274        K: Into<MultipleKeys> + Send,
275    {
276        match self.segment().await? {
277            Segment::Plain(segment) => segment.del::<(), K>(keys).await,
278            Segment::Atomic(segment) => segment.del::<(), K>(keys).await,
279        }
280    }
281
282    /// Unlinks the specified keys.
283    ///
284    /// Queued into this delivery's segment; it runs after the handler returns, when
285    /// the delivery is acknowledged.
286    pub async fn unlink<K>(&self, keys: K) -> Result<(), Error>
287    where
288        K: Into<MultipleKeys> + Send,
289    {
290        match self.segment().await? {
291            Segment::Plain(segment) => segment.unlink::<(), K>(keys).await,
292            Segment::Atomic(segment) => segment.unlink::<(), K>(keys).await,
293        }
294    }
295
296    /// Renames `source` key to `destination`.
297    ///
298    /// Queued into this delivery's segment; it runs after the handler returns, when
299    /// the delivery is acknowledged.
300    pub async fn rename<S, D>(&self, source: S, destination: D) -> Result<(), Error>
301    where
302        S: Into<Key> + Send,
303        D: Into<Key> + Send,
304    {
305        match self.segment().await? {
306            Segment::Plain(segment) => segment.rename::<(), S, D>(source, destination).await,
307            Segment::Atomic(segment) => segment.rename::<(), S, D>(source, destination).await,
308        }
309    }
310
311    /// Renames `source` key to `destination` if `destination` does not yet exist.
312    ///
313    /// Queued into this delivery's segment; it runs after the handler returns, when
314    /// the delivery is acknowledged.
315    pub async fn renamenx<S, D>(&self, source: S, destination: D) -> Result<(), Error>
316    where
317        S: Into<Key> + Send,
318        D: Into<Key> + Send,
319    {
320        match self.segment().await? {
321            Segment::Plain(segment) => segment.renamenx::<(), S, D>(source, destination).await,
322            Segment::Atomic(segment) => segment.renamenx::<(), S, D>(source, destination).await,
323        }
324    }
325
326    /// Append `value` to `key` if it's a string.
327    ///
328    /// Queued into this delivery's segment; it runs after the handler returns, when
329    /// the delivery is acknowledged.
330    pub async fn append<K, V>(&self, key: K, value: V) -> Result<(), Error>
331    where
332        K: Into<Key> + Send,
333        V: TryInto<Value> + Send,
334        V::Error: Into<Error> + Send,
335    {
336        match self.segment().await? {
337            Segment::Plain(segment) => segment.append::<(), K, V>(key, value).await,
338            Segment::Atomic(segment) => segment.append::<(), K, V>(key, value).await,
339        }
340    }
341
342    /// Returns the values of all specified keys.
343    ///
344    /// Queued into this delivery's segment; it runs after the handler returns, when
345    /// the delivery is acknowledged.
346    pub async fn mget<K>(&self, keys: K) -> Result<(), Error>
347    where
348        K: Into<MultipleKeys> + Send,
349    {
350        match self.segment().await? {
351            Segment::Plain(segment) => segment.mget::<(), K>(keys).await,
352            Segment::Atomic(segment) => segment.mget::<(), K>(keys).await,
353        }
354    }
355
356    /// Sets the given keys to their respective values.
357    ///
358    /// Queued into this delivery's segment; it runs after the handler returns, when
359    /// the delivery is acknowledged.
360    pub async fn mset<V>(&self, values: V) -> Result<(), Error>
361    where
362        V: TryInto<Map> + Send,
363        V::Error: Into<Error> + Send,
364    {
365        match self.segment().await? {
366            Segment::Plain(segment) => segment.mset(values).await,
367            Segment::Atomic(segment) => segment.mset(values).await,
368        }
369    }
370
371    /// Sets the given keys to their respective values.
372    ///
373    /// Queued into this delivery's segment; it runs after the handler returns, when
374    /// the delivery is acknowledged.
375    pub async fn msetnx<V>(&self, values: V) -> Result<(), Error>
376    where
377        V: TryInto<Map> + Send,
378        V::Error: Into<Error> + Send,
379    {
380        match self.segment().await? {
381            Segment::Plain(segment) => segment.msetnx::<(), V>(values).await,
382            Segment::Atomic(segment) => segment.msetnx::<(), V>(values).await,
383        }
384    }
385
386    /// Increments the number stored at `key` by one.
387    ///
388    /// Queued into this delivery's segment; it runs after the handler returns, when
389    /// the delivery is acknowledged.
390    pub async fn incr<K>(&self, key: K) -> Result<(), Error>
391    where
392        K: Into<Key> + Send,
393    {
394        match self.segment().await? {
395            Segment::Plain(segment) => segment.incr::<(), K>(key).await,
396            Segment::Atomic(segment) => segment.incr::<(), K>(key).await,
397        }
398    }
399
400    /// Increments the number stored at `key` by `val`.
401    ///
402    /// Queued into this delivery's segment; it runs after the handler returns, when
403    /// the delivery is acknowledged.
404    pub async fn incr_by<K>(&self, key: K, val: i64) -> Result<(), Error>
405    where
406        K: Into<Key> + Send,
407    {
408        match self.segment().await? {
409            Segment::Plain(segment) => segment.incr_by::<(), K>(key, val).await,
410            Segment::Atomic(segment) => segment.incr_by::<(), K>(key, val).await,
411        }
412    }
413
414    /// Increment the string representing a floating point number stored at key by `val`.
415    ///
416    /// Queued into this delivery's segment; it runs after the handler returns, when
417    /// the delivery is acknowledged.
418    pub async fn incr_by_float<K>(&self, key: K, val: f64) -> Result<(), Error>
419    where
420        K: Into<Key> + Send,
421    {
422        match self.segment().await? {
423            Segment::Plain(segment) => segment.incr_by_float::<(), K>(key, val).await,
424            Segment::Atomic(segment) => segment.incr_by_float::<(), K>(key, val).await,
425        }
426    }
427
428    /// Decrements the number stored at `key` by one.
429    ///
430    /// Queued into this delivery's segment; it runs after the handler returns, when
431    /// the delivery is acknowledged.
432    pub async fn decr<K>(&self, key: K) -> Result<(), Error>
433    where
434        K: Into<Key> + Send,
435    {
436        match self.segment().await? {
437            Segment::Plain(segment) => segment.decr::<(), K>(key).await,
438            Segment::Atomic(segment) => segment.decr::<(), K>(key).await,
439        }
440    }
441
442    /// Decrements the number stored at `key` by `val`.
443    ///
444    /// Queued into this delivery's segment; it runs after the handler returns, when
445    /// the delivery is acknowledged.
446    pub async fn decr_by<K>(&self, key: K, val: i64) -> Result<(), Error>
447    where
448        K: Into<Key> + Send,
449    {
450        match self.segment().await? {
451            Segment::Plain(segment) => segment.decr_by::<(), K>(key, val).await,
452            Segment::Atomic(segment) => segment.decr_by::<(), K>(key, val).await,
453        }
454    }
455
456    /// Returns the remaining time to live of a key that has a timeout, in seconds.
457    ///
458    /// Queued into this delivery's segment; it runs after the handler returns, when
459    /// the delivery is acknowledged.
460    pub async fn ttl<K>(&self, key: K) -> Result<(), Error>
461    where
462        K: Into<Key> + Send,
463    {
464        match self.segment().await? {
465            Segment::Plain(segment) => segment.ttl::<(), K>(key).await,
466            Segment::Atomic(segment) => segment.ttl::<(), K>(key).await,
467        }
468    }
469
470    /// Returns the remaining time to live of a key that has a timeout, in milliseconds.
471    ///
472    /// Queued into this delivery's segment; it runs after the handler returns, when
473    /// the delivery is acknowledged.
474    pub async fn pttl<K>(&self, key: K) -> Result<(), Error>
475    where
476        K: Into<Key> + Send,
477    {
478        match self.segment().await? {
479            Segment::Plain(segment) => segment.pttl::<(), K>(key).await,
480            Segment::Atomic(segment) => segment.pttl::<(), K>(key).await,
481        }
482    }
483
484    /// Remove the existing timeout on a key, turning the key from volatile (a key with an expiration) to persistent (a key that will never expire as no timeout is associated).
485    ///
486    /// Queued into this delivery's segment; it runs after the handler returns, when
487    /// the delivery is acknowledged.
488    pub async fn persist<K>(&self, key: K) -> Result<(), Error>
489    where
490        K: Into<Key> + Send,
491    {
492        match self.segment().await? {
493            Segment::Plain(segment) => segment.persist::<(), K>(key).await,
494            Segment::Atomic(segment) => segment.persist::<(), K>(key).await,
495        }
496    }
497
498    /// Set a timeout on key.
499    ///
500    /// Queued into this delivery's segment; it runs after the handler returns, when
501    /// the delivery is acknowledged.
502    pub async fn expire<K>(
503        &self,
504        key: K,
505        seconds: i64,
506        options: Option<ExpireOptions>,
507    ) -> Result<(), Error>
508    where
509        K: Into<Key> + Send,
510    {
511        match self.segment().await? {
512            Segment::Plain(segment) => segment.expire::<(), K>(key, seconds, options).await,
513            Segment::Atomic(segment) => segment.expire::<(), K>(key, seconds, options).await,
514        }
515    }
516
517    /// Set a timeout on a key based on a UNIX timestamp.
518    ///
519    /// Queued into this delivery's segment; it runs after the handler returns, when
520    /// the delivery is acknowledged.
521    pub async fn expire_at<K>(
522        &self,
523        key: K,
524        timestamp: i64,
525        options: Option<ExpireOptions>,
526    ) -> Result<(), Error>
527    where
528        K: Into<Key> + Send,
529    {
530        match self.segment().await? {
531            Segment::Plain(segment) => segment.expire_at::<(), K>(key, timestamp, options).await,
532            Segment::Atomic(segment) => segment.expire_at::<(), K>(key, timestamp, options).await,
533        }
534    }
535
536    /// Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire.
537    ///
538    /// Queued into this delivery's segment; it runs after the handler returns, when
539    /// the delivery is acknowledged.
540    pub async fn expire_time<K>(&self, key: K) -> Result<(), Error>
541    where
542        K: Into<Key> + Send,
543    {
544        match self.segment().await? {
545            Segment::Plain(segment) => segment.expire_time::<(), K>(key).await,
546            Segment::Atomic(segment) => segment.expire_time::<(), K>(key).await,
547        }
548    }
549
550    /// This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.
551    ///
552    /// Queued into this delivery's segment; it runs after the handler returns, when
553    /// the delivery is acknowledged.
554    pub async fn pexpire<K>(
555        &self,
556        key: K,
557        milliseconds: i64,
558        options: Option<ExpireOptions>,
559    ) -> Result<(), Error>
560    where
561        K: Into<Key> + Send,
562    {
563        match self.segment().await? {
564            Segment::Plain(segment) => segment.pexpire::<(), K>(key, milliseconds, options).await,
565            Segment::Atomic(segment) => segment.pexpire::<(), K>(key, milliseconds, options).await,
566        }
567    }
568
569    /// PEXPIREAT has the same effect and semantic as EXPIREAT, but the Unix time at which the key will expire is specified in milliseconds instead of seconds.
570    ///
571    /// Queued into this delivery's segment; it runs after the handler returns, when
572    /// the delivery is acknowledged.
573    pub async fn pexpire_at<K>(
574        &self,
575        key: K,
576        timestamp: i64,
577        options: Option<ExpireOptions>,
578    ) -> Result<(), Error>
579    where
580        K: Into<Key> + Send,
581    {
582        match self.segment().await? {
583            Segment::Plain(segment) => segment.pexpire_at::<(), K>(key, timestamp, options).await,
584            Segment::Atomic(segment) => segment.pexpire_at::<(), K>(key, timestamp, options).await,
585        }
586    }
587
588    /// PEXPIRETIME has the same semantic as EXPIRETIME, but returns the absolute Unix expiration timestamp in milliseconds instead of seconds.
589    ///
590    /// Queued into this delivery's segment; it runs after the handler returns, when
591    /// the delivery is acknowledged.
592    pub async fn pexpire_time<K>(&self, key: K) -> Result<(), Error>
593    where
594        K: Into<Key> + Send,
595    {
596        match self.segment().await? {
597            Segment::Plain(segment) => segment.pexpire_time::<(), K>(key).await,
598            Segment::Atomic(segment) => segment.pexpire_time::<(), K>(key).await,
599        }
600    }
601
602    /// Returns number of keys that exist from the `keys` arguments.
603    ///
604    /// Queued into this delivery's segment; it runs after the handler returns, when
605    /// the delivery is acknowledged.
606    pub async fn exists<K>(&self, keys: K) -> Result<(), Error>
607    where
608        K: Into<MultipleKeys> + Send,
609    {
610        match self.segment().await? {
611            Segment::Plain(segment) => segment.exists::<(), K>(keys).await,
612            Segment::Atomic(segment) => segment.exists::<(), K>(keys).await,
613        }
614    }
615
616    /// Returns all fields and values of the hash stored at `key`.
617    ///
618    /// Queued into this delivery's segment; it runs after the handler returns, when
619    /// the delivery is acknowledged.
620    pub async fn hgetall<K>(&self, key: K) -> Result<(), Error>
621    where
622        K: Into<Key> + Send,
623    {
624        match self.segment().await? {
625            Segment::Plain(segment) => segment.hgetall::<(), K>(key).await,
626            Segment::Atomic(segment) => segment.hgetall::<(), K>(key).await,
627        }
628    }
629
630    /// Removes the specified fields from the hash stored at `key`.
631    ///
632    /// Queued into this delivery's segment; it runs after the handler returns, when
633    /// the delivery is acknowledged.
634    pub async fn hdel<K, F>(&self, key: K, fields: F) -> Result<(), Error>
635    where
636        K: Into<Key> + Send,
637        F: Into<MultipleKeys> + Send,
638    {
639        match self.segment().await? {
640            Segment::Plain(segment) => segment.hdel::<(), K, F>(key, fields).await,
641            Segment::Atomic(segment) => segment.hdel::<(), K, F>(key, fields).await,
642        }
643    }
644
645    /// Returns if `field` is an existing field in the hash stored at `key`.
646    ///
647    /// Queued into this delivery's segment; it runs after the handler returns, when
648    /// the delivery is acknowledged.
649    pub async fn hexists<K, F>(&self, key: K, field: F) -> Result<(), Error>
650    where
651        K: Into<Key> + Send,
652        F: Into<Key> + Send,
653    {
654        match self.segment().await? {
655            Segment::Plain(segment) => segment.hexists::<(), K, F>(key, field).await,
656            Segment::Atomic(segment) => segment.hexists::<(), K, F>(key, field).await,
657        }
658    }
659
660    /// Returns the value associated with `field` in the hash stored at `key`.
661    ///
662    /// Queued into this delivery's segment; it runs after the handler returns, when
663    /// the delivery is acknowledged.
664    pub async fn hget<K, F>(&self, key: K, field: F) -> Result<(), Error>
665    where
666        K: Into<Key> + Send,
667        F: Into<Key> + Send,
668    {
669        match self.segment().await? {
670            Segment::Plain(segment) => segment.hget::<(), K, F>(key, field).await,
671            Segment::Atomic(segment) => segment.hget::<(), K, F>(key, field).await,
672        }
673    }
674
675    /// Increments the number stored at `field` in the hash stored at `key` by `increment`.
676    ///
677    /// Queued into this delivery's segment; it runs after the handler returns, when
678    /// the delivery is acknowledged.
679    pub async fn hincrby<K, F>(&self, key: K, field: F, increment: i64) -> Result<(), Error>
680    where
681        K: Into<Key> + Send,
682        F: Into<Key> + Send,
683    {
684        match self.segment().await? {
685            Segment::Plain(segment) => segment.hincrby::<(), K, F>(key, field, increment).await,
686            Segment::Atomic(segment) => segment.hincrby::<(), K, F>(key, field, increment).await,
687        }
688    }
689
690    /// Increment the specified `field` of a hash stored at `key`, and representing a floating point number, by the specified `increment`.
691    ///
692    /// Queued into this delivery's segment; it runs after the handler returns, when
693    /// the delivery is acknowledged.
694    pub async fn hincrbyfloat<K, F>(&self, key: K, field: F, increment: f64) -> Result<(), Error>
695    where
696        K: Into<Key> + Send,
697        F: Into<Key> + Send,
698    {
699        match self.segment().await? {
700            Segment::Plain(segment) => {
701                segment
702                    .hincrbyfloat::<(), K, F>(key, field, increment)
703                    .await
704            }
705            Segment::Atomic(segment) => {
706                segment
707                    .hincrbyfloat::<(), K, F>(key, field, increment)
708                    .await
709            }
710        }
711    }
712
713    /// Returns all field names in the hash stored at `key`.
714    ///
715    /// Queued into this delivery's segment; it runs after the handler returns, when
716    /// the delivery is acknowledged.
717    pub async fn hkeys<K>(&self, key: K) -> Result<(), Error>
718    where
719        K: Into<Key> + Send,
720    {
721        match self.segment().await? {
722            Segment::Plain(segment) => segment.hkeys::<(), K>(key).await,
723            Segment::Atomic(segment) => segment.hkeys::<(), K>(key).await,
724        }
725    }
726
727    /// Returns the number of fields contained in the hash stored at `key`.
728    ///
729    /// Queued into this delivery's segment; it runs after the handler returns, when
730    /// the delivery is acknowledged.
731    pub async fn hlen<K>(&self, key: K) -> Result<(), Error>
732    where
733        K: Into<Key> + Send,
734    {
735        match self.segment().await? {
736            Segment::Plain(segment) => segment.hlen::<(), K>(key).await,
737            Segment::Atomic(segment) => segment.hlen::<(), K>(key).await,
738        }
739    }
740
741    /// Returns the values associated with the specified `fields` in the hash stored at `key`.
742    ///
743    /// Queued into this delivery's segment; it runs after the handler returns, when
744    /// the delivery is acknowledged.
745    pub async fn hmget<K, F>(&self, key: K, fields: F) -> Result<(), Error>
746    where
747        K: Into<Key> + Send,
748        F: Into<MultipleKeys> + Send,
749    {
750        match self.segment().await? {
751            Segment::Plain(segment) => segment.hmget::<(), K, F>(key, fields).await,
752            Segment::Atomic(segment) => segment.hmget::<(), K, F>(key, fields).await,
753        }
754    }
755
756    /// Sets the specified fields to their respective values in the hash stored at `key`.
757    ///
758    /// Queued into this delivery's segment; it runs after the handler returns, when
759    /// the delivery is acknowledged.
760    pub async fn hmset<K, V>(&self, key: K, values: V) -> Result<(), Error>
761    where
762        K: Into<Key> + Send,
763        V: TryInto<Map> + Send,
764        V::Error: Into<Error> + Send,
765    {
766        match self.segment().await? {
767            Segment::Plain(segment) => segment.hmset::<(), K, V>(key, values).await,
768            Segment::Atomic(segment) => segment.hmset::<(), K, V>(key, values).await,
769        }
770    }
771
772    /// Sets fields in the hash stored at `key` to their provided values.
773    ///
774    /// Queued into this delivery's segment; it runs after the handler returns, when
775    /// the delivery is acknowledged.
776    pub async fn hset<K, V>(&self, key: K, values: V) -> Result<(), Error>
777    where
778        K: Into<Key> + Send,
779        V: TryInto<Map> + Send,
780        V::Error: Into<Error> + Send,
781    {
782        match self.segment().await? {
783            Segment::Plain(segment) => segment.hset::<(), K, V>(key, values).await,
784            Segment::Atomic(segment) => segment.hset::<(), K, V>(key, values).await,
785        }
786    }
787
788    /// Sets `field` in the hash stored at `key` to `value`, only if `field` does not yet exist.
789    ///
790    /// Queued into this delivery's segment; it runs after the handler returns, when
791    /// the delivery is acknowledged.
792    pub async fn hsetnx<K, F, V>(&self, key: K, field: F, value: V) -> Result<(), Error>
793    where
794        K: Into<Key> + Send,
795        F: Into<Key> + Send,
796        V: TryInto<Value> + Send,
797        V::Error: Into<Error> + Send,
798    {
799        match self.segment().await? {
800            Segment::Plain(segment) => segment.hsetnx::<(), K, F, V>(key, field, value).await,
801            Segment::Atomic(segment) => segment.hsetnx::<(), K, F, V>(key, field, value).await,
802        }
803    }
804
805    /// When called with just the `key` argument, return a random field from the hash value stored at `key`.
806    ///
807    /// Queued into this delivery's segment; it runs after the handler returns, when
808    /// the delivery is acknowledged.
809    pub async fn hrandfield<K>(&self, key: K, count: Option<(i64, bool)>) -> Result<(), Error>
810    where
811        K: Into<Key> + Send,
812    {
813        match self.segment().await? {
814            Segment::Plain(segment) => segment.hrandfield::<(), K>(key, count).await,
815            Segment::Atomic(segment) => segment.hrandfield::<(), K>(key, count).await,
816        }
817    }
818
819    /// Returns the string length of the value associated with `field` in the hash stored at `key`.
820    ///
821    /// Queued into this delivery's segment; it runs after the handler returns, when
822    /// the delivery is acknowledged.
823    pub async fn hstrlen<K, F>(&self, key: K, field: F) -> Result<(), Error>
824    where
825        K: Into<Key> + Send,
826        F: Into<Key> + Send,
827    {
828        match self.segment().await? {
829            Segment::Plain(segment) => segment.hstrlen::<(), K, F>(key, field).await,
830            Segment::Atomic(segment) => segment.hstrlen::<(), K, F>(key, field).await,
831        }
832    }
833
834    /// Returns all values in the hash stored at `key`.
835    ///
836    /// Queued into this delivery's segment; it runs after the handler returns, when
837    /// the delivery is acknowledged.
838    pub async fn hvals<K>(&self, key: K) -> Result<(), Error>
839    where
840        K: Into<Key> + Send,
841    {
842        match self.segment().await? {
843            Segment::Plain(segment) => segment.hvals::<(), K>(key).await,
844            Segment::Atomic(segment) => segment.hvals::<(), K>(key).await,
845        }
846    }
847
848    /// Pops one or more elements from the first non-empty list key from the list of provided key names.
849    ///
850    /// Queued into this delivery's segment; it runs after the handler returns, when
851    /// the delivery is acknowledged.
852    pub async fn lmpop<K>(
853        &self,
854        keys: K,
855        direction: LMoveDirection,
856        count: Option<i64>,
857    ) -> Result<(), Error>
858    where
859        K: Into<MultipleKeys> + Send,
860    {
861        match self.segment().await? {
862            Segment::Plain(segment) => segment.lmpop::<(), K>(keys, direction, count).await,
863            Segment::Atomic(segment) => segment.lmpop::<(), K>(keys, direction, count).await,
864        }
865    }
866
867    /// Returns the element at index in the list stored at key.
868    ///
869    /// Queued into this delivery's segment; it runs after the handler returns, when
870    /// the delivery is acknowledged.
871    pub async fn lindex<K>(&self, key: K, index: i64) -> Result<(), Error>
872    where
873        K: Into<Key> + Send,
874    {
875        match self.segment().await? {
876            Segment::Plain(segment) => segment.lindex::<(), K>(key, index).await,
877            Segment::Atomic(segment) => segment.lindex::<(), K>(key, index).await,
878        }
879    }
880
881    /// Inserts element in the list stored at key either before or after the reference value `pivot`.
882    ///
883    /// Queued into this delivery's segment; it runs after the handler returns, when
884    /// the delivery is acknowledged.
885    pub async fn linsert<K, P, V>(
886        &self,
887        key: K,
888        location: ListLocation,
889        pivot: P,
890        element: V,
891    ) -> Result<(), Error>
892    where
893        K: Into<Key> + Send,
894        P: TryInto<Value> + Send,
895        P::Error: Into<Error> + Send,
896        V: TryInto<Value> + Send,
897        V::Error: Into<Error> + Send,
898    {
899        match self.segment().await? {
900            Segment::Plain(segment) => {
901                segment
902                    .linsert::<(), K, P, V>(key, location, pivot, element)
903                    .await
904            }
905            Segment::Atomic(segment) => {
906                segment
907                    .linsert::<(), K, P, V>(key, location, pivot, element)
908                    .await
909            }
910        }
911    }
912
913    /// Returns the length of the list stored at key.
914    ///
915    /// Queued into this delivery's segment; it runs after the handler returns, when
916    /// the delivery is acknowledged.
917    pub async fn llen<K>(&self, key: K) -> Result<(), Error>
918    where
919        K: Into<Key> + Send,
920    {
921        match self.segment().await? {
922            Segment::Plain(segment) => segment.llen::<(), K>(key).await,
923            Segment::Atomic(segment) => segment.llen::<(), K>(key).await,
924        }
925    }
926
927    /// Removes and returns the first elements of the list stored at key.
928    ///
929    /// Queued into this delivery's segment; it runs after the handler returns, when
930    /// the delivery is acknowledged.
931    pub async fn lpop<K>(&self, key: K, count: Option<usize>) -> Result<(), Error>
932    where
933        K: Into<Key> + Send,
934    {
935        match self.segment().await? {
936            Segment::Plain(segment) => segment.lpop::<(), K>(key, count).await,
937            Segment::Atomic(segment) => segment.lpop::<(), K>(key, count).await,
938        }
939    }
940
941    /// The command returns the index of matching elements inside a Redis list.
942    ///
943    /// Queued into this delivery's segment; it runs after the handler returns, when
944    /// the delivery is acknowledged.
945    pub async fn lpos<K, V>(
946        &self,
947        key: K,
948        element: V,
949        rank: Option<i64>,
950        count: Option<i64>,
951        maxlen: Option<i64>,
952    ) -> Result<(), Error>
953    where
954        K: Into<Key> + Send,
955        V: TryInto<Value> + Send,
956        V::Error: Into<Error> + Send,
957    {
958        match self.segment().await? {
959            Segment::Plain(segment) => {
960                segment
961                    .lpos::<(), K, V>(key, element, rank, count, maxlen)
962                    .await
963            }
964            Segment::Atomic(segment) => {
965                segment
966                    .lpos::<(), K, V>(key, element, rank, count, maxlen)
967                    .await
968            }
969        }
970    }
971
972    /// Insert all the specified values at the head of the list stored at `key`.
973    ///
974    /// Queued into this delivery's segment; it runs after the handler returns, when
975    /// the delivery is acknowledged.
976    pub async fn lpush<K, V>(&self, key: K, elements: V) -> Result<(), Error>
977    where
978        K: Into<Key> + Send,
979        V: TryInto<MultipleValues> + Send,
980        V::Error: Into<Error> + Send,
981    {
982        match self.segment().await? {
983            Segment::Plain(segment) => segment.lpush::<(), K, V>(key, elements).await,
984            Segment::Atomic(segment) => segment.lpush::<(), K, V>(key, elements).await,
985        }
986    }
987
988    /// Inserts specified values at the head of the list stored at `key`, only if `key` already exists and holds a list.
989    ///
990    /// Queued into this delivery's segment; it runs after the handler returns, when
991    /// the delivery is acknowledged.
992    pub async fn lpushx<K, V>(&self, key: K, elements: V) -> Result<(), Error>
993    where
994        K: Into<Key> + Send,
995        V: TryInto<MultipleValues> + Send,
996        V::Error: Into<Error> + Send,
997    {
998        match self.segment().await? {
999            Segment::Plain(segment) => segment.lpushx::<(), K, V>(key, elements).await,
1000            Segment::Atomic(segment) => segment.lpushx::<(), K, V>(key, elements).await,
1001        }
1002    }
1003
1004    /// Returns the specified elements of the list stored at `key`.
1005    ///
1006    /// Queued into this delivery's segment; it runs after the handler returns, when
1007    /// the delivery is acknowledged.
1008    pub async fn lrange<K>(&self, key: K, start: i64, stop: i64) -> Result<(), Error>
1009    where
1010        K: Into<Key> + Send,
1011    {
1012        match self.segment().await? {
1013            Segment::Plain(segment) => segment.lrange::<(), K>(key, start, stop).await,
1014            Segment::Atomic(segment) => segment.lrange::<(), K>(key, start, stop).await,
1015        }
1016    }
1017
1018    /// Removes the first `count` occurrences of elements equal to `element` from the list stored at `key`.
1019    ///
1020    /// Queued into this delivery's segment; it runs after the handler returns, when
1021    /// the delivery is acknowledged.
1022    pub async fn lrem<K, V>(&self, key: K, count: i64, element: V) -> Result<(), Error>
1023    where
1024        K: Into<Key> + Send,
1025        V: TryInto<Value> + Send,
1026        V::Error: Into<Error> + Send,
1027    {
1028        match self.segment().await? {
1029            Segment::Plain(segment) => segment.lrem::<(), K, V>(key, count, element).await,
1030            Segment::Atomic(segment) => segment.lrem::<(), K, V>(key, count, element).await,
1031        }
1032    }
1033
1034    /// Sets the list element at `index` to `element`.
1035    ///
1036    /// Queued into this delivery's segment; it runs after the handler returns, when
1037    /// the delivery is acknowledged.
1038    pub async fn lset<K, V>(&self, key: K, index: i64, element: V) -> Result<(), Error>
1039    where
1040        K: Into<Key> + Send,
1041        V: TryInto<Value> + Send,
1042        V::Error: Into<Error> + Send,
1043    {
1044        match self.segment().await? {
1045            Segment::Plain(segment) => segment.lset::<(), K, V>(key, index, element).await,
1046            Segment::Atomic(segment) => segment.lset::<(), K, V>(key, index, element).await,
1047        }
1048    }
1049
1050    /// Trim an existing list so that it will contain only the specified range of elements specified.
1051    ///
1052    /// Queued into this delivery's segment; it runs after the handler returns, when
1053    /// the delivery is acknowledged.
1054    pub async fn ltrim<K>(&self, key: K, start: i64, stop: i64) -> Result<(), Error>
1055    where
1056        K: Into<Key> + Send,
1057    {
1058        match self.segment().await? {
1059            Segment::Plain(segment) => segment.ltrim::<(), K>(key, start, stop).await,
1060            Segment::Atomic(segment) => segment.ltrim::<(), K>(key, start, stop).await,
1061        }
1062    }
1063
1064    /// Removes and returns the last elements of the list stored at `key`.
1065    ///
1066    /// Queued into this delivery's segment; it runs after the handler returns, when
1067    /// the delivery is acknowledged.
1068    pub async fn rpop<K>(&self, key: K, count: Option<usize>) -> Result<(), Error>
1069    where
1070        K: Into<Key> + Send,
1071    {
1072        match self.segment().await? {
1073            Segment::Plain(segment) => segment.rpop::<(), K>(key, count).await,
1074            Segment::Atomic(segment) => segment.rpop::<(), K>(key, count).await,
1075        }
1076    }
1077
1078    /// Atomically returns and removes the last element (tail) of the list stored at `source`, and pushes the element at the first element (head) of the list stored at `destination`.
1079    ///
1080    /// Queued into this delivery's segment; it runs after the handler returns, when
1081    /// the delivery is acknowledged.
1082    pub async fn rpoplpush<S, D>(&self, source: S, dest: D) -> Result<(), Error>
1083    where
1084        S: Into<Key> + Send,
1085        D: Into<Key> + Send,
1086    {
1087        match self.segment().await? {
1088            Segment::Plain(segment) => segment.rpoplpush::<(), S, D>(source, dest).await,
1089            Segment::Atomic(segment) => segment.rpoplpush::<(), S, D>(source, dest).await,
1090        }
1091    }
1092
1093    /// Atomically returns and removes the first/last element (head/tail depending on the source direction argument) of the list stored at `source`, and pushes the element at the first/last element (head/tail depending on the destination direction argument) of the list stored at `destination`.
1094    ///
1095    /// Queued into this delivery's segment; it runs after the handler returns, when
1096    /// the delivery is acknowledged.
1097    pub async fn lmove<S, D>(
1098        &self,
1099        source: S,
1100        dest: D,
1101        source_direction: LMoveDirection,
1102        dest_direction: LMoveDirection,
1103    ) -> Result<(), Error>
1104    where
1105        S: Into<Key> + Send,
1106        D: Into<Key> + Send,
1107    {
1108        match self.segment().await? {
1109            Segment::Plain(segment) => {
1110                segment
1111                    .lmove::<(), S, D>(source, dest, source_direction, dest_direction)
1112                    .await
1113            }
1114            Segment::Atomic(segment) => {
1115                segment
1116                    .lmove::<(), S, D>(source, dest, source_direction, dest_direction)
1117                    .await
1118            }
1119        }
1120    }
1121
1122    /// Insert all the specified values at the tail of the list stored at `key`.
1123    ///
1124    /// Queued into this delivery's segment; it runs after the handler returns, when
1125    /// the delivery is acknowledged.
1126    pub async fn rpush<K, V>(&self, key: K, elements: V) -> Result<(), Error>
1127    where
1128        K: Into<Key> + Send,
1129        V: TryInto<MultipleValues> + Send,
1130        V::Error: Into<Error> + Send,
1131    {
1132        match self.segment().await? {
1133            Segment::Plain(segment) => segment.rpush::<(), K, V>(key, elements).await,
1134            Segment::Atomic(segment) => segment.rpush::<(), K, V>(key, elements).await,
1135        }
1136    }
1137
1138    /// Inserts specified values at the tail of the list stored at `key`, only if key already exists and holds a list.
1139    ///
1140    /// Queued into this delivery's segment; it runs after the handler returns, when
1141    /// the delivery is acknowledged.
1142    pub async fn rpushx<K, V>(&self, key: K, elements: V) -> Result<(), Error>
1143    where
1144        K: Into<Key> + Send,
1145        V: TryInto<MultipleValues> + Send,
1146        V::Error: Into<Error> + Send,
1147    {
1148        match self.segment().await? {
1149            Segment::Plain(segment) => segment.rpushx::<(), K, V>(key, elements).await,
1150            Segment::Atomic(segment) => segment.rpushx::<(), K, V>(key, elements).await,
1151        }
1152    }
1153
1154    /// Returns or stores the elements contained in the list, set or sorted set at `key`.
1155    ///
1156    /// Queued into this delivery's segment; it runs after the handler returns, when
1157    /// the delivery is acknowledged.
1158    pub async fn sort<K, S>(
1159        &self,
1160        key: K,
1161        by: Option<Str>,
1162        limit: Option<Limit>,
1163        get: S,
1164        order: Option<SortOrder>,
1165        alpha: bool,
1166        store: Option<Key>,
1167    ) -> Result<(), Error>
1168    where
1169        K: Into<Key> + Send,
1170        S: Into<MultipleStrings> + Send,
1171    {
1172        match self.segment().await? {
1173            Segment::Plain(segment) => {
1174                segment
1175                    .sort::<(), K, S>(key, by, limit, get, order, alpha, store)
1176                    .await
1177            }
1178            Segment::Atomic(segment) => {
1179                segment
1180                    .sort::<(), K, S>(key, by, limit, get, order, alpha, store)
1181                    .await
1182            }
1183        }
1184    }
1185
1186    /// Read-only variant of the SORT command.
1187    ///
1188    /// Queued into this delivery's segment; it runs after the handler returns, when
1189    /// the delivery is acknowledged.
1190    pub async fn sort_ro<K, S>(
1191        &self,
1192        key: K,
1193        by: Option<Str>,
1194        limit: Option<Limit>,
1195        get: S,
1196        order: Option<SortOrder>,
1197        alpha: bool,
1198    ) -> Result<(), Error>
1199    where
1200        K: Into<Key> + Send,
1201        S: Into<MultipleStrings> + Send,
1202    {
1203        match self.segment().await? {
1204            Segment::Plain(segment) => {
1205                segment
1206                    .sort_ro::<(), K, S>(key, by, limit, get, order, alpha)
1207                    .await
1208            }
1209            Segment::Atomic(segment) => {
1210                segment
1211                    .sort_ro::<(), K, S>(key, by, limit, get, order, alpha)
1212                    .await
1213            }
1214        }
1215    }
1216
1217    /// Add the specified members to the set stored at `key`.
1218    ///
1219    /// Queued into this delivery's segment; it runs after the handler returns, when
1220    /// the delivery is acknowledged.
1221    pub async fn sadd<K, V>(&self, key: K, members: V) -> Result<(), Error>
1222    where
1223        K: Into<Key> + Send,
1224        V: TryInto<MultipleValues> + Send,
1225        V::Error: Into<Error> + Send,
1226    {
1227        match self.segment().await? {
1228            Segment::Plain(segment) => segment.sadd::<(), K, V>(key, members).await,
1229            Segment::Atomic(segment) => segment.sadd::<(), K, V>(key, members).await,
1230        }
1231    }
1232
1233    /// Returns the set cardinality (number of elements) of the set stored at `key`.
1234    ///
1235    /// Queued into this delivery's segment; it runs after the handler returns, when
1236    /// the delivery is acknowledged.
1237    pub async fn scard<K>(&self, key: K) -> Result<(), Error>
1238    where
1239        K: Into<Key> + Send,
1240    {
1241        match self.segment().await? {
1242            Segment::Plain(segment) => segment.scard::<(), K>(key).await,
1243            Segment::Atomic(segment) => segment.scard::<(), K>(key).await,
1244        }
1245    }
1246
1247    /// Returns the members of the set resulting from the difference between the first set and all the successive sets.
1248    ///
1249    /// Queued into this delivery's segment; it runs after the handler returns, when
1250    /// the delivery is acknowledged.
1251    pub async fn sdiff<K>(&self, keys: K) -> Result<(), Error>
1252    where
1253        K: Into<MultipleKeys> + Send,
1254    {
1255        match self.segment().await? {
1256            Segment::Plain(segment) => segment.sdiff::<(), K>(keys).await,
1257            Segment::Atomic(segment) => segment.sdiff::<(), K>(keys).await,
1258        }
1259    }
1260
1261    /// This command is equal to SDIFF, but instead of returning the resulting set, it is stored in `destination`.
1262    ///
1263    /// Queued into this delivery's segment; it runs after the handler returns, when
1264    /// the delivery is acknowledged.
1265    pub async fn sdiffstore<D, K>(&self, dest: D, keys: K) -> Result<(), Error>
1266    where
1267        D: Into<Key> + Send,
1268        K: Into<MultipleKeys> + Send,
1269    {
1270        match self.segment().await? {
1271            Segment::Plain(segment) => segment.sdiffstore::<(), D, K>(dest, keys).await,
1272            Segment::Atomic(segment) => segment.sdiffstore::<(), D, K>(dest, keys).await,
1273        }
1274    }
1275
1276    /// Returns the members of the set resulting from the intersection of all the given sets.
1277    ///
1278    /// Queued into this delivery's segment; it runs after the handler returns, when
1279    /// the delivery is acknowledged.
1280    pub async fn sinter<K>(&self, keys: K) -> Result<(), Error>
1281    where
1282        K: Into<MultipleKeys> + Send,
1283    {
1284        match self.segment().await? {
1285            Segment::Plain(segment) => segment.sinter::<(), K>(keys).await,
1286            Segment::Atomic(segment) => segment.sinter::<(), K>(keys).await,
1287        }
1288    }
1289
1290    /// This command is equal to SINTER, but instead of returning the resulting set, it is stored in `destination`.
1291    ///
1292    /// Queued into this delivery's segment; it runs after the handler returns, when
1293    /// the delivery is acknowledged.
1294    pub async fn sinterstore<D, K>(&self, dest: D, keys: K) -> Result<(), Error>
1295    where
1296        D: Into<Key> + Send,
1297        K: Into<MultipleKeys> + Send,
1298    {
1299        match self.segment().await? {
1300            Segment::Plain(segment) => segment.sinterstore::<(), D, K>(dest, keys).await,
1301            Segment::Atomic(segment) => segment.sinterstore::<(), D, K>(dest, keys).await,
1302        }
1303    }
1304
1305    /// Returns if `member` is a member of the set stored at `key`.
1306    ///
1307    /// Queued into this delivery's segment; it runs after the handler returns, when
1308    /// the delivery is acknowledged.
1309    pub async fn sismember<K, V>(&self, key: K, member: V) -> Result<(), Error>
1310    where
1311        K: Into<Key> + Send,
1312        V: TryInto<Value> + Send,
1313        V::Error: Into<Error> + Send,
1314    {
1315        match self.segment().await? {
1316            Segment::Plain(segment) => segment.sismember::<(), K, V>(key, member).await,
1317            Segment::Atomic(segment) => segment.sismember::<(), K, V>(key, member).await,
1318        }
1319    }
1320
1321    /// Returns whether each member is a member of the set stored at `key`.
1322    ///
1323    /// Queued into this delivery's segment; it runs after the handler returns, when
1324    /// the delivery is acknowledged.
1325    pub async fn smismember<K, V>(&self, key: K, members: V) -> Result<(), Error>
1326    where
1327        K: Into<Key> + Send,
1328        V: TryInto<MultipleValues> + Send,
1329        V::Error: Into<Error> + Send,
1330    {
1331        match self.segment().await? {
1332            Segment::Plain(segment) => segment.smismember::<(), K, V>(key, members).await,
1333            Segment::Atomic(segment) => segment.smismember::<(), K, V>(key, members).await,
1334        }
1335    }
1336
1337    /// Returns all the members of the set value stored at `key`.
1338    ///
1339    /// Queued into this delivery's segment; it runs after the handler returns, when
1340    /// the delivery is acknowledged.
1341    pub async fn smembers<K>(&self, key: K) -> Result<(), Error>
1342    where
1343        K: Into<Key> + Send,
1344    {
1345        match self.segment().await? {
1346            Segment::Plain(segment) => segment.smembers::<(), K>(key).await,
1347            Segment::Atomic(segment) => segment.smembers::<(), K>(key).await,
1348        }
1349    }
1350
1351    /// Move `member` from the set at `source` to the set at `destination`.
1352    ///
1353    /// Queued into this delivery's segment; it runs after the handler returns, when
1354    /// the delivery is acknowledged.
1355    pub async fn smove<S, D, V>(&self, source: S, dest: D, member: V) -> Result<(), Error>
1356    where
1357        S: Into<Key> + Send,
1358        D: Into<Key> + Send,
1359        V: TryInto<Value> + Send,
1360        V::Error: Into<Error> + Send,
1361    {
1362        match self.segment().await? {
1363            Segment::Plain(segment) => segment.smove::<(), S, D, V>(source, dest, member).await,
1364            Segment::Atomic(segment) => segment.smove::<(), S, D, V>(source, dest, member).await,
1365        }
1366    }
1367
1368    /// Removes and returns one or more random members from the set value store at `key`.
1369    ///
1370    /// Queued into this delivery's segment; it runs after the handler returns, when
1371    /// the delivery is acknowledged.
1372    pub async fn spop<K>(&self, key: K, count: Option<usize>) -> Result<(), Error>
1373    where
1374        K: Into<Key> + Send,
1375    {
1376        match self.segment().await? {
1377            Segment::Plain(segment) => segment.spop::<(), K>(key, count).await,
1378            Segment::Atomic(segment) => segment.spop::<(), K>(key, count).await,
1379        }
1380    }
1381
1382    /// When called with just the key argument, return a random element from the set value stored at `key`.
1383    ///
1384    /// Queued into this delivery's segment; it runs after the handler returns, when
1385    /// the delivery is acknowledged.
1386    pub async fn srandmember<K>(&self, key: K, count: Option<usize>) -> Result<(), Error>
1387    where
1388        K: Into<Key> + Send,
1389    {
1390        match self.segment().await? {
1391            Segment::Plain(segment) => segment.srandmember::<(), K>(key, count).await,
1392            Segment::Atomic(segment) => segment.srandmember::<(), K>(key, count).await,
1393        }
1394    }
1395
1396    /// Remove the specified members from the set stored at `key`.
1397    ///
1398    /// Queued into this delivery's segment; it runs after the handler returns, when
1399    /// the delivery is acknowledged.
1400    pub async fn srem<K, V>(&self, key: K, members: V) -> Result<(), Error>
1401    where
1402        K: Into<Key> + Send,
1403        V: TryInto<MultipleValues> + Send,
1404        V::Error: Into<Error> + Send,
1405    {
1406        match self.segment().await? {
1407            Segment::Plain(segment) => segment.srem::<(), K, V>(key, members).await,
1408            Segment::Atomic(segment) => segment.srem::<(), K, V>(key, members).await,
1409        }
1410    }
1411
1412    /// Returns the members of the set resulting from the union of all the given sets.
1413    ///
1414    /// Queued into this delivery's segment; it runs after the handler returns, when
1415    /// the delivery is acknowledged.
1416    pub async fn sunion<K>(&self, keys: K) -> Result<(), Error>
1417    where
1418        K: Into<MultipleKeys> + Send,
1419    {
1420        match self.segment().await? {
1421            Segment::Plain(segment) => segment.sunion::<(), K>(keys).await,
1422            Segment::Atomic(segment) => segment.sunion::<(), K>(keys).await,
1423        }
1424    }
1425
1426    /// This command is equal to SUNION, but instead of returning the resulting set, it is stored in `destination`.
1427    ///
1428    /// Queued into this delivery's segment; it runs after the handler returns, when
1429    /// the delivery is acknowledged.
1430    pub async fn sunionstore<D, K>(&self, dest: D, keys: K) -> Result<(), Error>
1431    where
1432        D: Into<Key> + Send,
1433        K: Into<MultipleKeys> + Send,
1434    {
1435        match self.segment().await? {
1436            Segment::Plain(segment) => segment.sunionstore::<(), D, K>(dest, keys).await,
1437            Segment::Atomic(segment) => segment.sunionstore::<(), D, K>(dest, keys).await,
1438        }
1439    }
1440
1441    /// Adds all the specified members with the specified scores to the sorted set stored at `key`.
1442    ///
1443    /// Queued into this delivery's segment; it runs after the handler returns, when
1444    /// the delivery is acknowledged.
1445    pub async fn zadd<K, V>(
1446        &self,
1447        key: K,
1448        options: Option<SetOptions>,
1449        ordering: Option<Ordering>,
1450        changed: bool,
1451        incr: bool,
1452        values: V,
1453    ) -> Result<(), Error>
1454    where
1455        K: Into<Key> + Send,
1456        V: TryInto<MultipleZaddValues> + Send,
1457        V::Error: Into<Error> + Send,
1458    {
1459        match self.segment().await? {
1460            Segment::Plain(segment) => {
1461                segment
1462                    .zadd::<(), K, V>(key, options, ordering, changed, incr, values)
1463                    .await
1464            }
1465            Segment::Atomic(segment) => {
1466                segment
1467                    .zadd::<(), K, V>(key, options, ordering, changed, incr, values)
1468                    .await
1469            }
1470        }
1471    }
1472
1473    /// Returns the sorted set cardinality (number of elements) of the sorted set stored at `key`.
1474    ///
1475    /// Queued into this delivery's segment; it runs after the handler returns, when
1476    /// the delivery is acknowledged.
1477    pub async fn zcard<K>(&self, key: K) -> Result<(), Error>
1478    where
1479        K: Into<Key> + Send,
1480    {
1481        match self.segment().await? {
1482            Segment::Plain(segment) => segment.zcard::<(), K>(key).await,
1483            Segment::Atomic(segment) => segment.zcard::<(), K>(key).await,
1484        }
1485    }
1486
1487    /// Returns the number of elements in the sorted set at `key` with a score between `min` and `max`.
1488    ///
1489    /// Queued into this delivery's segment; it runs after the handler returns, when
1490    /// the delivery is acknowledged.
1491    pub async fn zcount<K>(&self, key: K, min: f64, max: f64) -> Result<(), Error>
1492    where
1493        K: Into<Key> + Send,
1494    {
1495        match self.segment().await? {
1496            Segment::Plain(segment) => segment.zcount::<(), K>(key, min, max).await,
1497            Segment::Atomic(segment) => segment.zcount::<(), K>(key, min, max).await,
1498        }
1499    }
1500
1501    /// This command is similar to ZDIFFSTORE, but instead of storing the resulting sorted set, it is returned to the client.
1502    ///
1503    /// Queued into this delivery's segment; it runs after the handler returns, when
1504    /// the delivery is acknowledged.
1505    pub async fn zdiff<K>(&self, keys: K, withscores: bool) -> Result<(), Error>
1506    where
1507        K: Into<MultipleKeys> + Send,
1508    {
1509        match self.segment().await? {
1510            Segment::Plain(segment) => segment.zdiff::<(), K>(keys, withscores).await,
1511            Segment::Atomic(segment) => segment.zdiff::<(), K>(keys, withscores).await,
1512        }
1513    }
1514
1515    /// Computes the difference between the first and all successive input sorted sets and stores the result in `destination`.
1516    ///
1517    /// Queued into this delivery's segment; it runs after the handler returns, when
1518    /// the delivery is acknowledged.
1519    pub async fn zdiffstore<D, K>(&self, dest: D, keys: K) -> Result<(), Error>
1520    where
1521        D: Into<Key> + Send,
1522        K: Into<MultipleKeys> + Send,
1523    {
1524        match self.segment().await? {
1525            Segment::Plain(segment) => segment.zdiffstore::<(), D, K>(dest, keys).await,
1526            Segment::Atomic(segment) => segment.zdiffstore::<(), D, K>(dest, keys).await,
1527        }
1528    }
1529
1530    /// Increments the score of `member` in the sorted set stored at `key` by `increment`.
1531    ///
1532    /// Queued into this delivery's segment; it runs after the handler returns, when
1533    /// the delivery is acknowledged.
1534    pub async fn zincrby<K, V>(&self, key: K, increment: f64, member: V) -> Result<(), Error>
1535    where
1536        K: Into<Key> + Send,
1537        V: TryInto<Value> + Send,
1538        V::Error: Into<Error> + Send,
1539    {
1540        match self.segment().await? {
1541            Segment::Plain(segment) => segment.zincrby::<(), K, V>(key, increment, member).await,
1542            Segment::Atomic(segment) => segment.zincrby::<(), K, V>(key, increment, member).await,
1543        }
1544    }
1545
1546    /// This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the client.
1547    ///
1548    /// Queued into this delivery's segment; it runs after the handler returns, when
1549    /// the delivery is acknowledged.
1550    pub async fn zinter<K, W>(
1551        &self,
1552        keys: K,
1553        weights: W,
1554        aggregate: Option<AggregateOptions>,
1555        withscores: bool,
1556    ) -> Result<(), Error>
1557    where
1558        K: Into<MultipleKeys> + Send,
1559        W: Into<MultipleWeights> + Send,
1560    {
1561        match self.segment().await? {
1562            Segment::Plain(segment) => {
1563                segment
1564                    .zinter::<(), K, W>(keys, weights, aggregate, withscores)
1565                    .await
1566            }
1567            Segment::Atomic(segment) => {
1568                segment
1569                    .zinter::<(), K, W>(keys, weights, aggregate, withscores)
1570                    .await
1571            }
1572        }
1573    }
1574
1575    /// Computes the intersection of the sorted sets given by the specified keys, and stores the result in `destination`.
1576    ///
1577    /// Queued into this delivery's segment; it runs after the handler returns, when
1578    /// the delivery is acknowledged.
1579    pub async fn zinterstore<D, K, W>(
1580        &self,
1581        dest: D,
1582        keys: K,
1583        weights: W,
1584        aggregate: Option<AggregateOptions>,
1585    ) -> Result<(), Error>
1586    where
1587        D: Into<Key> + Send,
1588        K: Into<MultipleKeys> + Send,
1589        W: Into<MultipleWeights> + Send,
1590    {
1591        match self.segment().await? {
1592            Segment::Plain(segment) => {
1593                segment
1594                    .zinterstore::<(), D, K, W>(dest, keys, weights, aggregate)
1595                    .await
1596            }
1597            Segment::Atomic(segment) => {
1598                segment
1599                    .zinterstore::<(), D, K, W>(dest, keys, weights, aggregate)
1600                    .await
1601            }
1602        }
1603    }
1604
1605    /// When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at key with a value between min and max.
1606    ///
1607    /// Queued into this delivery's segment; it runs after the handler returns, when
1608    /// the delivery is acknowledged.
1609    pub async fn zlexcount<K, M, N>(&self, key: K, min: M, max: N) -> Result<(), Error>
1610    where
1611        K: Into<Key> + Send,
1612        M: TryInto<ZRange> + Send,
1613        M::Error: Into<Error> + Send,
1614        N: TryInto<ZRange> + Send,
1615        N::Error: Into<Error> + Send,
1616    {
1617        match self.segment().await? {
1618            Segment::Plain(segment) => segment.zlexcount::<(), K, M, N>(key, min, max).await,
1619            Segment::Atomic(segment) => segment.zlexcount::<(), K, M, N>(key, min, max).await,
1620        }
1621    }
1622
1623    /// Removes and returns up to count members with the highest scores in the sorted set stored at `key`.
1624    ///
1625    /// Queued into this delivery's segment; it runs after the handler returns, when
1626    /// the delivery is acknowledged.
1627    pub async fn zpopmax<K>(&self, key: K, count: Option<usize>) -> Result<(), Error>
1628    where
1629        K: Into<Key> + Send,
1630    {
1631        match self.segment().await? {
1632            Segment::Plain(segment) => segment.zpopmax::<(), K>(key, count).await,
1633            Segment::Atomic(segment) => segment.zpopmax::<(), K>(key, count).await,
1634        }
1635    }
1636
1637    /// Removes and returns up to count members with the lowest scores in the sorted set stored at `key`.
1638    ///
1639    /// Queued into this delivery's segment; it runs after the handler returns, when
1640    /// the delivery is acknowledged.
1641    pub async fn zpopmin<K>(&self, key: K, count: Option<usize>) -> Result<(), Error>
1642    where
1643        K: Into<Key> + Send,
1644    {
1645        match self.segment().await? {
1646            Segment::Plain(segment) => segment.zpopmin::<(), K>(key, count).await,
1647            Segment::Atomic(segment) => segment.zpopmin::<(), K>(key, count).await,
1648        }
1649    }
1650
1651    /// Pops one or more elements, that are member-score pairs, from the first non-empty sorted set in the provided list of key names.
1652    ///
1653    /// Queued into this delivery's segment; it runs after the handler returns, when
1654    /// the delivery is acknowledged.
1655    pub async fn zmpop<K>(&self, keys: K, sort: ZCmp, count: Option<i64>) -> Result<(), Error>
1656    where
1657        K: Into<MultipleKeys> + Send,
1658    {
1659        match self.segment().await? {
1660            Segment::Plain(segment) => segment.zmpop::<(), K>(keys, sort, count).await,
1661            Segment::Atomic(segment) => segment.zmpop::<(), K>(keys, sort, count).await,
1662        }
1663    }
1664
1665    /// When called with just the key argument, return a random element from the sorted set value stored at `key`.
1666    ///
1667    /// Queued into this delivery's segment; it runs after the handler returns, when
1668    /// the delivery is acknowledged.
1669    pub async fn zrandmember<K>(&self, key: K, count: Option<(i64, bool)>) -> Result<(), Error>
1670    where
1671        K: Into<Key> + Send,
1672    {
1673        match self.segment().await? {
1674            Segment::Plain(segment) => segment.zrandmember::<(), K>(key, count).await,
1675            Segment::Atomic(segment) => segment.zrandmember::<(), K>(key, count).await,
1676        }
1677    }
1678
1679    /// This command is like ZRANGE, but stores the result in the `destination` key.
1680    ///
1681    /// Queued into this delivery's segment; it runs after the handler returns, when
1682    /// the delivery is acknowledged.
1683    pub async fn zrangestore<D, S, M, N>(
1684        &self,
1685        dest: D,
1686        source: S,
1687        min: M,
1688        max: N,
1689        sort: Option<ZSort>,
1690        rev: bool,
1691        limit: Option<Limit>,
1692    ) -> Result<(), Error>
1693    where
1694        D: Into<Key> + Send,
1695        S: Into<Key> + Send,
1696        M: TryInto<ZRange> + Send,
1697        M::Error: Into<Error> + Send,
1698        N: TryInto<ZRange> + Send,
1699        N::Error: Into<Error> + Send,
1700    {
1701        match self.segment().await? {
1702            Segment::Plain(segment) => {
1703                segment
1704                    .zrangestore::<(), D, S, M, N>(dest, source, min, max, sort, rev, limit)
1705                    .await
1706            }
1707            Segment::Atomic(segment) => {
1708                segment
1709                    .zrangestore::<(), D, S, M, N>(dest, source, min, max, sort, rev, limit)
1710                    .await
1711            }
1712        }
1713    }
1714
1715    /// Returns the specified range of elements in the sorted set stored at `key`.
1716    ///
1717    /// Queued into this delivery's segment; it runs after the handler returns, when
1718    /// the delivery is acknowledged.
1719    pub async fn zrange<K, M, N>(
1720        &self,
1721        key: K,
1722        min: M,
1723        max: N,
1724        sort: Option<ZSort>,
1725        rev: bool,
1726        limit: Option<Limit>,
1727        withscores: bool,
1728    ) -> Result<(), Error>
1729    where
1730        K: Into<Key> + Send,
1731        M: TryInto<ZRange> + Send,
1732        M::Error: Into<Error> + Send,
1733        N: TryInto<ZRange> + Send,
1734        N::Error: Into<Error> + Send,
1735    {
1736        match self.segment().await? {
1737            Segment::Plain(segment) => {
1738                segment
1739                    .zrange::<(), K, M, N>(key, min, max, sort, rev, limit, withscores)
1740                    .await
1741            }
1742            Segment::Atomic(segment) => {
1743                segment
1744                    .zrange::<(), K, M, N>(key, min, max, sort, rev, limit, withscores)
1745                    .await
1746            }
1747        }
1748    }
1749
1750    /// When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at `key` with a value between `min` and `max`.
1751    ///
1752    /// Queued into this delivery's segment; it runs after the handler returns, when
1753    /// the delivery is acknowledged.
1754    pub async fn zrangebylex<K, M, N>(
1755        &self,
1756        key: K,
1757        min: M,
1758        max: N,
1759        limit: Option<Limit>,
1760    ) -> Result<(), Error>
1761    where
1762        K: Into<Key> + Send,
1763        M: TryInto<ZRange> + Send,
1764        M::Error: Into<Error> + Send,
1765        N: TryInto<ZRange> + Send,
1766        N::Error: Into<Error> + Send,
1767    {
1768        match self.segment().await? {
1769            Segment::Plain(segment) => {
1770                segment
1771                    .zrangebylex::<(), K, M, N>(key, min, max, limit)
1772                    .await
1773            }
1774            Segment::Atomic(segment) => {
1775                segment
1776                    .zrangebylex::<(), K, M, N>(key, min, max, limit)
1777                    .await
1778            }
1779        }
1780    }
1781
1782    /// When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at `key` with a value between `max` and `min`.
1783    ///
1784    /// Queued into this delivery's segment; it runs after the handler returns, when
1785    /// the delivery is acknowledged.
1786    pub async fn zrevrangebylex<K, M, N>(
1787        &self,
1788        key: K,
1789        max: M,
1790        min: N,
1791        limit: Option<Limit>,
1792    ) -> Result<(), Error>
1793    where
1794        K: Into<Key> + Send,
1795        M: TryInto<ZRange> + Send,
1796        M::Error: Into<Error> + Send,
1797        N: TryInto<ZRange> + Send,
1798        N::Error: Into<Error> + Send,
1799    {
1800        match self.segment().await? {
1801            Segment::Plain(segment) => {
1802                segment
1803                    .zrevrangebylex::<(), K, M, N>(key, max, min, limit)
1804                    .await
1805            }
1806            Segment::Atomic(segment) => {
1807                segment
1808                    .zrevrangebylex::<(), K, M, N>(key, max, min, limit)
1809                    .await
1810            }
1811        }
1812    }
1813
1814    /// Returns all the elements in the sorted set at key with a score between `min` and `max` (including elements with score equal to `min` or `max`).
1815    ///
1816    /// Queued into this delivery's segment; it runs after the handler returns, when
1817    /// the delivery is acknowledged.
1818    pub async fn zrangebyscore<K, M, N>(
1819        &self,
1820        key: K,
1821        min: M,
1822        max: N,
1823        withscores: bool,
1824        limit: Option<Limit>,
1825    ) -> Result<(), Error>
1826    where
1827        K: Into<Key> + Send,
1828        M: TryInto<ZRange> + Send,
1829        M::Error: Into<Error> + Send,
1830        N: TryInto<ZRange> + Send,
1831        N::Error: Into<Error> + Send,
1832    {
1833        match self.segment().await? {
1834            Segment::Plain(segment) => {
1835                segment
1836                    .zrangebyscore::<(), K, M, N>(key, min, max, withscores, limit)
1837                    .await
1838            }
1839            Segment::Atomic(segment) => {
1840                segment
1841                    .zrangebyscore::<(), K, M, N>(key, min, max, withscores, limit)
1842                    .await
1843            }
1844        }
1845    }
1846
1847    /// Returns all the elements in the sorted set at `key` with a score between `max` and `min` (including elements with score equal to `max` or `min`).
1848    ///
1849    /// Queued into this delivery's segment; it runs after the handler returns, when
1850    /// the delivery is acknowledged.
1851    pub async fn zrevrangebyscore<K, M, N>(
1852        &self,
1853        key: K,
1854        max: M,
1855        min: N,
1856        withscores: bool,
1857        limit: Option<Limit>,
1858    ) -> Result<(), Error>
1859    where
1860        K: Into<Key> + Send,
1861        M: TryInto<ZRange> + Send,
1862        M::Error: Into<Error> + Send,
1863        N: TryInto<ZRange> + Send,
1864        N::Error: Into<Error> + Send,
1865    {
1866        match self.segment().await? {
1867            Segment::Plain(segment) => {
1868                segment
1869                    .zrevrangebyscore::<(), K, M, N>(key, max, min, withscores, limit)
1870                    .await
1871            }
1872            Segment::Atomic(segment) => {
1873                segment
1874                    .zrevrangebyscore::<(), K, M, N>(key, max, min, withscores, limit)
1875                    .await
1876            }
1877        }
1878    }
1879
1880    /// Returns the rank of member in the sorted set stored at `key`, with the scores ordered from low to high.
1881    ///
1882    /// Queued into this delivery's segment; it runs after the handler returns, when
1883    /// the delivery is acknowledged.
1884    pub async fn zrank<K, V>(&self, key: K, member: V, withscore: bool) -> Result<(), Error>
1885    where
1886        K: Into<Key> + Send,
1887        V: TryInto<Value> + Send,
1888        V::Error: Into<Error> + Send,
1889    {
1890        match self.segment().await? {
1891            Segment::Plain(segment) => segment.zrank::<(), K, V>(key, member, withscore).await,
1892            Segment::Atomic(segment) => segment.zrank::<(), K, V>(key, member, withscore).await,
1893        }
1894    }
1895
1896    /// Removes the specified members from the sorted set stored at `key`.
1897    ///
1898    /// Queued into this delivery's segment; it runs after the handler returns, when
1899    /// the delivery is acknowledged.
1900    pub async fn zrem<K, V>(&self, key: K, members: V) -> Result<(), Error>
1901    where
1902        K: Into<Key> + Send,
1903        V: TryInto<MultipleValues> + Send,
1904        V::Error: Into<Error> + Send,
1905    {
1906        match self.segment().await? {
1907            Segment::Plain(segment) => segment.zrem::<(), K, V>(key, members).await,
1908            Segment::Atomic(segment) => segment.zrem::<(), K, V>(key, members).await,
1909        }
1910    }
1911
1912    /// When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command removes all elements in the sorted set stored at `key` between the lexicographical range specified by `min` and `max`.
1913    ///
1914    /// Queued into this delivery's segment; it runs after the handler returns, when
1915    /// the delivery is acknowledged.
1916    pub async fn zremrangebylex<K, M, N>(&self, key: K, min: M, max: N) -> Result<(), Error>
1917    where
1918        K: Into<Key> + Send,
1919        M: TryInto<ZRange> + Send,
1920        M::Error: Into<Error> + Send,
1921        N: TryInto<ZRange> + Send,
1922        N::Error: Into<Error> + Send,
1923    {
1924        match self.segment().await? {
1925            Segment::Plain(segment) => segment.zremrangebylex::<(), K, M, N>(key, min, max).await,
1926            Segment::Atomic(segment) => segment.zremrangebylex::<(), K, M, N>(key, min, max).await,
1927        }
1928    }
1929
1930    /// Removes all elements in the sorted set stored at `key` with rank between `start` and `stop`.
1931    ///
1932    /// Queued into this delivery's segment; it runs after the handler returns, when
1933    /// the delivery is acknowledged.
1934    pub async fn zremrangebyrank<K>(&self, key: K, start: i64, stop: i64) -> Result<(), Error>
1935    where
1936        K: Into<Key> + Send,
1937    {
1938        match self.segment().await? {
1939            Segment::Plain(segment) => segment.zremrangebyrank::<(), K>(key, start, stop).await,
1940            Segment::Atomic(segment) => segment.zremrangebyrank::<(), K>(key, start, stop).await,
1941        }
1942    }
1943
1944    /// Removes all elements in the sorted set stored at `key` with a score between `min` and `max`.
1945    ///
1946    /// Queued into this delivery's segment; it runs after the handler returns, when
1947    /// the delivery is acknowledged.
1948    pub async fn zremrangebyscore<K, M, N>(&self, key: K, min: M, max: N) -> Result<(), Error>
1949    where
1950        K: Into<Key> + Send,
1951        M: TryInto<ZRange> + Send,
1952        M::Error: Into<Error> + Send,
1953        N: TryInto<ZRange> + Send,
1954        N::Error: Into<Error> + Send,
1955    {
1956        match self.segment().await? {
1957            Segment::Plain(segment) => segment.zremrangebyscore::<(), K, M, N>(key, min, max).await,
1958            Segment::Atomic(segment) => {
1959                segment.zremrangebyscore::<(), K, M, N>(key, min, max).await
1960            }
1961        }
1962    }
1963
1964    /// Returns the specified range of elements in the sorted set stored at `key`.
1965    ///
1966    /// Queued into this delivery's segment; it runs after the handler returns, when
1967    /// the delivery is acknowledged.
1968    pub async fn zrevrange<K>(
1969        &self,
1970        key: K,
1971        start: i64,
1972        stop: i64,
1973        withscores: bool,
1974    ) -> Result<(), Error>
1975    where
1976        K: Into<Key> + Send,
1977    {
1978        match self.segment().await? {
1979            Segment::Plain(segment) => {
1980                segment
1981                    .zrevrange::<(), K>(key, start, stop, withscores)
1982                    .await
1983            }
1984            Segment::Atomic(segment) => {
1985                segment
1986                    .zrevrange::<(), K>(key, start, stop, withscores)
1987                    .await
1988            }
1989        }
1990    }
1991
1992    /// Returns the rank of `member` in the sorted set stored at `key`, with the scores ordered from high to low.
1993    ///
1994    /// Queued into this delivery's segment; it runs after the handler returns, when
1995    /// the delivery is acknowledged.
1996    pub async fn zrevrank<K, V>(&self, key: K, member: V, withscore: bool) -> Result<(), Error>
1997    where
1998        K: Into<Key> + Send,
1999        V: TryInto<Value> + Send,
2000        V::Error: Into<Error> + Send,
2001    {
2002        match self.segment().await? {
2003            Segment::Plain(segment) => segment.zrevrank::<(), K, V>(key, member, withscore).await,
2004            Segment::Atomic(segment) => segment.zrevrank::<(), K, V>(key, member, withscore).await,
2005        }
2006    }
2007
2008    /// Returns the score of `member` in the sorted set at `key`.
2009    ///
2010    /// Queued into this delivery's segment; it runs after the handler returns, when
2011    /// the delivery is acknowledged.
2012    pub async fn zscore<K, V>(&self, key: K, member: V) -> Result<(), Error>
2013    where
2014        K: Into<Key> + Send,
2015        V: TryInto<Value> + Send,
2016        V::Error: Into<Error> + Send,
2017    {
2018        match self.segment().await? {
2019            Segment::Plain(segment) => segment.zscore::<(), K, V>(key, member).await,
2020            Segment::Atomic(segment) => segment.zscore::<(), K, V>(key, member).await,
2021        }
2022    }
2023
2024    /// This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the client.
2025    ///
2026    /// Queued into this delivery's segment; it runs after the handler returns, when
2027    /// the delivery is acknowledged.
2028    pub async fn zunion<K, W>(
2029        &self,
2030        keys: K,
2031        weights: W,
2032        aggregate: Option<AggregateOptions>,
2033        withscores: bool,
2034    ) -> Result<(), Error>
2035    where
2036        K: Into<MultipleKeys> + Send,
2037        W: Into<MultipleWeights> + Send,
2038    {
2039        match self.segment().await? {
2040            Segment::Plain(segment) => {
2041                segment
2042                    .zunion::<(), K, W>(keys, weights, aggregate, withscores)
2043                    .await
2044            }
2045            Segment::Atomic(segment) => {
2046                segment
2047                    .zunion::<(), K, W>(keys, weights, aggregate, withscores)
2048                    .await
2049            }
2050        }
2051    }
2052
2053    /// Computes the union of the sorted sets given by the specified keys, and stores the result in `destination`.
2054    ///
2055    /// Queued into this delivery's segment; it runs after the handler returns, when
2056    /// the delivery is acknowledged.
2057    pub async fn zunionstore<D, K, W>(
2058        &self,
2059        dest: D,
2060        keys: K,
2061        weights: W,
2062        aggregate: Option<AggregateOptions>,
2063    ) -> Result<(), Error>
2064    where
2065        D: Into<Key> + Send,
2066        K: Into<MultipleKeys> + Send,
2067        W: Into<MultipleWeights> + Send,
2068    {
2069        match self.segment().await? {
2070            Segment::Plain(segment) => {
2071                segment
2072                    .zunionstore::<(), D, K, W>(dest, keys, weights, aggregate)
2073                    .await
2074            }
2075            Segment::Atomic(segment) => {
2076                segment
2077                    .zunionstore::<(), D, K, W>(dest, keys, weights, aggregate)
2078                    .await
2079            }
2080        }
2081    }
2082
2083    /// Returns the scores associated with the specified members in the sorted set stored at `key`.
2084    ///
2085    /// Queued into this delivery's segment; it runs after the handler returns, when
2086    /// the delivery is acknowledged.
2087    pub async fn zmscore<K, V>(&self, key: K, members: V) -> Result<(), Error>
2088    where
2089        K: Into<Key> + Send,
2090        V: TryInto<MultipleValues> + Send,
2091        V::Error: Into<Error> + Send,
2092    {
2093        match self.segment().await? {
2094            Segment::Plain(segment) => segment.zmscore::<(), K, V>(key, members).await,
2095            Segment::Atomic(segment) => segment.zmscore::<(), K, V>(key, members).await,
2096        }
2097    }
2098
2099    /// This command returns the list of consumers that belong to the `groupname` consumer group of the stream stored at `key`.
2100    ///
2101    /// Queued into this delivery's segment; it runs after the handler returns, when
2102    /// the delivery is acknowledged.
2103    pub async fn xinfo_consumers<K, S>(&self, key: K, groupname: S) -> Result<(), Error>
2104    where
2105        K: Into<Key> + Send,
2106        S: Into<Str> + Send,
2107    {
2108        match self.segment().await? {
2109            Segment::Plain(segment) => segment.xinfo_consumers::<(), K, S>(key, groupname).await,
2110            Segment::Atomic(segment) => segment.xinfo_consumers::<(), K, S>(key, groupname).await,
2111        }
2112    }
2113
2114    /// This command returns the list of all consumers groups of the stream stored at `key`.
2115    ///
2116    /// Queued into this delivery's segment; it runs after the handler returns, when
2117    /// the delivery is acknowledged.
2118    pub async fn xinfo_groups<K>(&self, key: K) -> Result<(), Error>
2119    where
2120        K: Into<Key> + Send,
2121    {
2122        match self.segment().await? {
2123            Segment::Plain(segment) => segment.xinfo_groups::<(), K>(key).await,
2124            Segment::Atomic(segment) => segment.xinfo_groups::<(), K>(key).await,
2125        }
2126    }
2127
2128    /// This command returns information about the stream stored at `key`.
2129    ///
2130    /// Queued into this delivery's segment; it runs after the handler returns, when
2131    /// the delivery is acknowledged.
2132    pub async fn xinfo_stream<K>(&self, key: K, full: bool, count: Option<u64>) -> Result<(), Error>
2133    where
2134        K: Into<Key> + Send,
2135    {
2136        match self.segment().await? {
2137            Segment::Plain(segment) => segment.xinfo_stream::<(), K>(key, full, count).await,
2138            Segment::Atomic(segment) => segment.xinfo_stream::<(), K>(key, full, count).await,
2139        }
2140    }
2141
2142    /// Appends the specified stream entry to the stream at the specified key.
2143    ///
2144    /// Queued into this delivery's segment; it runs after the handler returns, when
2145    /// the delivery is acknowledged.
2146    pub async fn xadd<K, C, I, F>(
2147        &self,
2148        key: K,
2149        nomkstream: bool,
2150        cap: C,
2151        id: I,
2152        fields: F,
2153    ) -> Result<(), Error>
2154    where
2155        K: Into<Key> + Send,
2156        I: Into<XID> + Send,
2157        F: TryInto<MultipleOrderedPairs> + Send,
2158        F::Error: Into<Error> + Send,
2159        C: TryInto<XCap> + Send,
2160        C::Error: Into<Error> + Send,
2161    {
2162        match self.segment().await? {
2163            Segment::Plain(segment) => {
2164                segment
2165                    .xadd::<(), K, C, I, F>(key, nomkstream, cap, id, fields)
2166                    .await
2167            }
2168            Segment::Atomic(segment) => {
2169                segment
2170                    .xadd::<(), K, C, I, F>(key, nomkstream, cap, id, fields)
2171                    .await
2172            }
2173        }
2174    }
2175
2176    /// Trims the stream by evicting older entries (entries with lower IDs) if needed.
2177    ///
2178    /// Queued into this delivery's segment; it runs after the handler returns, when
2179    /// the delivery is acknowledged.
2180    pub async fn xtrim<K, C>(&self, key: K, cap: C) -> Result<(), Error>
2181    where
2182        K: Into<Key> + Send,
2183        C: TryInto<XCap> + Send,
2184        C::Error: Into<Error> + Send,
2185    {
2186        match self.segment().await? {
2187            Segment::Plain(segment) => segment.xtrim::<(), K, C>(key, cap).await,
2188            Segment::Atomic(segment) => segment.xtrim::<(), K, C>(key, cap).await,
2189        }
2190    }
2191
2192    /// Removes the specified entries from a stream, and returns the number of entries deleted.
2193    ///
2194    /// Queued into this delivery's segment; it runs after the handler returns, when
2195    /// the delivery is acknowledged.
2196    pub async fn xdel<K, S>(&self, key: K, ids: S) -> Result<(), Error>
2197    where
2198        K: Into<Key> + Send,
2199        S: Into<MultipleStrings> + Send,
2200    {
2201        match self.segment().await? {
2202            Segment::Plain(segment) => segment.xdel::<(), K, S>(key, ids).await,
2203            Segment::Atomic(segment) => segment.xdel::<(), K, S>(key, ids).await,
2204        }
2205    }
2206
2207    /// The command returns the stream entries matching a given range of IDs.
2208    ///
2209    /// Queued into this delivery's segment; it runs after the handler returns, when
2210    /// the delivery is acknowledged.
2211    pub async fn xrange<K, S, E>(
2212        &self,
2213        key: K,
2214        start: S,
2215        end: E,
2216        count: Option<u64>,
2217    ) -> Result<(), Error>
2218    where
2219        K: Into<Key> + Send,
2220        S: TryInto<Value> + Send,
2221        S::Error: Into<Error> + Send,
2222        E: TryInto<Value> + Send,
2223        E::Error: Into<Error> + Send,
2224    {
2225        match self.segment().await? {
2226            Segment::Plain(segment) => segment.xrange::<(), K, S, E>(key, start, end, count).await,
2227            Segment::Atomic(segment) => segment.xrange::<(), K, S, E>(key, start, end, count).await,
2228        }
2229    }
2230
2231    /// Similar to `XRANGE`, but with the results returned in reverse order.
2232    ///
2233    /// Queued into this delivery's segment; it runs after the handler returns, when
2234    /// the delivery is acknowledged.
2235    pub async fn xrevrange<K, S, E>(
2236        &self,
2237        key: K,
2238        end: E,
2239        start: S,
2240        count: Option<u64>,
2241    ) -> Result<(), Error>
2242    where
2243        K: Into<Key> + Send,
2244        S: TryInto<Value> + Send,
2245        S::Error: Into<Error> + Send,
2246        E: TryInto<Value> + Send,
2247        E::Error: Into<Error> + Send,
2248    {
2249        match self.segment().await? {
2250            Segment::Plain(segment) => {
2251                segment
2252                    .xrevrange::<(), K, S, E>(key, end, start, count)
2253                    .await
2254            }
2255            Segment::Atomic(segment) => {
2256                segment
2257                    .xrevrange::<(), K, S, E>(key, end, start, count)
2258                    .await
2259            }
2260        }
2261    }
2262
2263    /// Returns the number of entries inside a stream.
2264    ///
2265    /// Queued into this delivery's segment; it runs after the handler returns, when
2266    /// the delivery is acknowledged.
2267    pub async fn xlen<K>(&self, key: K) -> Result<(), Error>
2268    where
2269        K: Into<Key> + Send,
2270    {
2271        match self.segment().await? {
2272            Segment::Plain(segment) => segment.xlen::<(), K>(key).await,
2273            Segment::Atomic(segment) => segment.xlen::<(), K>(key).await,
2274        }
2275    }
2276
2277    /// This command creates a new consumer group uniquely identified by `groupname` for the stream stored at `key`.
2278    ///
2279    /// Queued into this delivery's segment; it runs after the handler returns, when
2280    /// the delivery is acknowledged.
2281    pub async fn xgroup_create<K, S, I>(
2282        &self,
2283        key: K,
2284        groupname: S,
2285        id: I,
2286        mkstream: bool,
2287    ) -> Result<(), Error>
2288    where
2289        K: Into<Key> + Send,
2290        S: Into<Str> + Send,
2291        I: Into<XID> + Send,
2292    {
2293        match self.segment().await? {
2294            Segment::Plain(segment) => {
2295                segment
2296                    .xgroup_create::<(), K, S, I>(key, groupname, id, mkstream)
2297                    .await
2298            }
2299            Segment::Atomic(segment) => {
2300                segment
2301                    .xgroup_create::<(), K, S, I>(key, groupname, id, mkstream)
2302                    .await
2303            }
2304        }
2305    }
2306
2307    /// Create a consumer named `consumername` in the consumer group `groupname` of the stream that's stored at `key`.
2308    ///
2309    /// Queued into this delivery's segment; it runs after the handler returns, when
2310    /// the delivery is acknowledged.
2311    pub async fn xgroup_createconsumer<K, G, C>(
2312        &self,
2313        key: K,
2314        groupname: G,
2315        consumername: C,
2316    ) -> Result<(), Error>
2317    where
2318        K: Into<Key> + Send,
2319        G: Into<Str> + Send,
2320        C: Into<Str> + Send,
2321    {
2322        match self.segment().await? {
2323            Segment::Plain(segment) => {
2324                segment
2325                    .xgroup_createconsumer::<(), K, G, C>(key, groupname, consumername)
2326                    .await
2327            }
2328            Segment::Atomic(segment) => {
2329                segment
2330                    .xgroup_createconsumer::<(), K, G, C>(key, groupname, consumername)
2331                    .await
2332            }
2333        }
2334    }
2335
2336    /// Delete a consumer named `consumername` in the consumer group `groupname` of the stream that's stored at `key`.
2337    ///
2338    /// Queued into this delivery's segment; it runs after the handler returns, when
2339    /// the delivery is acknowledged.
2340    pub async fn xgroup_delconsumer<K, G, C>(
2341        &self,
2342        key: K,
2343        groupname: G,
2344        consumername: C,
2345    ) -> Result<(), Error>
2346    where
2347        K: Into<Key> + Send,
2348        G: Into<Str> + Send,
2349        C: Into<Str> + Send,
2350    {
2351        match self.segment().await? {
2352            Segment::Plain(segment) => {
2353                segment
2354                    .xgroup_delconsumer::<(), K, G, C>(key, groupname, consumername)
2355                    .await
2356            }
2357            Segment::Atomic(segment) => {
2358                segment
2359                    .xgroup_delconsumer::<(), K, G, C>(key, groupname, consumername)
2360                    .await
2361            }
2362        }
2363    }
2364
2365    /// Completely destroy a consumer group.
2366    ///
2367    /// Queued into this delivery's segment; it runs after the handler returns, when
2368    /// the delivery is acknowledged.
2369    pub async fn xgroup_destroy<K, S>(&self, key: K, groupname: S) -> Result<(), Error>
2370    where
2371        K: Into<Key> + Send,
2372        S: Into<Str> + Send,
2373    {
2374        match self.segment().await? {
2375            Segment::Plain(segment) => segment.xgroup_destroy::<(), K, S>(key, groupname).await,
2376            Segment::Atomic(segment) => segment.xgroup_destroy::<(), K, S>(key, groupname).await,
2377        }
2378    }
2379
2380    /// Set the last delivered ID for a consumer group.
2381    ///
2382    /// Queued into this delivery's segment; it runs after the handler returns, when
2383    /// the delivery is acknowledged.
2384    pub async fn xgroup_setid<K, S, I>(&self, key: K, groupname: S, id: I) -> Result<(), Error>
2385    where
2386        K: Into<Key> + Send,
2387        S: Into<Str> + Send,
2388        I: Into<XID> + Send,
2389    {
2390        match self.segment().await? {
2391            Segment::Plain(segment) => {
2392                segment
2393                    .xgroup_setid::<(), K, S, I>(key, groupname, id)
2394                    .await
2395            }
2396            Segment::Atomic(segment) => {
2397                segment
2398                    .xgroup_setid::<(), K, S, I>(key, groupname, id)
2399                    .await
2400            }
2401        }
2402    }
2403
2404    /// Remove one or more messages from the Pending Entries List (PEL) of a stream consumer group.
2405    ///
2406    /// Queued into this delivery's segment; it runs after the handler returns, when
2407    /// the delivery is acknowledged.
2408    pub async fn xack<K, G, I>(&self, key: K, group: G, ids: I) -> Result<(), Error>
2409    where
2410        K: Into<Key> + Send,
2411        G: Into<Str> + Send,
2412        I: Into<MultipleIDs> + Send,
2413    {
2414        match self.segment().await? {
2415            Segment::Plain(segment) => segment.xack::<(), K, G, I>(key, group, ids).await,
2416            Segment::Atomic(segment) => segment.xack::<(), K, G, I>(key, group, ids).await,
2417        }
2418    }
2419
2420    /// In the context of a stream consumer group, this command changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument.
2421    ///
2422    /// Queued into this delivery's segment; it runs after the handler returns, when
2423    /// the delivery is acknowledged.
2424    pub async fn xclaim<K, G, C, I>(
2425        &self,
2426        key: K,
2427        group: G,
2428        consumer: C,
2429        min_idle_time: u64,
2430        ids: I,
2431        idle: Option<u64>,
2432        time: Option<u64>,
2433        retry_count: Option<u64>,
2434        force: bool,
2435        justid: bool,
2436    ) -> Result<(), Error>
2437    where
2438        K: Into<Key> + Send,
2439        G: Into<Str> + Send,
2440        C: Into<Str> + Send,
2441        I: Into<MultipleIDs> + Send,
2442    {
2443        match self.segment().await? {
2444            Segment::Plain(segment) => {
2445                segment
2446                    .xclaim::<(), K, G, C, I>(
2447                        key,
2448                        group,
2449                        consumer,
2450                        min_idle_time,
2451                        ids,
2452                        idle,
2453                        time,
2454                        retry_count,
2455                        force,
2456                        justid,
2457                    )
2458                    .await
2459            }
2460            Segment::Atomic(segment) => {
2461                segment
2462                    .xclaim::<(), K, G, C, I>(
2463                        key,
2464                        group,
2465                        consumer,
2466                        min_idle_time,
2467                        ids,
2468                        idle,
2469                        time,
2470                        retry_count,
2471                        force,
2472                        justid,
2473                    )
2474                    .await
2475            }
2476        }
2477    }
2478
2479    /// This command transfers ownership of pending stream entries that match the specified criteria.
2480    ///
2481    /// Queued into this delivery's segment; it runs after the handler returns, when
2482    /// the delivery is acknowledged.
2483    pub async fn xautoclaim<K, G, C, I>(
2484        &self,
2485        key: K,
2486        group: G,
2487        consumer: C,
2488        min_idle_time: u64,
2489        start: I,
2490        count: Option<u64>,
2491        justid: bool,
2492    ) -> Result<(), Error>
2493    where
2494        K: Into<Key> + Send,
2495        G: Into<Str> + Send,
2496        C: Into<Str> + Send,
2497        I: Into<XID> + Send,
2498    {
2499        match self.segment().await? {
2500            Segment::Plain(segment) => {
2501                segment
2502                    .xautoclaim::<(), K, G, C, I>(
2503                        key,
2504                        group,
2505                        consumer,
2506                        min_idle_time,
2507                        start,
2508                        count,
2509                        justid,
2510                    )
2511                    .await
2512            }
2513            Segment::Atomic(segment) => {
2514                segment
2515                    .xautoclaim::<(), K, G, C, I>(
2516                        key,
2517                        group,
2518                        consumer,
2519                        min_idle_time,
2520                        start,
2521                        count,
2522                        justid,
2523                    )
2524                    .await
2525            }
2526        }
2527    }
2528
2529    /// Inspect the list of pending messages in a consumer group.
2530    ///
2531    /// Queued into this delivery's segment; it runs after the handler returns, when
2532    /// the delivery is acknowledged.
2533    pub async fn xpending<K, G, A>(&self, key: K, group: G, args: A) -> Result<(), Error>
2534    where
2535        K: Into<Key> + Send,
2536        G: Into<Str> + Send,
2537        A: Into<XPendingArgs> + Send,
2538    {
2539        match self.segment().await? {
2540            Segment::Plain(segment) => segment.xpending::<(), K, G, A>(key, group, args).await,
2541            Segment::Atomic(segment) => segment.xpending::<(), K, G, A>(key, group, args).await,
2542        }
2543    }
2544
2545    /// Invoke a function.
2546    ///
2547    /// Queued into this delivery's segment; it runs after the handler returns, when
2548    /// the delivery is acknowledged.
2549    pub async fn fcall<F, K, V>(&self, func: F, keys: K, args: V) -> Result<(), Error>
2550    where
2551        F: Into<Str> + Send,
2552        K: Into<MultipleKeys> + Send,
2553        V: TryInto<MultipleValues> + Send,
2554        V::Error: Into<Error> + Send,
2555    {
2556        match self.segment().await? {
2557            Segment::Plain(segment) => segment.fcall::<(), F, K, V>(func, keys, args).await,
2558            Segment::Atomic(segment) => segment.fcall::<(), F, K, V>(func, keys, args).await,
2559        }
2560    }
2561
2562    /// This is a read-only variant of the FCALL command that cannot execute commands that modify data.
2563    ///
2564    /// Queued into this delivery's segment; it runs after the handler returns, when
2565    /// the delivery is acknowledged.
2566    pub async fn fcall_ro<F, K, V>(&self, func: F, keys: K, args: V) -> Result<(), Error>
2567    where
2568        F: Into<Str> + Send,
2569        K: Into<MultipleKeys> + Send,
2570        V: TryInto<MultipleValues> + Send,
2571        V::Error: Into<Error> + Send,
2572    {
2573        match self.segment().await? {
2574            Segment::Plain(segment) => segment.fcall_ro::<(), F, K, V>(func, keys, args).await,
2575            Segment::Atomic(segment) => segment.fcall_ro::<(), F, K, V>(func, keys, args).await,
2576        }
2577    }
2578
2579    /// Delete a library and all its functions.
2580    ///
2581    /// Queued into this delivery's segment; it runs after the handler returns, when
2582    /// the delivery is acknowledged.
2583    pub async fn function_delete<S>(&self, library_name: S) -> Result<(), Error>
2584    where
2585        S: Into<Str> + Send,
2586    {
2587        match self.segment().await? {
2588            Segment::Plain(segment) => segment.function_delete::<(), S>(library_name).await,
2589            Segment::Atomic(segment) => segment.function_delete::<(), S>(library_name).await,
2590        }
2591    }
2592
2593    /// Return the serialized payload of loaded libraries.
2594    ///
2595    /// Queued into this delivery's segment; it runs after the handler returns, when
2596    /// the delivery is acknowledged.
2597    pub async fn function_dump(&self) -> Result<(), Error> {
2598        match self.segment().await? {
2599            Segment::Plain(segment) => segment.function_dump::<()>().await,
2600            Segment::Atomic(segment) => segment.function_dump::<()>().await,
2601        }
2602    }
2603
2604    /// Deletes all the libraries.
2605    ///
2606    /// Queued into this delivery's segment; it runs after the handler returns, when
2607    /// the delivery is acknowledged.
2608    pub async fn function_flush(&self, r#async: bool) -> Result<(), Error> {
2609        match self.segment().await? {
2610            Segment::Plain(segment) => segment.function_flush::<()>(r#async).await,
2611            Segment::Atomic(segment) => segment.function_flush::<()>(r#async).await,
2612        }
2613    }
2614
2615    /// Return information about the functions and libraries.
2616    ///
2617    /// Queued into this delivery's segment; it runs after the handler returns, when
2618    /// the delivery is acknowledged.
2619    pub async fn function_list<S>(
2620        &self,
2621        library_name: Option<S>,
2622        withcode: bool,
2623    ) -> Result<(), Error>
2624    where
2625        S: Into<Str> + Send,
2626    {
2627        match self.segment().await? {
2628            Segment::Plain(segment) => segment.function_list::<(), S>(library_name, withcode).await,
2629            Segment::Atomic(segment) => {
2630                segment.function_list::<(), S>(library_name, withcode).await
2631            }
2632        }
2633    }
2634
2635    /// Load a library to Redis.
2636    ///
2637    /// Queued into this delivery's segment; it runs after the handler returns, when
2638    /// the delivery is acknowledged.
2639    pub async fn function_load<S>(&self, replace: bool, code: S) -> Result<(), Error>
2640    where
2641        S: Into<Str> + Send,
2642    {
2643        match self.segment().await? {
2644            Segment::Plain(segment) => segment.function_load::<(), S>(replace, code).await,
2645            Segment::Atomic(segment) => segment.function_load::<(), S>(replace, code).await,
2646        }
2647    }
2648
2649    /// Restore libraries from the serialized payload.
2650    ///
2651    /// Queued into this delivery's segment; it runs after the handler returns, when
2652    /// the delivery is acknowledged.
2653    pub async fn function_restore<B, P>(&self, serialized: B, policy: P) -> Result<(), Error>
2654    where
2655        B: Into<Bytes> + Send,
2656        P: TryInto<FnPolicy> + Send,
2657        P::Error: Into<Error> + Send,
2658    {
2659        match self.segment().await? {
2660            Segment::Plain(segment) => {
2661                segment
2662                    .function_restore::<(), B, P>(serialized, policy)
2663                    .await
2664            }
2665            Segment::Atomic(segment) => {
2666                segment
2667                    .function_restore::<(), B, P>(serialized, policy)
2668                    .await
2669            }
2670        }
2671    }
2672
2673    /// Return information about the function that's currently running and information about the available execution engines.
2674    ///
2675    /// Queued into this delivery's segment; it runs after the handler returns, when
2676    /// the delivery is acknowledged.
2677    pub async fn function_stats(&self) -> Result<(), Error> {
2678        match self.segment().await? {
2679            Segment::Plain(segment) => segment.function_stats::<()>().await,
2680            Segment::Atomic(segment) => segment.function_stats::<()>().await,
2681        }
2682    }
2683
2684    /// Publish a message on the PubSub interface, returning the number of clients that received the message.
2685    ///
2686    /// Queued into this delivery's segment; it runs after the handler returns, when
2687    /// the delivery is acknowledged.
2688    pub async fn publish<S, V>(&self, channel: S, message: V) -> Result<(), Error>
2689    where
2690        S: Into<Str> + Send,
2691        V: TryInto<Value> + Send,
2692        V::Error: Into<Error> + Send,
2693    {
2694        match self.segment().await? {
2695            Segment::Plain(segment) => segment.publish::<(), S, V>(channel, message).await,
2696            Segment::Atomic(segment) => segment.publish::<(), S, V>(channel, message).await,
2697        }
2698    }
2699
2700    /// Posts a message to the given shard channel.
2701    ///
2702    /// Queued into this delivery's segment; it runs after the handler returns, when
2703    /// the delivery is acknowledged.
2704    pub async fn spublish<S, V>(&self, channel: S, message: V) -> Result<(), Error>
2705    where
2706        S: Into<Str> + Send,
2707        V: TryInto<Value> + Send,
2708        V::Error: Into<Error> + Send,
2709    {
2710        match self.segment().await? {
2711            Segment::Plain(segment) => segment.spublish::<(), S, V>(channel, message).await,
2712            Segment::Atomic(segment) => segment.spublish::<(), S, V>(channel, message).await,
2713        }
2714    }
2715
2716    /// Lists the currently active channels.
2717    ///
2718    /// Queued into this delivery's segment; it runs after the handler returns, when
2719    /// the delivery is acknowledged.
2720    pub async fn pubsub_channels<S>(&self, pattern: S) -> Result<(), Error>
2721    where
2722        S: Into<Str> + Send,
2723    {
2724        match self.segment().await? {
2725            Segment::Plain(segment) => segment.pubsub_channels::<(), S>(pattern).await,
2726            Segment::Atomic(segment) => segment.pubsub_channels::<(), S>(pattern).await,
2727        }
2728    }
2729
2730    /// Returns the number of unique patterns that are subscribed to by clients.
2731    ///
2732    /// Queued into this delivery's segment; it runs after the handler returns, when
2733    /// the delivery is acknowledged.
2734    pub async fn pubsub_numpat(&self) -> Result<(), Error> {
2735        match self.segment().await? {
2736            Segment::Plain(segment) => segment.pubsub_numpat::<()>().await,
2737            Segment::Atomic(segment) => segment.pubsub_numpat::<()>().await,
2738        }
2739    }
2740
2741    /// Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
2742    ///
2743    /// Queued into this delivery's segment; it runs after the handler returns, when
2744    /// the delivery is acknowledged.
2745    pub async fn pubsub_numsub<S>(&self, channels: S) -> Result<(), Error>
2746    where
2747        S: Into<MultipleStrings> + Send,
2748    {
2749        match self.segment().await? {
2750            Segment::Plain(segment) => segment.pubsub_numsub::<(), S>(channels).await,
2751            Segment::Atomic(segment) => segment.pubsub_numsub::<(), S>(channels).await,
2752        }
2753    }
2754
2755    /// Lists the currently active shard channels.
2756    ///
2757    /// Queued into this delivery's segment; it runs after the handler returns, when
2758    /// the delivery is acknowledged.
2759    pub async fn pubsub_shardchannels<S>(&self, pattern: S) -> Result<(), Error>
2760    where
2761        S: Into<Str> + Send,
2762    {
2763        match self.segment().await? {
2764            Segment::Plain(segment) => segment.pubsub_shardchannels::<(), S>(pattern).await,
2765            Segment::Atomic(segment) => segment.pubsub_shardchannels::<(), S>(pattern).await,
2766        }
2767    }
2768
2769    /// Returns the number of subscribers for the specified shard channels.
2770    ///
2771    /// Queued into this delivery's segment; it runs after the handler returns, when
2772    /// the delivery is acknowledged.
2773    pub async fn pubsub_shardnumsub<S>(&self, channels: S) -> Result<(), Error>
2774    where
2775        S: Into<MultipleStrings> + Send,
2776    {
2777        match self.segment().await? {
2778            Segment::Plain(segment) => segment.pubsub_shardnumsub::<(), S>(channels).await,
2779            Segment::Atomic(segment) => segment.pubsub_shardnumsub::<(), S>(channels).await,
2780        }
2781    }
2782}