Expand description
§InstallRS
Build self-contained software installers in plain Rust, with an optional native wizard GUI (Win32 / GTK3), component selection, progress, cancellation, and compression.
Write a library crate exporting install and uninstall, then
build it with the installrs CLI
to get a single self-extracting executable.
use anyhow::Result;
use installrs::{source, Installer};
pub fn install(i: &mut Installer) -> Result<()> {
i.process_commandline()?;
i.set_out_dir("/opt/my-app");
i.file(source!("app"), "app").mode(0o755).install()?;
i.dir(source!("assets"), "assets").install()?;
i.uninstaller("uninstall").install()?;
Ok(())
}
pub fn uninstall(i: &mut Installer) -> Result<()> {
i.process_commandline()?;
i.remove("/opt/my-app").install()?;
Ok(())
}Build with installrs --target . --output my-installer. The CLI
generates a self-contained binary that embeds your assets, an
uninstaller, and a SHA-256 payload integrity check.
Optional features:
gui+ a backend (gui-win32orgui-gtk3) — native wizard with welcome / license / components / directory picker / install / finish / error pages, plus custom pages for arbitrary inputs. The same wizard definition runs--headlessfor unattended installs. Seegui::InstallerGui.lzma/gzip/bzip2— compression methods for the embedded payload. Pass--compression <method>to the CLI.
See the project’s getting-started guide and the example/
directory in the repo for a complete working installer.
§API stability
Items shown in these docs follow normal semver. Items hidden via
#[doc(hidden)] — the __private module, Installer::new,
Installer::install_main, the Source inner field — are part
of the contract between this crate and the code generated by the
installrs CLI. Not a public API. They may change in any
release, including patch releases. User code should never call
them; the generated installer crate pins installrs = "=X.Y.Z"
so the CLI and runtime always match.
Modules§
- gui
gui - Optional native wizard GUI and dialog helpers.
Macros§
Structs§
- Cancellation
Token - Shared cancellation flag. Cloning yields another handle to the
same flag — flipping any clone trips every
check_cancelled()call across the wizard, the install thread, and the Ctrl+C handler. - Component
- An optional feature the user can select or deselect at install time.
- DirOp
- Builder for installing an embedded directory tree. Created by
Installer::dir. Chainfilterandon_errorfor fine-grained control. - FileOp
- Builder for installing a single embedded file. Created by
Installer::file; finalize withinstall. Chainstatus/log/weight/overwrite/modebefore installing. - Installer
- The central context passed into your
installanduninstallfunctions. Holds the embedded payload table, parsed CLI options, registered components, the out-dir for relative paths, the progress sink, the cancellation flag, and the optional log file. - MkdirOp
- Builder for creating an empty directory at install time. Created
by
Installer::mkdir. - Remove
Op - Builder for removing a path at install / uninstall time. Created
by
Installer::remove. Files are deleted; directories are removed recursively. - Source
- Compile-time reference to an embedded file or directory.
- Stderr
Progress Sink - Default text-based progress sink used by non-GUI installs. Writes status and log lines to stderr; renders an in-place progress bar when stderr is a TTY, otherwise emits no progress lines.
- Uninstaller
Op - Builder for writing the embedded uninstaller binary to disk.
Created by
Installer::uninstaller.
Enums§
- Error
Action - Decision returned from an on-error handler inside a directory install.
- Option
Kind - Declared shape of a user-defined command-line option. Register via
crate::Installer::add_option; read parsed results viacrate::Installer::option. - Option
Value - Parsed value of a user-defined option, stored per-option after
crate::Installer::process_commandline. - Overwrite
Mode - What to do when a destination file already exists.
Traits§
- From
Option Value - Types that can be pulled out of an
OptionValueviacrate::Installer::option. Implemented forbool,String,i64,i32,u64,u32. - Progress
Sink - Sink for progress, status, and log events emitted by installer operations.
Type Aliases§
- DirError
Handler - Per-file error handler for directory installs.
- DirFilter
- Filter closure for directory installs. Receives the relative path within
the directory (e.g.
"bin/app.exe") and returnstrueto include the file.