MongoDB Rust Driver
On this page
Introduction
Welcome to the documentation site for the official MongoDB Rust driver. You can add the driver to your application to work with MongoDB in Rust. Download it from crates.io or set up a runnable project with examples from our Usage Guide.
Installation
See Installation
Connect to MongoDB Atlas
Select from the Sync or Async tabs below for corresponding connection code samples.
To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:
Note
For information about connecting to Atlas Serverless, see the Serverless Instance Limitations page for the minimum driver version you need.
Connect to a MongoDB Server on Your Local Machine
If you need to run a MongoDB server on your local machine for development purposes instead of using an Atlas cluster, you need to complete the following:
Download the Community or Enterprise version of MongoDB Server.
Install and configure MongoDB Server.
Start the server.
Important
Always secure your MongoDB server from malicious attacks. See our Security Checklist for a list of security recommendations.
After you successfully start your MongoDB server, specify your connection string in your driver connection code.
If your MongoDB Server is running locally, you can use the connection string
"mongodb://localhost:<port>"
where <port>
is the port number you
configured your server to listen for incoming connections.
If you need to specify a different hostname or IP address, see our Server Manual entry on Connection Strings.
To test whether you can connect to your server, replace the connection string in the Connect to MongoDB Atlas code example and run it.
Compatibility
MongoDB Compatibility
Compatibility Table Legend
Icon | Explanation |
---|---|
✓ | All features are supported. |
⊛ | The Driver version will work with the MongoDB version, but not all
new MongoDB features are supported. |
No mark | The Driver version is not tested with the MongoDB version. |
The Rust driver is not compatible with MongoDB server versions older than 3.6.
[1] | (1, 2) The Rust driver does not support Decimal128, Client-Side Field Level Encryption, GridFS, and OCSP. |
[2] | The Rust driver does not support Decimal128, Client-Side Field Level Encryption, GridFS, OCSP, and change streams. |
[3] | Not all features in MongoDB are available in these driver versions. Unsupported features include Decimal128, Client-Side Field Level Encryption, GridFS, OCSP, change streams, Causal Consistency, and Serverless Instances. |
Language Compatibility
The MongoDB Rust driver requires Rust 1.51 or later.
For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.
How to get help
Ask questions on our MongoDB Community Forums.
Visit our Support Channels.
See our RUST JIRA project to raise issues or request features.