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> --versionwith a 10 s timeout, return stdout. A non-zero exit or timeout surfaces asUpdateError::SelfTestFailedat the call site. - default_
swap_ fn - Default
SwapFn— realself-replacecall. - download_
to_ file - Stream
assetintodest, returning the byte count. EmitsDownloadingprogress events. - dry_
run_ outcome - Dry-run outcome shape — no swap.
- extract_
binary - Extract the binary matching
tool_namefrom the archive atsrcintodest_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/Vfrom a tag and parse as semver. Used for thecheckcomparison and downgrade check. - swap_
outcome - Swap outcome shape — after a successful
self-replace.
Type Aliases§
- Self
Test Fn - Self-test function — runs the staged binary with
--versionand returns its captured stdout. Lets tests avoid spawning a real child. - SwapFn
- Swap function — lets tests substitute a double for
self_replace::self_replace. ReturnsOkiff the running binary has been replaced.