Crates.io | mias_channel |
lib.rs | mias_channel |
version | 0.1.0 |
source | src |
created_at | 2024-07-08 02:14:54.42521 |
updated_at | 2024-07-08 02:14:54.42521 |
description | A library that supports bi-directional channels by wrapping others |
homepage | https://github.com/Levbeta/mias_channel |
repository | https://github.com/Levbeta/mias_channel |
max_upload_size | |
id | 1295287 |
size | 16,151 |
MiasChannel
is a library for creating channels that can be used to send and receive messages between tasks.
Allowing for easy bi-directional communication between tasks. (Normal channel) And allowing for oneshot responses to be sent back to the sender. (Responder channel)
MiasChannel
at the moment only supports tokio. By wrapping the tokio channels in a more user friendly API for bi-directional communication.
It has a goal of supporting more channels in the future easily by using features to enable different channel implementations.
The responder channel is a channel that allows for a request to be sent to a receiver and for a response to be sent back to the sender. This is useful for when you want to send a request to a task and get a response back. The responder channel is implemented using a normal channel and oneshot channels.
Is built on top of the normal channel and oneshot channels. In the future i want to replace the oneshot channels with a more efficient implementation.
use mias_channel::responder_channel;
#[tokio::main]
async fn main() {
let (tx, mut rx) = responder_channel::<i64, f64>(10);
tokio::task::spawn(async move {
while let Some((req, tx)) = rx.recv().await {
tx.send(req as f64).unwrap();
}
});
let res = tx.send(10).await;
}