dropbear

Crates.iodropbear
lib.rsdropbear
version0.1.0
sourcesrc
created_at2021-01-21 01:05:21.065752
updated_at2021-01-21 01:05:21.065752
descriptionAwaitable drop container based on Tokio oneshots
homepage
repositoryhttps://github.com/Dessix/dropbear-rs
max_upload_size
id344696
size17,946
Zoey (Dessix)

documentation

README

Without AsyncDrop, awaiting at item being dropped is non-trivial.

This wrapper allows awaiting it, and can therein be used to perform async clean-up on the contents of an Arc or similar, when it is no longer in use.

use dropbear::DropBear;
let (bearer, notify) = DropBear::new(x.clone());
drop(bearer);
assert_eq!(notify.await.unwrap(), x); // => true
use dropbear::DropBear;
let (bearer, notify) = DropBear::new(item);
let arc = Arc::new(bearer);
// Pass the arc elsewhere, handing ownership over
// Or clone it elsewhere, do some work here, then drop your copy
{
    // ...
}
// Receive the original item once the last Arc instance is dropped
let original_item = notify.await.unwrap();
// ... and perform async cleanup on the contents
perform_cleanup(original_item).await;
Commit count: 1

cargo fmt