BoltR
A standalone, pure Rust implementation of the Bolt v5.x wire protocol - the binary protocol used by Neo4j and other graph databases for client-server communication.
Any Bolt-compatible database engine can plug in via the BoltBackend trait. BoltR handles TCP transport, PackStream encoding, session management, transactions, and the full Bolt type system over the wire.
Features
- Spec-faithful: Full Bolt v5.x protocol (5.1-5.4), all PackStream types, all message types
- Pure Rust: No C/C++ dependencies
- Lightweight: Minimal deps: tokio, bytes, thiserror, tracing
- Fast: Efficient PackStream encoding, chunked streaming
- Embeddable: Library-first design, usable by any Rust project
- TLS: Optional TLS via
tlsfeature flag (tokio-rustls) - Auth: Pluggable authentication via
AuthValidatortrait - Observability: Structured tracing via
tracingcrate - Graceful shutdown: Drain connections on signal
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
Implementing a Backend
Implement the BoltBackend trait to connect your database:
use ;
use BoltError;
Starting the Server
use BoltServer;
use Duration;
async
Using the Client
Enable the client feature:
[]
= { = "0.1", = ["client"] }
use BoltConnection;
use HashMap;
async
Architecture
Application (Cypher statements, parameters, results)
|
v
Bolt Messages
- Client: HELLO, LOGON, RUN, PULL, BEGIN, COMMIT, ROLLBACK, GOODBYE
- Server: SUCCESS, RECORD, FAILURE, IGNORED
|
v
PackStream Encoding
- Full Bolt type system: scalars, graph elements, temporal, spatial
|
v
Chunk Framing (2-byte length-prefixed)
|
v
BoltBackend trait (your database plugs in here)
Bolt Type Support
| Bolt Type | Wire Encoding |
|---|---|
NULL, BOOLEAN, INTEGER, FLOAT, STRING, BYTES |
PackStream native markers |
DATE, TIME, DATETIME, DURATION |
PackStream structures |
POINT2D, POINT3D |
PackStream structures with SRID |
LIST, DICT |
Recursive PackStream containers |
NODE |
ID + labels + properties + element_id |
RELATIONSHIP |
ID + type + start/end + properties + element_id |
PATH |
Alternating nodes and relationships |
Modules
| Module | Description |
|---|---|
packstream |
Binary encoding format (markers, encode, decode) |
types |
BoltValue enum and graph/temporal/spatial types |
chunk |
TCP message framing (length-prefixed chunks) |
message |
Client and server message types, encode/decode |
server |
BoltBackend trait, session/transaction management, TCP server |
client |
BoltConnection, BoltSession (feature-gated) |
error |
BoltError enum with Neo4j-compatible codes |
Requirements
- Rust 1.85.0+ (edition 2024)
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.