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
Sourcepub fn new(max_concurrent: usize) -> Self
pub fn new(max_concurrent: usize) -> Self
Create an empty manager allowing up to max_concurrent active downloads.
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
Converts
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>
Converts
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