Crates.io | self-replace |
lib.rs | self-replace |
version | 1.3.7 |
source | src |
created_at | 2023-05-14 14:12:27.182946 |
updated_at | 2023-09-19 21:20:43.361477 |
description | Utility crate that allows executables to replace or uninstall themselves |
homepage | https://github.com/mitsuhiko/self-replace |
repository | https://github.com/mitsuhiko/self-replace |
max_upload_size | |
id | 864280 |
size | 53,826 |
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.
For details about the implementation refer to the documentation.
To uninstall a binary, use self_delete
.
self_replace::self_delete()?;
To replace a binary for updating, use self_replace
.
let new_binary = "/path/to/new/binary";
self_replace::self_replace(&new_binary)?;
std::fs::remove_file(&new_binary)?;