Expand description
Typed records: one table, and every rendering derived from it.
§Why this is a re-export and not a wrapper
Everything else in this crate wraps the SDK because there is something to translate: a capability
to hold, an error to map onto one type, a protocol to hide. A Table has none of that. It is a
bounded arena and some arithmetic - no syscall, no capability, no failure mode that a program
should be told about differently. Wrapping twenty-three methods to change nothing would be exactly the
speculative layer CLAUDE.md 26.2 warns against, and it would add a second name for one thing
(Commandment III).
So these are the SDK’s types, re-exported here so that a program written against gs never has
to name the lower layer to use them.
§The one idea worth carrying away
The table is the truth; the grid and the JSON are views of it (Commandment III). Build the table once, then render. Do not build a grid and a JSON separately from the same loop - the moment there are two constructions of one fact, they can disagree, and the one somebody reads will be whichever you did not check.
let mut t = gs::record::Table::new(&["name", "size"]);
let n = t.intern(b"kernel.elf");
t.add_row(&[n, gs::record::Value::Int(1930096)]);
t.sort("size", true);
t.to_grid(&mut sink); // one view
t.to_json(&mut sink); // another view of the SAME table§Bounded, and it will tell you
Fixed capacity, no heap (CLAUDE.md 26.6.1): REC_MAX_ROWS rows, REC_MAX_COLS columns, and a
REC_ARENA-byte string arena. Past that, the row, column or string is dropped (a string that
does not fit becomes Value::Empty) and Table::overflow returns true - which is there to be
CHECKED. One case does NOT set it: an add_row given more values than the table has columns
keeps the first ncols and silently ignores the rest. A truncated table that renders cleanly is a report that lies by
omission, and the flag is how you avoid printing one.
Structs§
- Table
- A bounded table of typed rows - the canonical structured-pipe value. Owned column names (so a
from_jsonparse can name columns dynamically), rows ofValue, and a byte arena holding theStrcells. All inline, no heap.
Enums§
- AggErr
- Why an aggregate failed - each maps to a loud shell notice, never a silent 0.
- AggOp
- A numeric-column reducer (the
sum/min/max/avgpipe aggregators, docs/scripting.md §5). - Value
- A typed cell.
Strpoints into the owningTable’s arena (no lifetimes, no heap).
Constants§
- REC_
ARENA - Backing store (bytes) for interned
Strcell values. - REC_
COL_ NAME - Maximum column-name length (bytes).
- REC_
MAX_ COLS - Maximum columns in a table.
- REC_
MAX_ ROWS - Maximum rows in a table.
- REC_
WIRE_ MAGIC - Magic prefix of the binary wire encoding (
Table::encode/decode). Lets a decoder reject a non-record byte stream loudly instead of misparsing it.
Traits§
- Record
Sink - A sink the renderers write bytes into - the caller’s bridge to a console, a capture buffer, or an IPC message. Implement it for whatever the bytes should go to.
Functions§
- parse_
predicate - Parse a compact predicate token
col<op>val(e.g.mem>0,state=BlockRecv,name!=x). The operator is the longest match (!=/>=/<=/==before=/>/</~); before it is the column, after it the value.Noneif no operator is present.