Skip to main content

drevo_core/
lib.rs

1//! An embeddable property-graph engine: nodes and edges with JSON properties,
2//! held in memory, with optional write-ahead-log durability, ACID
3//! transactions, and secondary indexes that follow the graph through a change
4//! feed.
5//!
6//! This is the engine underneath [drevo](https://github.com/ice1x/drevo), which
7//! adds Cypher, the HTTP and Bolt servers, and the Python bindings on top. Use
8//! `drevo-core` on its own when you want the graph inside your process and
9//! nothing else.
10//!
11//! # Example
12//!
13//! ```
14//! use drevo_core::engine::GraphEngine;
15//! use drevo_core::model::{Direction, NewEdge, NewNode, Properties};
16//! use drevo_core::native::NativeGraph;
17//! use drevo_core::native_fts::NativeFtsIndex;
18//!
19//! fn task(title: &str) -> NewNode {
20//!     NewNode {
21//!         kind: "task".into(),
22//!         title: title.into(),
23//!         body: String::new(),
24//!         body_html: String::new(),
25//!         properties: Properties::default(),
26//!     }
27//! }
28//!
29//! let graph = NativeGraph::new(); // or NativeGraph::open_durable("graph.wal")?
30//! let deploy = graph.create_node(task("Deploy release"))?;
31//! let review = graph.create_node(task("Review release notes"))?;
32//! graph.create_edge(NewEdge {
33//!     from_id: deploy.id,
34//!     to_id: review.id,
35//!     kind: "blocked_by".into(),
36//!     weight: 1.0,
37//!     properties: Properties::default(),
38//! })?;
39//!
40//! let blockers = graph.neighbors(deploy.id, Direction::Outgoing, Some("blocked_by"))?;
41//! assert_eq!(blockers[0].title, "Review release notes");
42//!
43//! // Indexes catch up with the graph by reading its change feed.
44//! let mut fts = NativeFtsIndex::new();
45//! fts.sync(&graph);
46//! assert_eq!(fts.search("deploy", 1)[0].0, deploy.id);
47//! # Ok::<(), drevo_core::error::CoreError>(())
48//! ```
49//!
50//! # Where to start
51//!
52//! - [`native::NativeGraph`] — the engine: create, read, update and delete
53//!   nodes and edges, traverse, take snapshots, run transactions
54//!   ([`begin`](native::NativeGraph::begin)) and two-phase commits.
55//! - [`engine::GraphEngine`] — the trait that operations are written against.
56//! - [`model`] — [`Node`](model::Node), [`Edge`](model::Edge) and their
57//!   create/patch inputs.
58//! - Indexes: [`native_fts`] (BM25 full-text search),
59//!   [`native_label_index`], [`native_property_index`].
60//! - Replication: [`replica`], [`delta`], [`hlc`], [`lww`].
61
62pub mod bm25;
63pub mod csr;
64pub mod delta;
65pub mod dump;
66pub mod engine;
67pub mod error;
68pub mod hlc;
69pub mod labels;
70pub mod lww;
71pub mod model;
72pub mod native;
73pub mod native_fts;
74pub mod native_label_index;
75pub mod native_property_index;
76pub mod replica;
77pub mod tokenizer;
78pub mod value_encoding;