Principle:2giosangmitom Sqmeow nvim View Request Parsing
| Knowledge Sources | |
|---|---|
| Domains | View_Processing, RPC |
| Last Updated | 2026-10-16 14:00 GMT |
Overview
A request parsing principle that decodes structured filter, sort, and column-scope specifications from MessagePack RPC calls into typed engine structures for local result processing.
Description
View Request Parsing is the principle of translating editor grid UI inputs — filter dropdowns, sort columns, column selections, staged edits — from MessagePack arrays and maps into typed engine structures (Filter, Sort, Changes). The parser is strict where wrong input could change behavior or permissions, and lenient where absence is a valid default.
This principle addresses the challenge of bridging the editor's loosely typed Lua tables with the engine's typed Rust structures. Filters carry an optional column index (None = search all columns), an operator (Op enum: Eq, Ne, Gt, Ge, Lt, Le, Contains, StartsWith, IsNull, NotNull), and a value string. Sort carries a column index and descending flag. Column indices are optional (None = all columns). Staged changes distinguish SQL expressions from literal values.
Usage
Use this principle when a grid UI sends filter/sort/edit requests to an engine: parse typed structures from wire format, default sensibly on absence, and reject malformed input that could change behavior.
Theoretical Basis
The principle maps wire-format maps to typed structures:
- Filters: Array of
{column, op, value}→Vec<Filter>. Column isOption<usize>(None = all). Op is parsed from string name; unknown ops error. - Sort: Array of
{column, descending}→Vec<Sort>. Column is required; descending defaults to false. - Indices: Array of u64 →
Option<Vec<usize>>(empty/absent = None = all). - Changes: Map with
updates,deletes,inserts→Changes. Cells distinguishsql(expression) fromvalue(literal).
# Abstract pattern (NOT real implementation):
def filters(value) -> list[Filter]:
return [Filter(
column=item.get("column"), # None = all columns
op=Op.parse(item["op"]), # unknown → error
value=item.get("value", ""),
) for item in value or []]
def changes(value) -> Changes:
return Changes(
updates=[(u["row"], parse_cells(u["cells"])) for u in value["updates"]],
deletes=indices(value["deletes"]),
inserts=[parse_cells(ins) for ins in value["inserts"]],
)