self-replace
is a crate that allows binaries to replace themselves with newer
versions or to uninstall themselves. On Unix systems this is a simple feat, but
on Windows a few hacks are needed which is why this crate exists.
This is a useful operation when working with single-executable utilties that want to implement a form of self updating or self uninstallation.
rust
// uninstall
self_replace::self_delete()?;
```rust use std::fs;
let newbinary = "/path/to/new/binary"; selfreplace::selfdelete(&newbinary)?; fs::removefile(&newbinary)?; ```