appsignal
mongo-rust-driver
Rust

Mongo Rust driver built on top of the Mongo C driver

Last updated Apr 7, 2026
89
Stars
22
Forks
6
Issues
0
Stars/day
Attention Score
30
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Mongo Rust Driver

Mongo Rust driver built on top of the Mongo C driver. This driver is a thin wrapper around the production-ready C driver that provides a safe and ergonomic Rust interface which handles all the gnarly usage details of the C driver for you.

Bson encoding and decoding is handled by the bson crate, the bindings are based on generated bindings by bindgen.

The API should still be considered experimental, but I'm not expecting changes at the moment.

Documentation

Compatibility

The driver currently only builds on Unix, tested on Mac Os X and Linux so far. It's compatible with MongoDB 2.6 up to 3.4 and has full replica set and SSL support.

Installation

If you have any trouble installing the crate (linking openssl can be tricky) please check out the installation instructions for the C driver.

To build on Mac install OpenSSL 1.1 and cmake:

brew install openssl@1.1
brew install cmake

Export these env vars the before you make a clean build:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_C

Logging

All internal logging by mongoc is redirected to the macros in the log crate. See the log docs to configure output in your application.

SSL test

There is a test included to connect to a replica set over SSL. To skip this test:

SKIPSSLCONNECTION_TESTS=true cargo test

To run this tests fill these environment variables with something appropiate to connect to a replica set:

MONGORUSTDRIVERSSLURI
MONGORUSTDRIVERSSLPEM_FILE
MONGORUSTDRIVERSSLCA_FILE

Examples

See the tests directory for examples of how to use the driver.

License

Licensed under either of

* Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) * MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Contributions are very welcome, only the functionality we use has been wrapped so far. Please write a test for any behavior you add.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท appsignal/mongo-rust-driver ยท Updated daily from GitHub