Crates.io | async-oneshot-channel |
lib.rs | async-oneshot-channel |
version | 0.1.3 |
source | src |
created_at | 2024-11-21 01:06:10.220593 |
updated_at | 2024-12-12 03:32:26.369665 |
description | A simple async oneshot channel implementation |
homepage | |
repository | https://github.com/AmitPr/async-oneshot-channel |
max_upload_size | |
id | 1455517 |
size | 18,992 |
A simple (<150 LoC, dependency-free) "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));
MaybeUninit
safety.Send
and Sync
where appropriateNone
if all senders dropLicensed under the MIT license.