Expand description

Mortem is a library for that strives to achieve one thing; ensuring the executable is deleted after execution stops and be out of the way while doing so.

Mortem requires only one line to function and works completely transparently in the background. It does this by providing a Guard type. When a Guard is created, it does nothing. When it gets dropped, however, it begins the process of deleting the host executable. It does this with the best of it’s ability, either trying once and exiting successfully upon failure (provided by Guard::soft()) or trying continually and blocking till it succeeds (provided by Guard::hard()).

This means, for Mortem to do it’s work, all that it needs is to be dropped at the end of the main function.

Usage

Simply register a guard (either soft or hard) in the main function, and have it be dropped to delete the binary.

fn main() {
    let _mortem = mortem::hard(); // register mortem guard

    // some code
    println!("Hello!")

    // _mortem drops and executable is deleted
}

Async

Using Mortem in an async runtime is functionally the same and no user action is required beyond the usual.

Tokio
#[tokio::main]
async fn main() {
    let _mortem = mortem::hard(); // register mortem guard

    // some code
    tokio::spawn(async {
        println!("Hello!")
    }).await;

    // _mortem drops and executable is deleted
}
async-std
#[async_std::main]
async fn main() {
    let _mortem = mortem::hard(); // register mortem guard

    // some code
    async_std::task::spawn(async {
        println!("Hello!")
    }).await;

    // _mortem drops and executable is deleted
}

Structs

Executable guard.

Functions

Create a guard that when dropped blocks till the host executable is successfully deleted.

Create a guard that when dropped tries to delete the host executable.