Expand description
Row-level data I/O codecs for LoraDB.
lora-io is the row-level counterpart to lora-snapshot. Snapshots
ship the entire graph as a binary blob; lora-io ships rows
as JSONL, JSON, or CSV. Encoders consume native
lora_executor::Row values and stream them to any
std::io::Write; decoders parse incoming bytes back into flat
(name, LoraValue) records ready to feed into Cypher CREATE
statements (see RowMapping).
The crate has no dependency on the database engine itself. It
deals only with the value model and the on-disk formats. The
import/export driver (which actually executes Cypher) lives in
lora-database::io and re-uses these codecs.
Structs§
- Column
Spec - One file column → one target property.
sourceis the column name as it appears in the file (after schema-marker canonicalisation, e.g._idfor:ID);propertyis the target node/relationship property name. When equal, the mapping is the identity — useful default for the auto-mapping path. - CsvDecoder
- CsvEncoder
- Json
Array Decoder - Decoder that parses the entire array up-front, then yields one
element per
next_rowcall. Not streaming — usesuper::JsonlDecoderfor that. - Json
Array Encoder - Jsonl
Decoder - Jsonl
Encoder - RowParse
Error - Structured per-record parse failure. Carries the user-visible row
number, an optional column attribution (CSV cell parses), a
truncated sample of the raw bytes that failed, and the underlying
message. Boxed into
std::io::Errorviarow_parse_io_errorso it travels through the standardfeed/finishreturn type; recoverable viadowncast_row_parse_error. - Streaming
CsvDecoder - Push-based CSV decoder. Layers a streaming feed loop on top of
the same
process_bufbyte-level state machine used by the pull-basedCsvDecoder. The cell/record state lives on the struct so it persists acrossfeedcalls — partial records stay parked until enough bytes arrive to complete them. - Streaming
Json Array Decoder - Push-based JSON-array decoder. Tracks brace/bracket depth and
JSON string state byte-by-byte so the input can be fed in
arbitrarily sized chunks. Memory bound: at most one in-progress
record (between its opening
{and matching}) plus a single chunk of incoming bytes. - Streaming
Jsonl Decoder - Push-based JSONL decoder. Accumulates bytes between calls to
Self::feed, splits on\n, parses each completed line as a JSON object, and queues the resulting record forSelf::drain.
Enums§
- Format
- Wire format for row-level import/export.
- RowMapping
- Top-level mapping: how to turn a stream of decoded rows into Cypher inserts. Carries enough information for the playground’s auto-detect / preview path; users can edit this in the import dialog before running.
Constants§
- RAW_
SAMPLE_ MAX_ CHARS - Cap on
raw_samplelength to keep error payloads small enough to transport cheaply across the WASM boundary and render in the UI.
Traits§
- RowDecoder
- Pull-based row decoder. Reads from a
std::io::BufReadand yields completed rows one at a time. Used by native Rust callers that already have the input as a stream-like reader. - RowEncoder
- Streaming row encoder. Implementors own the underlying writer and may flush at chunk boundaries.
- Streaming
RowDecoder - Push-based streaming row decoder. The caller feeds bytes one
chunk at a time (e.g. from
File.stream().getReader()in the browser); the decoder accumulates partial records internally and emits completed rows viaSelf::drain. Designed for the WASM streaming-import path where the engine and the source live on different sides of the worker boundary.
Functions§
- downcast_
row_ parse_ error - Attempt to recover a
RowParseErrorfrom anio::Errorpreviously produced viarow_parse_io_error. ReturnsNonefor any other error. - invalid_
data - Wrap an
std::io::Errorwith extra context. Used by decoders when surfacing parser errors as I/O errors. - lora_
value_ from_ json - Parse the canonical tagged JSON shape back into a
LoraValue. Untagged objects becomeLoraValue::Map; untagged arrays becomeLoraValue::List. Strings stay strings — temporal / vector / point values must use the tagged{ "kind": ... }form to round-trip, otherwise they decode as plain strings. - lora_
value_ to_ json - Render a
LoraValueinto aserde_json::Valueusing the canonical tagged shape. The result is lossless — feeding it back throughlora_value_from_jsonreconstructs the original value. - parameterized_
create_ for_ node - Build the Cypher template for a node mapping. The result expects
a
$rowsparameter containing an array of objects whose keys match the source column names referenced by the mapping. - parameterized_
create_ for_ relationship - Build the Cypher template for a relationship mapping.
- row_
parse_ io_ error - Wrap a
RowParseErrorinstd::io::Errorso it flows through the existingResult<_, std::io::Error>channels. Recover the structured form withdowncast_row_parse_error. - write_
all_ rows - Convenience: drive any
RowEncoderthrough a row iterator and return how many rows were written. Used by [super::import] and can also be called directly when a caller already has a materialized result in hand.