pub struct ModelLifecycle { /* private fields */ }Expand description
Stateful lifecycle helper for model installation progress.
Implementations§
Source§impl ModelLifecycle
impl ModelLifecycle
Sourcepub const fn new(manifest: ModelManifest, consent: DownloadConsent) -> Self
pub const fn new(manifest: ModelManifest, consent: DownloadConsent) -> Self
Create lifecycle state for a manifest.
Sourcepub const fn state(&self) -> &ModelState
pub const fn state(&self) -> &ModelState
Current lifecycle state.
Sourcepub const fn manifest(&self) -> &ModelManifest
pub const fn manifest(&self) -> &ModelManifest
Underlying manifest for this lifecycle.
Sourcepub fn approve_consent(&mut self, source: ConsentSource)
pub fn approve_consent(&mut self, source: ConsentSource)
Mark consent as granted (e.g., after explicit user approval).
Sourcepub fn begin_download(&mut self, total_bytes: u64) -> SearchResult<()>
pub fn begin_download(&mut self, total_bytes: u64) -> SearchResult<()>
Start the download state.
§Errors
Returns SearchError::InvalidConfig on invalid transition or zero total bytes.
Sourcepub fn update_download_progress(
&mut self,
bytes_downloaded: u64,
) -> SearchResult<()>
pub fn update_download_progress( &mut self, bytes_downloaded: u64, ) -> SearchResult<()>
Update bytes downloaded and recompute bounded percent.
§Errors
Returns SearchError::InvalidConfig if not currently downloading.
Sourcepub fn begin_verification(&mut self) -> SearchResult<()>
pub fn begin_verification(&mut self) -> SearchResult<()>
Move from downloading to verifying.
§Errors
Returns SearchError::InvalidConfig if not currently downloading.
Sourcepub fn mark_ready(&mut self)
pub fn mark_ready(&mut self)
Mark install ready.
Sourcepub fn fail_verification(&mut self, reason: impl Into<String>)
pub fn fail_verification(&mut self, reason: impl Into<String>)
Mark install verification failed.
Sourcepub fn mark_update_available(
&mut self,
current_revision: impl Into<String>,
latest_revision: impl Into<String>,
)
pub fn mark_update_available( &mut self, current_revision: impl Into<String>, latest_revision: impl Into<String>, )
Mark update available.
Sourcepub fn recover_after_cancel(&mut self) -> SearchResult<()>
pub fn recover_after_cancel(&mut self) -> SearchResult<()>
Recover from cancelled state so a new download can start.
§Errors
Returns SearchError::InvalidConfig if current state is not Cancelled.
Trait Implementations§
Source§impl Clone for ModelLifecycle
impl Clone for ModelLifecycle
Source§fn clone(&self) -> ModelLifecycle
fn clone(&self) -> ModelLifecycle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModelLifecycle
impl RefUnwindSafe for ModelLifecycle
impl Send for ModelLifecycle
impl Sync for ModelLifecycle
impl Unpin for ModelLifecycle
impl UnsafeUnpin for ModelLifecycle
impl UnwindSafe for ModelLifecycle
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
Mutably borrows from an owned value. Read more
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: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).