pub struct DownloadManager { /* private fields */ }Expand description
Manages a queue of downloads with progress tracking.
This is a synchronous data structure – callers drive the actual async downloads and update state through the provided methods.
Implementations§
Source§impl DownloadManager
impl DownloadManager
pub fn new(max_concurrent: usize) -> Self
Sourcepub fn enqueue(
&mut self,
url: String,
dest: PathBuf,
mod_name: Option<String>,
) -> usize
pub fn enqueue( &mut self, url: String, dest: PathBuf, mod_name: Option<String>, ) -> usize
Add a download to the queue. Returns the assigned download ID.
Sourcepub fn pause(&mut self, id: usize, bytes_so_far: u64)
pub fn pause(&mut self, id: usize, bytes_so_far: u64)
Pause an active download, recording how many bytes were fetched so far.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of currently active downloads.
Sourcepub fn max_concurrent(&self) -> usize
pub fn max_concurrent(&self) -> usize
Maximum number of concurrent downloads allowed.
Sourcepub fn all(&self) -> &[ManagedDownload]
pub fn all(&self) -> &[ManagedDownload]
View all tracked downloads.
Sourcepub fn get_mut(&mut self, id: usize) -> Option<&mut ManagedDownload>
pub fn get_mut(&mut self, id: usize) -> Option<&mut ManagedDownload>
Get a mutable reference to a download by ID.
Sourcepub fn get(&self, id: usize) -> Option<&ManagedDownload>
pub fn get(&self, id: usize) -> Option<&ManagedDownload>
Get an immutable reference to a download by ID.
Sourcepub fn can_start_more(&self) -> bool
pub fn can_start_more(&self) -> bool
Returns true if there is room to start another download.
Sourcepub fn next_queued(&self) -> Vec<usize>
pub fn next_queued(&self) -> Vec<usize>
Return IDs of queued downloads that could be activated, up to the remaining concurrency budget.
Auto Trait Implementations§
impl Freeze for DownloadManager
impl RefUnwindSafe for DownloadManager
impl Send for DownloadManager
impl Sync for DownloadManager
impl Unpin for DownloadManager
impl UnsafeUnpin for DownloadManager
impl UnwindSafe for DownloadManager
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