[][src]Crate autocleanup

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.

Structs

AutoCleanup

Enums

Item

Representation of a cleanup node.