Skip to main content

Crate installrs

Crate installrs 

Source
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-win32 or gui-gtk) — native wizard with welcome / license / components / directory picker / install / finish / error pages, plus custom pages for arbitrary inputs. The same wizard definition runs --headless for unattended installs. See gui::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)] (e.g. [EmbeddedEntry], [verify_payload], 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§

guigui
Optional native wizard GUI and dialog helpers.

Macros§

source
Produce a Source from a literal path, hashed at compile time.

Structs§

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. Chain filter and on_error for fine-grained control.
FileOp
Builder for installing a single embedded file. Created by Installer::file; finalize with install. Chain status / log / weight / overwrite / mode before installing.
Installer
The central context passed into your install and uninstall functions. 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.
RemoveOp
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.
StderrProgressSink
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.
UninstallerOp
Builder for writing the embedded uninstaller binary to disk. Created by Installer::uninstaller.

Enums§

ErrorAction
Decision returned from an on-error handler inside a directory install.
OptionKind
Declared shape of a user-defined command-line option. Register via crate::Installer::option; read parsed results via crate::Installer::option.
OptionValue
Parsed value of a user-defined option, stored per-option after crate::Installer::process_commandline.
OverwriteMode
What to do when a destination file already exists.

Traits§

FromOptionValue
Types that can be pulled out of an OptionValue via crate::Installer::option. Implemented for bool, String, i64, i32, u64, u32.
ProgressSink
Sink for progress, status, and log events emitted by installer operations.

Type Aliases§

DirErrorHandler
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 returns true to include the file.