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
impl AxoUpdater
sourcepub fn load_receipt(&mut self) -> AxoupdateResult<&mut AxoUpdater>
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.
sourcepub fn check_receipt_is_for_this_executable(&self) -> AxoupdateResult<bool>
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
impl AxoUpdater
sourcepub fn set_github_token(&mut self, token: &str) -> &mut AxoUpdater
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.
sourcepub fn set_axo_token(&mut self, token: &str) -> &mut AxoUpdater
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
impl AxoUpdater
sourcepub fn new() -> AxoUpdater
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.
sourcepub fn new_for(app_name: &str) -> AxoUpdater
pub fn new_for(app_name: &str) -> AxoUpdater
Creates a new AxoUpdater struct with an explicitly-specified name.
sourcepub fn new_for_updater_executable() -> AxoupdateResult<AxoUpdater>
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.
sourcepub fn set_release_source(&mut self, source: ReleaseSource) -> &mut AxoUpdater
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.
sourcepub fn set_current_version(
&mut self,
version: Version
) -> AxoupdateResult<&mut AxoUpdater>
pub fn set_current_version( &mut self, version: Version ) -> AxoupdateResult<&mut AxoUpdater>
Explicitly specifies the current version.
sourcepub fn enable_installer_stdout(&mut self) -> &mut AxoUpdater
pub fn enable_installer_stdout(&mut self) -> &mut AxoUpdater
Enables printing the underlying installer’s stdout.
sourcepub fn disable_installer_stdout(&mut self) -> &mut AxoUpdater
pub fn disable_installer_stdout(&mut self) -> &mut AxoUpdater
Disables printing the underlying installer’s stdout.
sourcepub fn enable_installer_stderr(&mut self) -> &mut AxoUpdater
pub fn enable_installer_stderr(&mut self) -> &mut AxoUpdater
Enables printing the underlying installer’s stderr.
sourcepub fn disable_installer_stderr(&mut self) -> &mut AxoUpdater
pub fn disable_installer_stderr(&mut self) -> &mut AxoUpdater
Disables printing the underlying installer’s stderr.
sourcepub fn enable_installer_output(&mut self) -> &mut AxoUpdater
pub fn enable_installer_output(&mut self) -> &mut AxoUpdater
Enables all output for the underlying installer.
sourcepub fn disable_installer_output(&mut self) -> &mut AxoUpdater
pub fn disable_installer_output(&mut self) -> &mut AxoUpdater
Disables all output for the underlying installer.
sourcepub fn configure_installer_path(
&mut self,
path: impl Into<Utf8PathBuf>
) -> &mut AxoUpdater
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.
sourcepub fn use_release_installer(&mut self) -> &mut AxoUpdater
pub fn use_release_installer(&mut self) -> &mut AxoUpdater
Configures AxoUpdater to use the installer from the new release. This is the default setting.
sourcepub fn set_install_dir(
&mut self,
path: impl Into<Utf8PathBuf>
) -> &mut AxoUpdater
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.
sourcepub fn configure_version_specifier(
&mut self,
version_specifier: UpdateRequest
) -> &mut AxoUpdater
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
.
sourcepub fn always_update(&mut self, setting: bool) -> &mut AxoUpdater
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
sourcepub async fn is_update_needed(&mut self) -> AxoupdateResult<bool>
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.
sourcepub async fn run(&mut self) -> AxoupdateResult<Option<UpdateResult>>
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.
sourcepub async fn query_new_version(&mut self) -> AxoupdateResult<Option<&Version>>
pub async fn query_new_version(&mut self) -> AxoupdateResult<Option<&Version>>
Queries for new releases and then returns the detected version.