Skip to main content

Module render

Module render 

Source
Expand description

Export rendering: serialize query results into CSV, JSON, YAML, or XLSX and atomically write them to a vault-scoped path.

This module is the single source of truth for what an exported file looks like. The CLI’s --output flag and the MCP read tools’ export parameter both delegate here, which keeps the wire shape identical across consumers and lets the pyo3 / wasm bindings get the same renderers for free.

The XLSX backend is feature-gated behind xlsx (default off) so consumers that don’t need spreadsheet output don’t pay for rust_xlsxwriter and its dependency tree.

§Path safety

All exports are written inside the vault root. Absolute paths, .. components, and symlink escapes are rejected. On filename collision, the renderer auto-suffixes (1), (2), … — there is no overwrite mode, by design.

Enums§

Format
Export output format. CSV carries the delimiter byte so callers can pick comma / semicolon / tab without a separate enum.

Functions§

export_records
Export a list of Records to a file under the vault root.
export_value
Export an arbitrary JSON-serializable value to a file under the vault root.
render_records
Render records to the in-memory byte buffer for format. Public for consumers that want to stream/inspect bytes without writing to disk.
render_value
Render an arbitrary JSON value to the format’s bytes. JSON / YAML accept any shape; CSV / XLSX only accept tabular shapes (array of objects, array of scalars, single object).
resolve_export_path
Resolve a requested export path against the vault root, enforcing the vault sandbox and auto-suffixing on filename collision.