Skip to main content

UpdateManager

Struct UpdateManager 

Source
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: PathBuf

The application binary which will be replaced by the update. Defaults to the currently running executable.

§source: S

The source releases are listed and downloaded from.

Implementations§

Source§

impl<S> UpdateManager<S>
where S: Source,

Source

pub fn new(source: S) -> Self

Create a manager which will update the currently running executable using the provided release source.

Source

pub fn with_target_application(self, target_application: PathBuf) -> Self

Override the application binary which will be updated (defaults to the currently running executable).

Source

pub async fn get_releases(&self) -> Result<Vec<Release>, Error>

List the releases available from the configured Source.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<S> Debug for UpdateManager<S>
where S: Source,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S> Default for UpdateManager<S>
where S: Source,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S = GitHubSource> !RefUnwindSafe for UpdateManager<S>

§

impl<S = GitHubSource> !UnwindSafe for UpdateManager<S>

§

impl<S> Freeze for UpdateManager<S>
where S: Freeze,

§

impl<S> Send for UpdateManager<S>

§

impl<S> Sync for UpdateManager<S>

§

impl<S> Unpin for UpdateManager<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for UpdateManager<S>
where S: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more