| Crates.io | async-oneshot-channel |
| lib.rs | async-oneshot-channel |
| version | 0.1.8 |
| created_at | 2024-11-21 01:06:10.220593+00 |
| updated_at | 2024-12-20 21:25:04.507107+00 |
| description | A simple async oneshot channel implementation |
| homepage | |
| repository | https://github.com/AmitPr/async-oneshot-channel |
| max_upload_size | |
| id | 1455517 |
| size | 18,971 |
A simple (<100 LoC) "oneshot" channel for asynchronously sending a single value between tasks, in a thread-safe and async-runtime-agnostic manner. This implementation supports cloned senders while ensuring only one send operation will succeed.
use futures::executor::block_on;
// Create a new channel
let (tx, rx) = oneshot();
// Send a value
tx.send(42).unwrap();
// Receive the value asynchronously
let result = block_on(rx.recv());
assert_eq!(result, Some(42));
Send and Sync where appropriateNone if all senders dropLicensed under the MIT license.