How to Use Async Channels (flume, kanal, tokio

:sync)

Use flume to create bounded async channels for sending messages between Rust tasks without blocking.

Use flume for lightweight async channels in Rust by creating a sender and receiver pair, then sending and receiving messages across async tasks.

use flume::bounded;

#[tokio::main]
async fn main() {
    let (tx, rx) = bounded(10);
    tokio::spawn(async move {
        tx.send("hello").await.unwrap();
    });
    let msg = rx.recv().await.unwrap();
    println!("{msg}");
}