RESP (REdis Serialization Protocol) encoding and decoding over
::hot::tcp. Handles RESP2 and the RESP3 additions. Internal to the
redis package.
Commands are encoded as arrays of bulk strings. Replies are decoded to
Hot values: simple strings to Str, bulk strings to Str when valid
UTF-8 (else Bytes), integers to Int, doubles to Dec, booleans to
Bool, arrays/sets/pushes to Vec, maps to Map, and the various null
forms to null. Error replies decode to Result.Err.
Values
CR
CR: Int 13
LF
LF: Int 10
Functions
decode-bulk-value
fn (data: Bytes): Any
encode-command
fn (args: Vec): Bytes
Encode a command (a Vec of arguments) as a RESP array of bulk strings. Bytes arguments pass through unchanged (bulk strings are binary-safe); everything else is coerced to its string form. Lengths are byte lengths, not character lengths.
read-aggregate
fn (socket): Any
read-blob-error
fn (socket): Str
read-bulk
fn (socket): Any
read-line
fn (socket): Str
read-line-loop
fn (socket, acc: Bytes): Str
read-map
fn (socket): Map
read-map-n
fn (socket, remaining: Int, acc: Map): Map
read-n
fn (socket, remaining: Int, acc: Vec): Vec
read-null
fn (socket): Null
read-reply
fn (socket): Any
Read and decode a single RESP reply from socket. Blocks until a full
reply arrives. Error replies (-) decode to a Result.Err carrying
the Redis error message.
read-verbatim
fn (socket): Any