A safe, type-safe Rust wrapper for WiredTiger, the high-performance embedded database engine used as MongoDB's storage engine.
| Crate | Description |
|---|---|
wtrs |
Safe, ergonomic Rust API over WiredTiger |
wt-sys |
Low-level FFI bindings; compiles WiredTiger C from source |
ext_crypto |
Example WiredTiger extension (cdylib) |
WiredTiger itself is a git submodule at wt-sys/src/wiredtiger and is compiled from source at build time.
- Rust toolchain (stable)
- A C compiler (clang or gcc)
- Git submodules initialized
git submodule update --init --recursivecargo build
cargo build --releasecargo testcargo run --example ex_helloOpens a WiredTiger database, creates a session, and closes cleanly. Rust port of wiredtiger/examples/c/ex_hello.c.
cargo run --example ex_cursorCreates a string-keyed table, inserts/updates/deletes records, and scans results forward. Rust port of wiredtiger/examples/c/ex_cursor.c.
WiredTiger's resource model maps to Rust lifetimes:
Connection (Send + Sync)
└── Session<'conn> (Send)
└── Cursor<'session> (Send)
Connection— opened viaConnection::open(path, config); auto-closes on drop.Session— created viaconn.open_session(config); manages transactions.Cursor— created viasession.open_cursor(uri, config); used for all data access and mutation.
WiredTiger extensions are cdylib crates that export wiredtiger_extension_init(). The ext_crypto crate demonstrates this pattern.
cargo build -p ext_crypto