@@ -37,13 +37,19 @@ Download and Install
3737
3838 .. step:: Install the Rust Driver
3939
40- Add the following crates to your project by including them in the
40+ Add the following crates to your project by including them in the
4141 dependencies list located in your project's ``Cargo.toml`` file:
4242
4343 - ``mongodb``, the {+driver-short+} crate
44- - ``bson``, the MongoDB data representation crate
45- - ``serde_json``, A JSON data representation crate
46-
44+ - ``serde_json``, a JSON data representation crate
45+ - ``futures``, an asynchronous runtime crate that provides core abstractions
46+
47+ .. tip::
48+
49+ The ``mongodb`` crate resolves the ``bson`` crate, which is the primary
50+ MongoDB data representation crate. You do not need to add the ``bson``
51+ crate to your dependencies list.
52+
4753 The following code shows an example dependencies list that
4854 includes the preceding crates:
4955
@@ -55,27 +61,60 @@ Download and Install
5561 .. code-block:: bash
5662
5763 [dependencies]
58- bson = "2.7.0"
5964 serde_json = "1.0.107"
65+ futures = "0.3.28"
66+ tokio = {version = "1.32.0", features = ["full"]}
6067
6168 [dependencies.mongodb]
6269 version = "{+version+}"
63- default-features = false
64- features = ["async-std-runtime"]
70+ features = ["tokio-runtime"]
6571
6672 .. tab:: Synchronous API
6773 :tabid: synchronous-api
6874
6975 .. code-block:: bash
7076
7177 [dependencies]
72- bson = "2.7.0"
7378 serde_json = "1.0.107"
7479
7580 [dependencies.mongodb]
7681 version = "{+version+}"
7782 features = ["tokio-sync"]
7883
84+ .. tip::
85+
86+ The ``tokio`` asynchronous runtime is the driver's default runtime crate
87+ and does not require a feature flag. The preceding code example includes
88+ the ``"tokio-runtime"`` feature flag to specify the ``tokio`` runtime, but
89+ this flag is optional.
90+
91+ If you want to use a different synchronous or asynchronous runtime crate,
92+ replace the feature flag with your runtime crate's corresponding flag.
93+ The driver supports the following alternative feature flags, which use the
94+ `async-std <https://crates.io/crates/async-std>`__ crate runtime:
95+
96+ - The ``"async-std-runtime"`` feature flag
97+ - The ``"sync"`` feature flag
98+
99+ For more information about these feature flags, see the `API documentation
100+ <{+api+}/#all-feature-flags>`__.
101+
102+ If you want to use both the asynchronous and synchronous runtimes, specify
103+ the ``tokio`` runtime dependency and include the ``"tokio-sync"`` flag in
104+ ``dependencies.mongodb``. The following code shows an example dependencies
105+ list that supports sync and async code:
106+
107+ .. code-block:: bash
108+
109+ [dependencies]
110+ serde_json = "1.0.107"
111+ futures = "0.3.28"
112+ tokio = {version = "1.32.0", features = ["full"]}
113+
114+ [dependencies.mongodb]
115+ version = "2.6.1"
116+ features = ["tokio-sync"]
117+
79118After you complete these steps, you should have Rust and Cargo installed
80119and a new Rust project with the necessary driver dependencies.
81120
0 commit comments