Skip to content

Commit 1afb1b2

Browse files
authored
DOCSP-39854: Remove async-std runtime support (#119)
1 parent 48731de commit 1afb1b2

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

source/fundamentals/runtimes.txt

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,54 @@ Overview
1414
--------
1515

1616
In this guide, you can learn about the {+driver-short+}'s :ref:`asynchronous <rust-runtimes-configure-async>`
17-
and :ref:`synchronous <rust-runtimes-configure-sync>` APIs.
18-
This guide explains how to enable the available APIs and structure your code to use each.
17+
and :ref:`synchronous <rust-runtimes-configure-sync>` APIs. This guide explains how to enable the available APIs
18+
and structure your code to use each.
1919

20-
The {+driver-short+} supports ``tokio`` and ``async-std``, two popular asynchronous runtime crates.
21-
By default, the driver uses the ``tokio`` asynchronous runtime, but you can select a specific runtime
22-
by adding feature flags to the ``mongodb`` dependency in your ``Cargo.toml`` file.
20+
The {+driver-short+} supports the ``tokio`` asynchronous runtime crate, which is the default
21+
runtime.
2322

24-
The driver also includes a synchronous API for use cases that require blocking, or when parallelism is not necessary.
25-
You can select the synchronous API by adding feature flags to the ``mongodb`` dependency in your ``Cargo.toml`` file.
23+
.. important::
2624

27-
.. _rust-runtimes-configure-async:
25+
Beginning in {+driver-short+} v3.0, the ``tokio`` runtime is the only asynchronous runtime crate that
26+
the driver supports. Previous versions of the driver also support the ``async-std`` runtime crate.
27+
If your application uses the ``async-std`` runtime, you can start a ``tokio`` runtime in the same
28+
application by creating a ``Runtime`` struct instance and wrapping driver operations with the ``Runtime::spawn()``
29+
method. Ensure that you use the same ``Runtime`` instance for instantiating a ``Client`` and calling
30+
driver methods on that ``Client`` instance.
31+
32+
For an example that instantiates a ``Runtime`` and calls the ``spawn()`` method, see the `tokio documentation
33+
<https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html#examples-2>`__.
2834

29-
Configure the Asynchronous Runtime
30-
----------------------------------
35+
The driver also includes a synchronous API for use cases that require blocking, or when parallelism
36+
is not necessary. You can select the synchronous API by adding feature flags to the ``mongodb`` dependency
37+
in your ``Cargo.toml`` file.
3138

32-
The driver uses the ``tokio`` runtime by default.
33-
You can explicitly choose a runtime by adding the ``"tokio-runtime"`` or ``"async-std-runtime"``
34-
feature flags to the ``mongodb`` dependency.
39+
This guide includes the following sections:
3540

36-
Select from the following tabs to see how to add feature flags for each corresponding crate:
41+
- :ref:`rust-runtimes-configure-async` shows how to configure your application to use the
42+
``tokio`` asynchronous runtime
3743

38-
.. tabs::
44+
- :ref:`rust-runtimes-configure-sync` shows how to configure your application to use the
45+
``sync`` and ``tokio-sync`` synchronous runtimes
3946

40-
.. tab:: tokio
41-
:tabid: asynchronous-api-tokio
47+
- :ref:`rust-runtimes-configure-both` shows how to enable both the asynchronous and synchronous
48+
runtimes APIs in your application
4249

43-
.. code-block:: toml
44-
45-
[dependencies.mongodb]
46-
version = "{+version+}"
47-
features = ["tokio-runtime"]
50+
- :ref:`rust-addtl-info-runtimes` provides links to resources and API documentation for types
51+
and methods mentioned in this guide
4852

49-
.. tab:: async-std
50-
:tabid: asynchronous-api-async-std
53+
.. _rust-runtimes-configure-async:
5154

52-
.. code-block:: toml
55+
Configure the Asynchronous Runtime
56+
----------------------------------
5357

54-
[dependencies.mongodb]
55-
version = "{+version+}"
56-
default-features = false
57-
features = ["async-std"]
58+
The driver uses the ``tokio`` runtime by default, so you can use this runtime without specifying any
59+
feature flags in your project's ``Cargo.toml`` file.
5860

59-
For more information on installing the driver and adding feature flags,
60-
see the :ref:`rust-quick-start-download-and-install` step of the Quick Start.
61+
You can explicitly choose the ``tokio`` runtime by adding the ``"tokio-runtime"`` feature flag to
62+
the ``mongodb`` dependency. For more information on installing the driver and adding feature flags,
63+
including an example that specifies the ``"tokio-runtime"`` feature flag, see the
64+
:ref:`rust-quick-start-download-and-install` step of the Quick Start.
6165

6266
Tokio Runtime Example
6367
~~~~~~~~~~~~~~~~~~~~~
@@ -113,6 +117,8 @@ When the ``insert_one`` method runs inside the ``for`` loop, the driver waits fo
113117
:language: rust
114118
:dedent:
115119

120+
.. _rust-runtimes-configure-both:
121+
116122
Use Both Asynchronous and Synchronous APIs
117123
------------------------------------------
118124

@@ -130,6 +136,8 @@ For example, to enable both ``tokio`` runtimes, you can add the ``tokio`` depend
130136
version = "{+version+}"
131137
features = ["tokio-sync"]
132138

139+
.. _rust-addtl-info-runtimes:
140+
133141
Additional Information
134142
----------------------
135143

0 commit comments

Comments
 (0)