pub struct UpdateManager<S = GitHubSource>where
S: Source,{
pub target_application: PathBuf,
pub source: S,
/* private fields */
}Expand description
Drives the three-phase, in-place self-update of an application binary.
An UpdateManager lists the releases offered by its Source, downloads
the asset the source selected for this platform, and then walks through the
prepare → replace → cleanup phases by relaunching the application between
each phase (see the crate-level docs and RESUME_FLAG).
Construct one with UpdateManager::new (which targets the currently
running executable) and customise it with
with_target_application if needed. Which
release asset is downloaded is configured on the Source — see
GitHubSource.
Fields§
§target_application: PathBufThe application binary which will be replaced by the update. Defaults to the currently running executable.
source: SThe source releases are listed and downloaded from.
Implementations§
Source§impl<S> UpdateManager<S>where
S: Source,
impl<S> UpdateManager<S>where
S: Source,
Sourcepub fn new(source: S) -> Self
pub fn new(source: S) -> Self
Create a manager which will update the currently running executable
using the provided release source.
Sourcepub fn with_target_application(self, target_application: PathBuf) -> Self
pub fn with_target_application(self, target_application: PathBuf) -> Self
Override the application binary which will be updated (defaults to the currently running executable).
Sourcepub async fn get_releases(&self) -> Result<Vec<Release>, Error>
pub async fn get_releases(&self) -> Result<Vec<Release>, Error>
List the releases available from the configured Source.
Sourcepub async fn update(&self, release: &Release) -> Result<bool, Error>
pub async fn update(&self, release: &Release) -> Result<bool, Error>
Begin updating the target_application to
the provided release.
This downloads the new binary, then launches it to continue the update
in a separate process. Returns Ok(true) if an update was started, in
which case the caller should exit promptly so the relaunched process can
replace the running binary.
Sourcepub async fn resume(&self, state: &UpdateState) -> Result<bool, Error>
pub async fn resume(&self, state: &UpdateState) -> Result<bool, Error>
Resume an update from a previously serialized UpdateState.
A consuming application calls this (usually via
resume_from_arg) when it is relaunched with
the RESUME_FLAG. Returns Ok(true) when a phase
was processed and the process should exit.
Sourcepub async fn resume_from_arg(&self, state_json: &str) -> Result<bool, Error>
pub async fn resume_from_arg(&self, state_json: &str) -> Result<bool, Error>
Deserialize an UpdateState from the JSON argument that follows the
RESUME_FLAG on the command line, then
resume the update from it.