Skip to main content

Updater

Struct Updater 

Source
pub struct Updater { /* private fields */ }
Expand description

A package’s updates: one thread checks and downloads, the state is shared, and nothing is applied until Updater::apply. Clones share the thread and the state; the thread ends with the last clone.

Implementations§

Source§

impl Updater

Source

pub fn new(spec: &'static PackageSpec, source: Source) -> Result<Updater, Error>

Error::NotPackaged outside a package.

Source

pub fn on_change(&self, f: impl Fn() + Send + Sync + 'static)

Called after every change of state: a GUI asks for a repaint here. Runs on the updater’s thread, or on the thread calling apply when before_apply refuses.

Source

pub fn status(&self) -> PackageStatus

The running version and what the updater is doing. Never waits for a check.

Source

pub fn check_now(&self)

Look now (the Check button, <app> update), and download what is found.

Source

pub fn run_in_background(&self, every: Duration)

Look at once and then every every, downloading what is found. A second call replaces the interval.

Source

pub fn apply(&self, after: After) -> Result<(), Error>

Runs before_apply, then hands the downloaded update to Velopack’s updater, which waits for this process to end before it replaces the files.

Who ends the process: for After::Exit this call exits it and returns only on an error. For After::RestartApp and After::RestartWith it returns Ok, and the caller must end the process soon (Velopack waits 60 seconds), a GUI by closing its window so that what it saves on exit is saved.

Once this returns Ok, the update is Velopack’s: if the app cancels the close (a “save your changes?” it answers with Cancel) or otherwise keeps running, a later call in this process fails with Error::Applying. Whether the update is applied then is up to Velopack’s updater, which waits for this process to end.

An error: nothing downloaded, an apply already running on another thread (Error::Applying), before_apply refused (nothing is applied, and a later call tries again), or Velopack failed.

Source

pub fn apply_pending_at_start(&self) -> Result<(), Error>

For a GUI’s start only, before its window opens: apply an update downloaded earlier and never applied, and start the app again; this call then exits the process itself, as there is no window to close. Looks at the downloaded packages only, never the network, so the start is not delayed. Ok when there is none, and on a start by Velopack’s updater: an update it failed to apply would otherwise be tried at every start.

Only the app’s single GUI instance may call this: an app that can run two must prevent the second first (corundum-framework-platform’s instance, or the gui crate’s WindowOptions::single_instance), or the second applies under the first.

Trait Implementations§

Source§

impl Clone for Updater

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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