pub struct DownloadProgress {
pub total_size: Option<u64>,
pub bytes_downloaded: u64,
pub file_hash: String,
pub cdn_host: String,
pub cdn_path: String,
pub target_file: PathBuf,
pub progress_file: PathBuf,
pub is_complete: bool,
pub last_updated: u64,
}
Expand description
Download progress information persisted to disk
Fields§
§total_size: Option<u64>
Total expected file size in bytes
bytes_downloaded: u64
Number of bytes downloaded so far
file_hash: String
Original file hash for verification
cdn_host: String
CDN host used for download
cdn_path: String
CDN path for the file
target_file: PathBuf
Target file path where content is being written
progress_file: PathBuf
Progress file path for state persistence
is_complete: bool
Whether the download is complete
last_updated: u64
Timestamp of last update (for cleanup of old progress files)
Implementations§
Source§impl DownloadProgress
impl DownloadProgress
Sourcepub fn new(
file_hash: String,
cdn_host: String,
cdn_path: String,
target_file: PathBuf,
) -> Self
pub fn new( file_hash: String, cdn_host: String, cdn_path: String, target_file: PathBuf, ) -> Self
Create a new download progress tracker
Sourcepub async fn load_from_file(progress_file: &Path) -> Result<Self>
pub async fn load_from_file(progress_file: &Path) -> Result<Self>
Load progress from disk
Sourcepub async fn save_to_file(&self) -> Result<()>
pub async fn save_to_file(&self) -> Result<()>
Save progress to disk
Sourcepub async fn verify_existing_file(&self) -> Result<bool>
pub async fn verify_existing_file(&self) -> Result<bool>
Check if the target file exists and has the expected size
Sourcepub fn completion_percentage(&self) -> Option<f64>
pub fn completion_percentage(&self) -> Option<f64>
Calculate download completion percentage
Sourcepub fn progress_string(&self) -> String
pub fn progress_string(&self) -> String
Get human-readable progress string
Trait Implementations§
Source§impl Clone for DownloadProgress
impl Clone for DownloadProgress
Source§fn clone(&self) -> DownloadProgress
fn clone(&self) -> DownloadProgress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DownloadProgress
impl Debug for DownloadProgress
Source§impl<'de> Deserialize<'de> for DownloadProgress
impl<'de> Deserialize<'de> for DownloadProgress
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DownloadProgress
impl RefUnwindSafe for DownloadProgress
impl Send for DownloadProgress
impl Sync for DownloadProgress
impl Unpin for DownloadProgress
impl UnwindSafe for DownloadProgress
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