Rust NIF parser for the RESP3 protocol.
Parses a binary buffer containing one or more RESP3-encoded values and returns
all complete values along with any unparsed remainder. This module owns the
public RESP parser API; parsing itself is performed by
Ferricstore.Resp.ParserNif.
Supported RESP3 types
| Prefix | Type | Elixir representation |
|---|---|---|
+ | Simple string | {:simple, binary()} |
- | Simple error | {:error, binary()} |
: | Integer | integer() |
$ | Bulk string | binary() or nil for $-1 |
* | Array | list() or nil for *-1 |
_ | Null | nil |
# | Boolean | true or false |
| , | Double | float() or :infinity | :neg_infinity | :nan |
| ( | Big number | integer() |
| ! | Blob error | {:error, binary()} |
| = | Verbatim string | {:verbatim, encoding, data} |
| % | Map | map() |
| ~ | Set | MapSet.t() |
| > | Push | {:push, list()} |
| | | Attribute | {:attribute, map()} |
Inline commands (plain text terminated by \r\n) are returned as
{:inline, [binary()]}.
Bulk-like payload length is checked at parse time against a configurable
maximum (:max_value_size in Application env, default 1 MB). A hard cap of
64 MB is enforced regardless of the configured value.
Summary
Functions
Returns the default maximum value size in bytes (1 MB).
Returns the hard cap on bulk-like payload length in bytes (64 MB).
Parses a binary buffer containing RESP3-encoded data.
Parses a binary buffer with an explicit maximum bulk-like payload size.
Parses server command frames into normalized command tuples in Rust.
Parses server command frames with an explicit maximum command argument size.
Types
@type command_ast() :: tuple()
@type parse_commands_result() :: {:ok, [parsed_command()], binary()} | {:error, term()}
@type parse_result() :: {:ok, [parsed_value()], binary()} | {:error, term()}
@type parsed_command() :: {:command, binary(), [binary()], command_ast(), [binary()]}
Functions
@spec default_max_value_size() :: pos_integer()
Returns the default maximum value size in bytes (1 MB).
@spec hard_cap_bytes() :: pos_integer()
Returns the hard cap on bulk-like payload length in bytes (64 MB).
@spec parse(binary()) :: parse_result()
Parses a binary buffer containing RESP3-encoded data.
@spec parse(binary(), non_neg_integer()) :: parse_result()
Parses a binary buffer with an explicit maximum bulk-like payload size.
@spec parse_commands(binary()) :: parse_commands_result()
Parses server command frames into normalized command tuples in Rust.
Command names are uppercased in the NIF. Arguments remain binary sub-binaries of the input buffer. RESP arrays must contain bulk-string command arguments; inline commands are split on spaces and tabs.
@spec parse_commands(binary(), non_neg_integer()) :: parse_commands_result()
Parses server command frames with an explicit maximum command argument size.