async_compatibility_layer/
channel.rs

1//! Abstraction over channels. This will expose the following types:
2//!
3//! - [`unbounded`] returning an [`UnboundedSender`] and [`UnboundedReceiver`]
4//! - [`bounded`] returning an [`BoundedSender`] and [`BoundedReceiver`]
5//! - [`oneshot`] returning an [`OneShotSender`] and [`OneShotReceiver`]
6//! - several error types
7//!
8//! Which channel is selected depends on these feature flags:
9//! - `channel-tokio` enables [tokio](https://docs.rs/tokio)
10//! - `channel-async-std` enables [async-std](https://docs.rs/async-std)
11//! - `channel-flume` enables [flume](https://docs.rs/flume)
12//!
13//! Note that exactly 1 of these features must be enabled. If 0 or 2+ are selected, you'll get compiler errors.
14//!
15//! Some of these implementations may not exist under the crate selected, in those cases they will be shimmed to another channel. e.g. `oneshot` might be implemented as `bounded(1)`.
16
17/// Bounded channels
18mod bounded;
19/// Oneshot channels
20mod oneshot;
21/// Unbounded channels
22mod unbounded;
23
24#[cfg(all(not(async_executor_impl = "tokio"), async_channel_impl = "tokio"))]
25compile_error!(
26    "async_channel_impl = 'tokio' requires tokio runtime, e. g. async_executor_impl = 'tokio'"
27);
28
29pub use bounded::{
30    bounded, BoundedStream, Receiver, RecvError, SendError, Sender, TryRecvError, TrySendError,
31};
32pub use oneshot::{oneshot, OneShotReceiver, OneShotRecvError, OneShotSender, OneShotTryRecvError};
33pub use unbounded::{
34    unbounded, UnboundedReceiver, UnboundedRecvError, UnboundedSendError, UnboundedSender,
35    UnboundedStream, UnboundedTryRecvError,
36};