Skip to main content

Module flow

Module flow 

Source
Expand description

The 10-step self-update flow. Pure functions + small helpers the crate::Updater composes.

The steps run in strict order — each precondition is checked and a failure leaves the disk in one of two states: the old binary untouched, or the new one fully verified and swapped in. No in-between.

Functions§

cache_dir_for
Default cache dir — <project-cache-dir>/update/<version>/. Falls back to the system temp dir if directories-rs can’t resolve.
default_self_test_fn
Default SelfTestFn — exec <staged> --version with a 10 s timeout, return stdout. A non-zero exit or timeout surfaces as UpdateError::SelfTestFailed at the call site.
default_swap_fn
Default SwapFn — real self-replace call.
download_to_file
Stream asset into dest, returning the byte count. Emits Downloading progress events.
dry_run_outcome
Dry-run outcome shape — no swap.
extract_binary
Extract the binary matching tool_name from the archive at src into dest_dir. Returns the extracted binary’s path.
fetch_small_asset
Fully buffer an asset into memory. Returns the bytes. Used for signatures and checksum files, which are small.
mark_executable
Set POSIX executable bits on path. No-op on Windows.
parse_release_tag
Strip any leading v / V from a tag and parse as semver. Used for the check comparison and downgrade check.
swap_outcome
Swap outcome shape — after a successful self-replace.

Type Aliases§

SelfTestFn
Self-test function — runs the staged binary with --version and returns its captured stdout. Lets tests avoid spawning a real child.
SwapFn
Swap function — lets tests substitute a double for self_replace::self_replace. Returns Ok iff the running binary has been replaced.