UpdateManager

Struct UpdateManager 

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

Update manager implementation with full lifecycle support

Implementations§

Source§

impl UpdateManager

Source

pub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>

Create a new update manager with comprehensive initialization

Source

pub async fn CheckForUpdates(&self) -> Result<Option<UpdateInfo>>

Check for available updates from the configured update server

This method:

  • Queries the update server based on the configured channel
  • Validates the update against minimum compatibility requirements
  • Updates the internal status with available update information
  • Triggers automatic download if configured

Returns: Some(UpdateInfo) if an update is available, None otherwise

Source

pub async fn DownloadUpdate(&self, update_info: &UpdateInfo) -> Result<()>

Download update package with resumable download support

This method:

  • Validates available disk space before starting download
  • Supports resumable downloads from network interruptions
  • Tracks download progress and calculates ETA
  • Updates download speed metrics
  • Verifies all checksums after download
§Arguments
  • update_info - Update information containing download URL and metadata
§Returns

Result<()> indicating success or failure

Source

pub async fn ApplyUpdate(&self, update_info: &UpdateInfo) -> Result<()>

Apply update with rollback capability

This method:

  • Creates full backup of current installation
  • Validates update package integrity
  • Applies update atomically
  • Automatically rolls back on failure
  • Updates rollback history
§Arguments
  • update_info - Update information for the version to apply
§Returns

Result<()> indicating success or failure (with automatic rollback)

Source

pub async fn RollbackToBackup(&self, backup_info: &RollbackState) -> Result<()>

Rollback to a previous version using backup

This method:

  • Verifies backup integrity using checksum
  • Restores files from backup
  • Validated rollback success
§Arguments
  • backup_info - Rollback state containing backup information
§Returns

Result<()> indicating success or failure

Source

pub async fn RollbackToVersion(&self, version: &str) -> Result<()>

Rollback to a specific version by version number

This method:

  • Searches for backup matching the version
  • Calls RollbackToBackup with the backup
§Arguments
  • version - Version to rollback to
§Returns

Result<()> indicating success or failure

Source

pub async fn GetAvailableRollbackVersions(&self) -> Vec<String>

Get available rollback versions

Returns list of versions that can be rolled back to

Source

pub async fn verify_update( &self, file_path: &str, update_info: Option<&UpdateInfo>, ) -> Result<bool>

Verify update file integrity comprehensive check

This method:

  • Checks file existence and non-zero size
  • Verifies all checksums if UpdateInfo provided
  • Detects corrupted downloads
§Arguments
  • file_path - Path to the update file
  • update_info - Optional update info with checksums
§Returns

Result - true if valid, false if invalid

Source

pub fn CompareVersions(v1: &str, v2: &str) -> i32

Compare two semantic version strings

Returns:

  • -1 if v1 < v2
  • 0 if v1 == v2
  • 1 if v1 > v2
§Arguments
  • v1 - First version string
  • v2 - Second version string
§Returns

i32 indicating comparison result

Source

pub async fn GetStatus(&self) -> UpdateStatus

Get current update status

Returns a clone of the current update status

Source

pub async fn CancelDownload(&self) -> Result<()>

Cancel ongoing download

This method:

  • Cancels the active download session
  • Cleans up temporary files
  • Updates status to paused
Source

pub async fn ResumeDownload(&self, update_info: &UpdateInfo) -> Result<()>

Resume paused download

This method:

  • Resumes a paused download session
  • Uses HTTP Range header for resume capability
§Arguments
  • update_info - Update information to resume download
Source

pub async fn GetUpdateChannel(&self) -> UpdateChannel

Get update configuration

Returns the current update channel configuration

Source

pub async fn SetUpdateChannel(&mut self, channel: UpdateChannel)

Set update channel

§Arguments
  • channel - New update channel to use
Source

pub async fn StageUpdate(&self, update_info: &UpdateInfo) -> Result<()>

Stage update for pre-installation verification

This method:

  • Stages the update in the staging directory
  • Verifies the staged update
  • Prepares for installation
§Arguments
  • update_info - Update information to stage
Source

pub async fn CleanupOldUpdates(&self) -> Result<()>

Clean up old update files

Removes downloaded updates older than a certain threshold to free disk space

Source

pub fn GetCacheDirectory(&self) -> &PathBuf

Get the cache directory path

Source

pub async fn StartBackgroundTasks(&self) -> Result<JoinHandle<()>>

Start background update checking task

This method:

  • Periodically checks for updates based on configured interval
  • Runs in a separate tokio task
  • Can be cancelled by stopping the task
§Returns

Result<tokio::task::JoinHandle<()>> - Handle to the background task

Source

pub async fn StopBackgroundTasks(&self)

Stop background tasks

This method:

  • Logs the stop request
  • In production, would cancel the join handle

Trait Implementations§

Source§

impl Clone for UpdateManager

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · 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.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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 = 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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