Struct axoupdater::AxoUpdater

source ·
pub struct AxoUpdater {
    pub name: Option<String>,
    pub source: Option<ReleaseSource>,
    /* private fields */
}
Expand description

Struct representing an updater process

Fields§

§name: Option<String>

The name of the program to update, if specified

§source: Option<ReleaseSource>

Information about where updates should be fetched from

Implementations§

source§

impl AxoUpdater

source

pub fn load_receipt(&mut self) -> AxoupdateResult<&mut AxoUpdater>

Attempts to load an install receipt in order to prepare for an update. If present and valid, the install receipt is used to populate the source and current_version fields. Shell and Powershell installers produced by cargo-dist since 0.9.0 will have created an install receipt.

source

pub fn check_receipt_is_for_this_executable(&self) -> AxoupdateResult<bool>

Checks to see if the loaded install receipt is for this executable. Used to guard against cases where the running EXE is from a package manager, but a receipt from a shell installed-copy is present on the system. Returns an error if the receipt hasn’t been loaded yet.

source§

impl AxoUpdater

source

pub fn set_github_token(&mut self, token: &str) -> &mut AxoUpdater

Configures AxoUpdater to use a specific GitHub token when performing requests. This is useful in circumstances where the user may encounter rate limits, and is necessary to access private repositories. This must have the repo scope enabled.

source

pub fn set_axo_token(&mut self, token: &str) -> &mut AxoUpdater

Configures AxoUpdater to use a specific Axo Releases token when performing requests.

source§

impl AxoUpdater

source

pub fn new() -> AxoUpdater

Creates a new, empty AxoUpdater struct. This struct lacks information necessary to perform the update, so at least the name and source fields will need to be filled in before the update can run.

source

pub fn new_for(app_name: &str) -> AxoUpdater

Creates a new AxoUpdater struct with an explicitly-specified name.

source

pub fn new_for_updater_executable() -> AxoupdateResult<AxoUpdater>

Creates a new AxoUpdater struct by attempting to autodetect the name of the current executable. This is only meant to be used by standalone updaters, not when this crate is used as a library in another program.

source

pub fn set_release_source(&mut self, source: ReleaseSource) -> &mut AxoUpdater

Explicitly configures the release source as an alternative to reading it from the install receipt. This can be useful for tasks which want to query the new version without actually performing an upgrade.

source

pub fn set_current_version( &mut self, version: Version ) -> AxoupdateResult<&mut AxoUpdater>

Explicitly specifies the current version.

source

pub fn enable_installer_stdout(&mut self) -> &mut AxoUpdater

Enables printing the underlying installer’s stdout.

source

pub fn disable_installer_stdout(&mut self) -> &mut AxoUpdater

Disables printing the underlying installer’s stdout.

source

pub fn enable_installer_stderr(&mut self) -> &mut AxoUpdater

Enables printing the underlying installer’s stderr.

source

pub fn disable_installer_stderr(&mut self) -> &mut AxoUpdater

Disables printing the underlying installer’s stderr.

source

pub fn enable_installer_output(&mut self) -> &mut AxoUpdater

Enables all output for the underlying installer.

source

pub fn disable_installer_output(&mut self) -> &mut AxoUpdater

Disables all output for the underlying installer.

source

pub fn configure_installer_path( &mut self, path: impl Into<Utf8PathBuf> ) -> &mut AxoUpdater

Configures AxoUpdater to use a specific installer for the new release instead of downloading it from the release source.

source

pub fn use_release_installer(&mut self) -> &mut AxoUpdater

Configures AxoUpdater to use the installer from the new release. This is the default setting.

source

pub fn set_install_dir( &mut self, path: impl Into<Utf8PathBuf> ) -> &mut AxoUpdater

Configures AxoUpdater with the install path to use. This is only needed if installing without an explicit install prefix.

source

pub fn configure_version_specifier( &mut self, version_specifier: UpdateRequest ) -> &mut AxoUpdater

Configures axoupdater’s update strategy, replacing whatever was previously configured with the strategy in version_specifier.

source

pub fn always_update(&mut self, setting: bool) -> &mut AxoUpdater

Always upgrade, including when already running the latest version or when the current version isn’t known

source

pub async fn is_update_needed(&mut self) -> AxoupdateResult<bool>

Determines if an update is needed by querying the newest version from the location specified in source. This includes a blocking network call, so it may be slow. This can only be performed if the current_version field has been set, either by loading the install receipt or by specifying it using set_current_version. Note that this also checks to see if the current executable is eligible for updates, by checking to see if it’s the executable that the install receipt is for. In the case that the executable comes from a different source, it will return before the network call for a new version.

source

pub async fn run(&mut self) -> AxoupdateResult<Option<UpdateResult>>

Attempts to perform an update. The return value specifies whether an update was actually performed or not; false indicates “no update was needed”, while an error indicates that an update couldn’t be performed due to an error.

source

pub async fn query_new_version(&mut self) -> AxoupdateResult<Option<&Version>>

Queries for new releases and then returns the detected version.

Trait Implementations§

source§

impl Default for AxoUpdater

source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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