Skip to content

A wrapper around `tokio::sync::mpsc` channels to provide an easy bidirectional stream API.

License

Notifications You must be signed in to change notification settings

Altanis/tokio-bichannel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tokio-bichannel

A wrapper around tokio::sync::mpsc channels to provide an easy bidirectional stream API.

How do I install this crate?

Add this to your Cargo.toml file:

tokio-bichannel = "1"

Examples

#[tokio::test]
async fn main() {
    let (mut chan1, mut chan2) = channel::<String, String>(10);

    chan1.send("Hello from chan1".to_string()).await.unwrap();
    chan2.send("Hello from chan2".to_string()).await.unwrap();

    let msg1 = chan2.recv().await.unwrap();
    let msg2 = chan1.recv().await.unwrap();

    assert_eq!(msg1, "Hello from chan1");
    assert_eq!(msg2, "Hello from chan2");
}

About

A wrapper around `tokio::sync::mpsc` channels to provide an easy bidirectional stream API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages