autocleanup 0.8.0

RAII wrapper for non-RAII objects.
Documentation
  • Coverage
  • 55.56%
    5 out of 9 items documented1 out of 7 items with examples
  • Size
  • Source code size: 3.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.4 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • openqrnch/autocleanup
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • qrnch-jan

Simple library for cleaning up non-RIAA resources using RIAA.

A function that needs to clean up resources automatically can create an AutoCleanup object that will clean up those resources automatically.

use std::path::Path;
use autocleanup::AutoCleanup;

fn do_something() -> Result<(), std::io::Error> {
  let mut ac = AutoCleanup::new();
  ac.push_file("/tmp/foo.sock");

  // .. do things ..

  Ok(())
  // /tmp/foo.sock will automatically be removed as the function
  // returns.
}

Be mindful of the Drop trait caveats; for instance calling std::process::exit() will cause Drop traits not to run.

Because the cleanup occurs at Drop there's no error handling for failed cleanups -- errors will be silently ignored.