pub struct DownloadHistory { /* private fields */ }Expand description
Persistent download history backed by a JSON file in the OS config dir.
Implementations§
Source§impl DownloadHistory
impl DownloadHistory
Sourcepub fn load() -> Self
pub fn load() -> Self
Load history from disk. Returns an empty history if the file does not exist or cannot be parsed.
Sourcepub fn save(&self) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn save(&self) -> Result<(), Box<dyn Error + Send + Sync>>
Write the current history to disk.
Sourcepub fn record(
&mut self,
entry: HistoryEntry,
status: EntryStatus,
error: Option<String>,
)
pub fn record( &mut self, entry: HistoryEntry, status: EntryStatus, error: Option<String>, )
Finalise an entry with a status and optional error message, then append (or replace, if the same URL already has an entry) it.
Sourcepub fn entries(&self) -> &[HistoryEntry]
pub fn entries(&self) -> &[HistoryEntry]
All history entries in insertion order (oldest first).
Sourcepub fn recent(&self, n: usize) -> Vec<&HistoryEntry>
pub fn recent(&self, n: usize) -> Vec<&HistoryEntry>
Up to n most-recent entries, newest first.
Sourcepub fn clear_completed(&mut self) -> usize
pub fn clear_completed(&mut self) -> usize
Remove entries whose status is Completed or Cancelled.
Returns the number of entries removed.
Auto Trait Implementations§
impl Freeze for DownloadHistory
impl RefUnwindSafe for DownloadHistory
impl Send for DownloadHistory
impl Sync for DownloadHistory
impl Unpin for DownloadHistory
impl UnsafeUnpin for DownloadHistory
impl UnwindSafe for DownloadHistory
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> 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