#mongodb #database

mongo_driver

Mongo Rust driver built on top of the Mongo C driver

19 releases (11 breaking)

0.12.1 May 16, 2018
0.12.0 Jan 16, 2018
0.11.0 Nov 3, 2017
0.8.0 Jul 5, 2017
0.1.0 Dec 19, 2015

#129 in Database interfaces

Download history 48/week @ 2019-07-27 78/week @ 2019-08-03 51/week @ 2019-08-10 25/week @ 2019-08-17 313/week @ 2019-08-24 101/week @ 2019-08-31 150/week @ 2019-09-07 154/week @ 2019-09-14 224/week @ 2019-09-21 113/week @ 2019-09-28 36/week @ 2019-10-05 46/week @ 2019-10-12 523/week @ 2019-10-19 655/week @ 2019-10-26 597/week @ 2019-11-02

285 downloads per month
Used in 2 crates

MIT/Apache

120KB
2.5K SLoC

Mongo Rust Driver

Build Status Crate

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:

brew install openssl@1.1

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"

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:

SKIP_SSL_CONNECTION_TESTS=true cargo test

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

MONGO_RUST_DRIVER_SSL_URI
MONGO_RUST_DRIVER_SSL_PEM_FILE
MONGO_RUST_DRIVER_SSL_CA_FILE

Examples

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

License

Licensed under either of

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.

Dependencies

~6MB
~103K SLoC