Skip to main content

Crate kaishin

Crate kaishin 

Source
Expand description

kaishin is a universal self-update library for Rust CLIs, extracted from rvpm and renri.

It provides utilities to:

  1. Fetch the latest release information from GitHub.
  2. Detect how the current executable was installed (e.g., via cargo install).
  3. Perform a self-update by replacing the current binary.
  4. Manage background update check intervals to avoid frequent API calls via Checker.
  5. Silently auto-update in the background — check, download, and replace the binary without prompting via Checker::auto_update / Checker::spawn_auto_update. The running process keeps the old binary; the new version takes effect on the next launch.

Structs§

Checker
A high-level handler for managing background update checks.
KaishinOptions
Configuration options for kaishin.
LatestRelease
Information about the latest release fetched from the GitHub API.
UpdateCheckState
Persistent state for background update checks, used for throttling.
UpdateOptions
Options for the self-update process.

Enums§

InstallMethod
The method by which the current executable was installed.

Functions§

check_latest_release
Fetches the latest release information for the repository specified in opts from GitHub.
default_interval
Returns the default interval between background update checks (24 hours).
default_state_path
Returns the default path for the state file under the system’s data directory.
detect_install_method
Detects the installation method of the executable at the given path.
format_update_banner
Formats a banner message intended for display when an update is available.
is_update_available
Compares the current version with a latest tag and returns true if an update is available.
load_check_state
Loads the persistent update check state from the given path.
parse_interval
Parses a duration string (e.g., “24h”, “1d”, “30m”) into a Duration.
run_self_update
Executes the self-update flow.
save_check_state
Saves the persistent update check state to the given path.
should_auto_check
Determines whether an automatic update check should be performed based on the interval.