Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
neug-rust
A Safe Rust wrapper for the alibaba/neug C++ graph database engine.
High-performance embedded graph database for analytics and real-time transactions.
graphscope.io/neug
Overview
This project provides high-level, idiomatic Rust bindings to the neug C++ library. It is designed as a Cargo workspace with two main crates:
neug-sys: Contains the low-level, unsafe FFI bindings generated bybindgenand the build script that compiles the underlying C++ library using CMake.neug-rust(in theneug-bindingsdirectory): Provides a safe, user-friendly Rust API (Database,Connection, etc.) that wraps the raw C++ pointers and handles memory management automatically.
Note: The architecture and intelligent CMake build mechanism of this repository were heavily inspired by the excellent zvec-rust-binding project. Like
zvec, our build script will automatically download the required C++ source code duringcargo buildif it is not present locally, bypassing the crates.io size limits.
Prerequisites
Building neug from source requires several C++ dependencies installed on your system, as defined by its CMake configuration. Please ensure you have the following installed (e.g., via brew on macOS or apt on Linux):
- CMake (>= 3.16)
- C++20 compatible compiler (Clang/GCC)
- OpenSSL
- gflags, glog
Note: Heavy dependencies like Apache Arrow, Protobuf, and Abseil are automatically downloaded and built by the internal CMake script.
Getting Started
Local Development
-
Clone the repository with submodules:
(If already cloned, run
git submodule update --init --recursive) -
Build the workspace:
Note: The first build will take a significant amount of time (often >5 minutes) as it compiles the entire C++ codebase and its dependencies.
-
Run Tests:
-
Run Examples:
Speeding up C++ Compilation
To prevent the underlying C++ library (neug-cpp) from compiling from scratch on subsequent builds or across workspaces, it is highly recommended to install a compiler cache tool. Our build script automatically detects and utilizes them:
- Install
sccache(viacargo install sccacheor brew/apt) - Or install
ccache(via brew/apt)
Performance & Benchmarks
The library is continuously benchmarked using criterion to measure the overhead introduced by the Rust FFI boundary and data preparation. Because the wrappers are extremely thin, the actual dispatch overhead is practically non-existent.
Running the realistic workloads (cargo bench) on an Apple Silicon (M-series) chip yields the following Rust Wrapper Overhead:
- Connection Lifecycle:
~1.85 µs- The time required to initialize and teardown a safe Rust connection proxy pointing to the C++ engine. - Query Dispatch (Parse & Execute):
~98.2 µs- The total time it takes to allocate strings in Rust, pass them across the FFI boundary, and have the C++ engine parse and execute a simple CypherMATCHquery.
(Note: These benchmarks measure the overhead of the Rust bindings, not the underlying neug C++ engine's execution time, as that varies by workload).
Usage Example
use ;
use tempdir;
Contributing
- Add high-level, safe Rust abstractions in
neug-bindings/src/. - Ensure you adhere to standard Rust community practices (e.g.,
cargo fmt,cargo clippy). - Add tests to verify your safe wrappers in
neug-bindings/tests/.
License
This wrapper is licensed under the same terms as the neug project (Apache License 2.0).