Skip to main content

Crate lora_io

Crate lora_io 

Source
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§

ColumnSpec
One file column → one target property. source is the column name as it appears in the file (after schema-marker canonicalisation, e.g. _id for :ID); property is the target node/relationship property name. When equal, the mapping is the identity — useful default for the auto-mapping path.
CsvDecoder
CsvEncoder
JsonArrayDecoder
Decoder that parses the entire array up-front, then yields one element per next_row call. Not streaming — use super::JsonlDecoder for that.
JsonArrayEncoder
JsonlDecoder
JsonlEncoder
RowParseError
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::Error via row_parse_io_error so it travels through the standard feed / finish return type; recoverable via downcast_row_parse_error.
StreamingCsvDecoder
Push-based CSV decoder. Layers a streaming feed loop on top of the same process_buf byte-level state machine used by the pull-based CsvDecoder. The cell/record state lives on the struct so it persists across feed calls — partial records stay parked until enough bytes arrive to complete them.
StreamingJsonArrayDecoder
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.
StreamingJsonlDecoder
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 for Self::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_sample length 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::BufRead and 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.
StreamingRowDecoder
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 via Self::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 RowParseError from an io::Error previously produced via row_parse_io_error. Returns None for any other error.
invalid_data
Wrap an std::io::Error with 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 become LoraValue::Map; untagged arrays become LoraValue::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 LoraValue into a serde_json::Value using the canonical tagged shape. The result is lossless — feeding it back through lora_value_from_json reconstructs the original value.
parameterized_create_for_node
Build the Cypher template for a node mapping. The result expects a $rows parameter 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 RowParseError in std::io::Error so it flows through the existing Result<_, std::io::Error> channels. Recover the structured form with downcast_row_parse_error.
write_all_rows
Convenience: drive any RowEncoder through 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.