On this page
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.
You can use the connection snippets in the following tabs to test your connection to your MongoDB deployment on Atlas. Select from the Sync or Async tabs below for corresponding connection code samples.
This connection snippet uses the Stable API feature, which you can enable when using the Rust driver v2.0 and later to connect to MongoDB Server v5.0 and later. When you use this feature, you can update your driver or server without worrying about backward compatibility issues with any commands covered by the Stable API.
To learn more about the Stable API feature, see Stable API in the Server manual.
Starting from Feburary 2022, the Versioned API is known as the Stable API. All concepts and features remain the same with this naming change.
If you are using a version of MongoDB or the driver that doesn't support the Stable API feature, you can use the connection snippets in the following tabs to test your connection to your MongoDB deployment on Atlas. Select from the Sync or Async tabs below for corresponding connection code samples.
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:
Install and configure MongoDB Server.
Start the server.
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
<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.
MongoDB ensures compatibility between the MongoDB Server and the drivers for three years after the server version's end of life (EOL) date. To learn more about the MongoDB release and EOL dates, see MongoDB Software Lifecycle Schedules.
All features are supported.
The Driver version will work with the MongoDB version, but not all new MongoDB features are supported.
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, 2) This Rust driver version does not support OCSP.|
|||This Rust driver version does not support Decimal128 or OCSP.|
|||(1, 2) This Rust driver version does not support Decimal128, Client-Side Field Level Encryption, GridFS, or OCSP.|
|||This Rust driver version does not support Decimal128, Client-Side Field Level Encryption, GridFS, OCSP, or change streams.|
|||This Rust driver version does not support Decimal128, Client-Side Field Level Encryption, GridFS, OCSP, change streams, Causal Consistency, or Serverless Instances.|
The MongoDB Rust driver requires Rust 1.57 or later.
For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.