pub struct Updater {
pub app_name: String,
pub current_version: Version,
pub proxy: Option<Url>,
pub github_client: GitHubClient,
pub headers: HeaderMap,
pub extract_path: PathBuf,
pub timeout: Option<Duration>,
pub installer_args: Vec<OsString>,
pub current_exe_args: Vec<OsString>,
pub latest_release: Option<GitHubRelease>,
pub proper_asset: Option<GitHubAsset>,
}Expand description
Updater instance capable of checking, downloading and installing updates.
Fields§
§app_name: String§current_version: Version§proxy: Option<Url>§github_client: GitHubClient§headers: HeaderMap§extract_path: PathBuf§timeout: Option<Duration>§installer_args: Vec<OsString>§current_exe_args: Vec<OsString>§latest_release: Option<GitHubRelease>§proper_asset: Option<GitHubAsset>Implementations§
Source§impl Updater
impl Updater
Sourcepub async fn latest_release(&self) -> Result<GitHubRelease>
pub async fn latest_release(&self) -> Result<GitHubRelease>
Fetch the latest GitHub release and convert it into a simplified structure.
Sourcepub fn latest_version(&self) -> Option<Version>
pub fn latest_version(&self) -> Option<Version>
The version of the latest release if it has been previously cached on this instance.
Sourcepub fn asset_size(&self) -> Option<u64>
pub fn asset_size(&self) -> Option<u64>
The size in bytes of the asset selected for this platform, if already resolved.
Sourcepub async fn proper_asset(&self) -> Result<GitHubAsset>
pub async fn proper_asset(&self) -> Result<GitHubAsset>
Resolve the proper asset for the current OS/arch.
Sourcepub async fn check(&self) -> Result<Option<Updater>>
pub async fn check(&self) -> Result<Option<Updater>>
Check for a newer version. Returns Ok(Some(Updater)) configured with the
selected asset if an update is available, or Ok(None) if up-to-date.
Sourcepub async fn update<C: FnMut(usize)>(&self, on_chunk: C) -> Result<bool>
pub async fn update<C: FnMut(usize)>(&self, on_chunk: C) -> Result<bool>
Check for updates and download/install if available.
This is a convenience method that combines Updater::check() and Updater::download_and_install().
Returns Ok(true) if an update was found and installed, Ok(false) if no update was needed.
Source§impl Updater
impl Updater
Sourcepub async fn download<C: FnMut(usize)>(&self, on_chunk: C) -> Result<Vec<u8>>
pub async fn download<C: FnMut(usize)>(&self, on_chunk: C) -> Result<Vec<u8>>
Downloads the updater package, verifies it then return it as bytes.
Use Updater::install to install it
Sourcepub fn install(&self, bytes: impl AsRef<[u8]>) -> Result<()>
pub fn install(&self, bytes: impl AsRef<[u8]>) -> Result<()>
Installs the updater package downloaded by Updater::download
pub fn relaunch(&self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Updater
impl !RefUnwindSafe for Updater
impl Send for Updater
impl Sync for Updater
impl Unpin for Updater
impl !UnwindSafe for Updater
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more