Crate nervusdb_v2

Crate nervusdb_v2 

Source
Expand description

§NervusDB v2 (Rust-First Edition)

The “SQLite” of Graph Databases for Rust.

NervusDB is an embedded graph database designed for local-first applications. It provides a unified, zero-config experience for managing persistent graph data with strong consistency and safety guarantees.

§🚀 Quickstart

Add nervusdb to your Cargo.toml. Then, you can start building your graph:

use nervusdb_v2::{Db, Result};

fn main() -> Result<()> {
    // 1. Open the database (creates .ndb and .wal files)
    let db = Db::open("my_graph.ndb")?;

    // 2. Write Data
    let mut txn = db.begin_write();
    // (APIs for node creation in progress, see examples/tour.rs)
    txn.commit()?;

    // 3. Query Data (Cypher)
    let snapshot = db.snapshot();
    // snapshot.query("MATCH (n) RETURN n", ...);

    Ok(())
}

§💡 Core Concepts

  • Db: The entry point. Handles file management, locking, and engine initialization. Safe to share across threads (it uses internal locking).
  • WriteTxn: Exclusive access for modifying the graph. ACID compliant.
  • ReadTxn / Snapshot: Consistent view of the graph for querying. Non-blocking.
  • query: The Cypher execution engine (re-exported from nervusdb-v2-query).

§📦 Feature Flags

FlagDescriptionDefault
async(Planned) Enable async Db and Txn wrappersfalse
serde(Implicit) Serde support for property valuestrue

Re-exports§

pub use nervusdb_v2_query as query;

Structs§

Db
The main database handle for NervusDB v2.
DbSnapshot
A wrapper around the storage snapshot to hide internal types.
EdgeKey
A directed edge from a source node to a destination node with a relationship type.
ReadTxn
A read-only transaction.
WriteTxn
A write transaction.

Enums§

Error
The error type for NervusDB operations.
PropertyValue
Property value types for nodes and edges.

Traits§

GraphSnapshot
A read-only snapshot of the graph state.

Type Aliases§

ExternalId
External identifier for a node, assigned by the user.
InternalNodeId
Internal node identifier used for storage and lookups.
LabelId
Label identifier for node classification.
RelTypeId
Relationship type identifier.
Result
A specialized Result type for NervusDB operations.