dropbear 0.1.0

Awaitable drop container based on Tokio oneshots
Documentation
  • Coverage
  • 42.86%
    3 out of 7 items documented0 out of 5 items with examples
  • Size
  • Source code size: 27.23 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Dessix/dropbear-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Dessix

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;