Minimal RESP2 encoder/decoder used by FauxRedis.
This module is intentionally self-contained and does not depend on the rest of the application. It operates purely on binaries and iodata.
Supported types:
- simple strings –
{:simple_string, binary}or the atom:ok - errors –
{:error, binary}or{:error, :noauth}etc. - integers –
{:integer, integer}or plain integers bulk strings –
{:bulk, binary | nil}or plain binaries /nil- arrays –
{:array, list}or plain lists
The parser understands all of these forms and returns Elixir values:
- simple string → binary
- error →
{:error, binary} - integer → integer
bulk → binary | nil
- array → list
Summary
Functions
Decodes a single RESP value from the given binary.
Convenience function for decoding exactly one value and asserting that the buffer has been fully consumed.
Encodes a value into RESP iodata.
Types
Functions
Decodes a single RESP value from the given binary.
Returns:
{:ok, value, rest}– successfully decoded one value:more– more data is required{:error, reason}– malformed input
Convenience function for decoding exactly one value and asserting that the buffer has been fully consumed.
Encodes a value into RESP iodata.
Accepted forms:
- binary – bulk string
- nil – null bulk string
- integer – integer reply
- list – array
{:error, message}– error reply{:simple_string, message}– simple string:ok– simple string "OK"