https://github.com/altanis/tokio-bichannel
A wrapper around `tokio::sync::mpsc` channels to provide an easy bidirectional stream API.
https://github.com/altanis/tokio-bichannel
Last synced: 3 months ago
JSON representation
A wrapper around `tokio::sync::mpsc` channels to provide an easy bidirectional stream API.
- Host: GitHub
- URL: https://github.com/altanis/tokio-bichannel
- Owner: Altanis
- License: mit
- Created: 2024-07-28T03:01:21.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-07-28T16:24:29.000Z (11 months ago)
- Last Synced: 2025-02-28T08:42:34.606Z (4 months ago)
- Language: Rust
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```rs
#[tokio::test]
async fn main() {
let (mut chan1, mut chan2) = channel::(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");
}
```