Skip to main content

Crate marsdb

Crate marsdb 

Source
Expand description

Embeddable property-graph database with an openCypher query subset: single binary, single file, optional in-memory mode.

let db = marsdb::Database::in_memory().unwrap();
db.execute("CREATE (a:Person {name: 'Alice'})-[:KNOWS]->(b:Person {name: 'Bob'})").unwrap();
let result = db.execute("MATCH (n:Person) RETURN n.name").unwrap();
assert_eq!(result.rows.len(), 2);

Modules§

temporal
Calendar math and ISO-8601 text conversion for PropertyValue::Date/ PropertyValue::Duration – kept out of marsdb-graph deliberately (that crate stores the value, it doesn’t know Cypher’s construction/ formatting rules – see PropertyValue’s own doc comment) and out of executor.rs (which owns dispatching to these, not the arithmetic itself, matching the split apply_arith/compare already have from e.g. the planner).

Structs§

CancellationToken
Cooperative cancellation handle for a running query. Clone it before execution and call cancel from another thread.
Database
ExecutionEvent
ExecutionObserver
Dependency-free callback adapter for sending execution events to an application’s logger, metrics collector, or tracing system.
ExecutionOptions
Per-statement safety limits and optional telemetry. Limit fields default to None, preserving unlimited behavior for trusted embedded callers.
IntegrityReport
Successful physical and logical integrity-check summary.
ProcedureSignature
A procedure’s declared shape – everything Executor needs to validate a CALL at the point it’s about to run (arity, coarse argument-type compatibility, output column names for YIELD), before ever asking ProcedureProvider::call to actually produce rows.
Procedures
Arc<dyn ProcedureProvider> wrapper – same “manual Debug, derived Clone” shape executor::ExecutionObserver already uses for its own Arc<dyn Fn(..)>, so ExecutionOptions (which embeds this) can keep deriving both.
QueryResult
QueryStats
Per-statement write counters, following the widely-used summary- counter conventions: properties_set counts removals too (removing a property is setting it away, and SET n.p = null is literally the same operation as REMOVE n.p here), while label changes are tracked as their own pair.
Transaction
Caller-managed atomic unit of work. Any statement error immediately aborts the whole transaction, preventing a later accidental commit of partial statement effects.

Enums§

Error
ExecutionOutcome
Coarse, stable outcome category for telemetry. Error messages and query text are deliberately excluded to avoid leaking user data through an observer by default.
GraphError
Literal
PathElem
One element of a Value::Path — a path is node, edge, node, edge, ..., node, alternating, as a single Vec, not two parallel node/edge vecs (which would create an unenforced nodes.len() == edges.len() + 1 invariant across every place a path gets built or read).
PropertyValue
A node/edge property, as persisted to redb (via postcard, see encode.rs) and used directly as MarsDB’s runtime scalar type – there is no separate “wire” representation. New variants append at the end (postcard’s derive encodes an enum discriminant by declaration order), never reorder/remove an existing one, or every already-stored property silently decodes as the wrong variant.
QueryError
Typed error taxonomy, in three tiers that reflect when the problem was knowable:
Statement
TzId
A DateTime’s zone: a fixed UTC offset, or a named IANA timezone (Europe/Stockholm) whose real offset varies by instant (DST) and is resolved on demand, not stored – see PropertyValue::DateTime’s doc comment.
Value

Traits§

ProcedureProvider
Implemented by whatever embeds MarsDB to make CALL resolve to real behavior. Executor calls signature once per CALL (for compile- time-shaped validation) and call once per input row (standalone: once total, since there’s no input row to iterate).
RowSink
Receiver for Executor::execute_streaming_with_options — rows are pushed one at a time, never materialized as a whole result. columns is called exactly once, before the first row. Returning Break from row stops the scan cleanly (early termination, not an error).

Functions§

parse
The real implementation behind lib.rs’s public parse – the pest-based parser.rs/cypher.pest this replaced are gone (see grammar/README.md).