graphqlite/lib.rs
1//! GraphQLite - SQLite extension for graph queries using Cypher
2//!
3//! This crate provides Rust bindings for GraphQLite, allowing you to use
4//! Cypher graph queries in SQLite databases.
5//!
6//! # High-Level Graph API
7//!
8//! The [`Graph`] struct provides an ergonomic interface for common graph operations:
9//!
10//! ```no_run
11//! use graphqlite::Graph;
12//!
13//! let g = Graph::open(":memory:")?;
14//!
15//! // Add nodes
16//! g.upsert_node("alice", [("name", "Alice"), ("age", "30")], "Person")?;
17//! g.upsert_node("bob", [("name", "Bob"), ("age", "25")], "Person")?;
18//!
19//! // Add edge
20//! g.upsert_edge("alice", "bob", [("since", "2020")], "KNOWS")?;
21//!
22//! // Query
23//! println!("{:?}", g.stats()?);
24//! println!("{:?}", g.get_neighbors("alice")?);
25//!
26//! // Graph algorithms
27//! let ranks = g.pagerank(0.85, 20)?;
28//! let communities = g.community_detection(10)?;
29//! # Ok::<(), graphqlite::Error>(())
30//! ```
31//!
32//! # Low-Level Cypher API
33//!
34//! The [`Connection`] struct provides direct Cypher query access:
35//!
36//! ```no_run
37//! use graphqlite::Connection;
38//!
39//! let conn = Connection::open(":memory:")?;
40//!
41//! // Create nodes
42//! conn.cypher("CREATE (n:Person {name: 'Alice', age: 30})")?;
43//!
44//! // Query the graph
45//! let results = conn.cypher("MATCH (n:Person) RETURN n.name, n.age")?;
46//! for row in &results {
47//! println!("{}: {}", row.get::<String>("n.name")?, row.get::<i64>("n.age")?);
48//! }
49//! # Ok::<(), graphqlite::Error>(())
50//! ```
51
52mod algorithms;
53mod connection;
54mod error;
55mod graph;
56mod manager;
57#[cfg(feature = "bundled-extension")]
58mod platform;
59mod query_builder;
60mod result;
61mod utils;
62
63pub use connection::Connection;
64pub use query_builder::CypherQuery;
65pub use error::Error;
66pub use graph::{graph, BulkInsertResult, CacheStatus, Graph, GraphStats};
67pub use manager::{graphs, GraphManager};
68pub use result::{CypherResult, Row, Value};
69pub use utils::{escape_string, format_value, sanitize_rel_type, CYPHER_RESERVED};
70
71// Algorithm result types
72pub use algorithms::{
73 ApspResult, AStarResult, BetweennessCentralityResult, ClosenessCentralityResult,
74 CommunityResult, ComponentResult, DegreeCentralityResult, EigenvectorCentralityResult,
75 KnnResult, NodeSimilarityResult, PageRankResult, ShortestPathResult, TraversalResult,
76 TriangleCountResult,
77};
78
79/// Result type for GraphQLite operations.
80pub type Result<T> = std::result::Result<T, Error>;