redis

Function pack_command

source
pub fn pack_command(args: &[Vec<u8>]) -> Vec<u8> 
Expand description

Packs a bunch of commands into a request. This is generally a quite useless function as this functionality is nicely wrapped through the Cmd object, but in some cases it can be useful. The return value of this can then be send to the low level ConnectionLike methods.

Example:

let mut args = vec![];
args.extend("SET".to_redis_args());
args.extend("my_key".to_redis_args());
args.extend(42.to_redis_args());
let cmd = redis::pack_command(&args);
assert_eq!(cmd, b"*3\r\n$3\r\nSET\r\n$6\r\nmy_key\r\n$2\r\n42\r\n".to_vec());