#[non_exhaustive]pub struct Task {Show 14 fields
pub schema_version: u32,
pub id: TaskId,
pub link: Link,
pub resource: Option<Resource>,
pub backend: Option<String>,
pub destination: PathBuf,
pub options: TaskOptions,
pub priority: i32,
pub state: TaskState,
pub files: Vec<FileItem>,
pub resume: Option<TaskResume>,
pub error: Option<String>,
pub created_at_ms: u64,
pub updated_at_ms: u64,
}Expand description
A persisted download task: the requested link, its resolved resource, destination and current progress.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.schema_version: u32Sidecar schema version; see TASK_SCHEMA_VERSION.
id: TaskIdUnique task id, also used as the sidecar file name.
link: LinkOriginal link supplied by the user.
resource: Option<Resource>Parsed, backend-agnostic description of what to download.
backend: Option<String>Name of the backend selected to execute the task.
destination: PathBufRoot directory that relative output paths are resolved against.
options: TaskOptionsPer-task options supplied when the task was added.
priority: i32Queue priority; larger values run first.
state: TaskStateCurrent lifecycle state of the task.
files: Vec<FileItem>Per-file progress entries generated from the resource.
resume: Option<TaskResume>Per-file resume checkpoints written while downloading.
error: Option<String>Error message from the most recent failure, if any.
created_at_ms: u64Creation timestamp in Unix milliseconds.
updated_at_ms: u64Timestamp of the last modification in Unix milliseconds.
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(link: Link, destination: PathBuf, options: TaskOptions) -> Self
pub fn new(link: Link, destination: PathBuf, options: TaskOptions) -> Self
Create a pending task with a fresh id and current timestamps. The file
list stays empty until Task::set_resource is called.
Sourcepub fn key(&self) -> String
pub fn key(&self) -> String
De-duplication key built from the canonical link and the destination path.
Sourcepub fn set_resource(&mut self, resource: Resource)
pub fn set_resource(&mut self, resource: Resource)
Attach the resolved resource and rebuild the per-file progress entries from it.
Sourcepub fn refresh_from_resume(&mut self)
pub fn refresh_from_resume(&mut self)
Pull completed byte counts and final paths back from the resume
manifest so status/list show meaningful progress.
Sourcepub fn total_bytes(&self) -> Option<u64>
pub fn total_bytes(&self) -> Option<u64>
Total size of all files in bytes, or None if any file has an unknown
size.
Sourcepub fn downloaded_bytes(&self) -> u64
pub fn downloaded_bytes(&self) -> u64
Sum of the bytes downloaded so far across all files.