pub struct Resource {
pub kind: ResourceKind,
pub name: String,
pub files: Vec<ResourceFile>,
pub request: RequestOptions,
pub checksum: Option<Checksum>,
pub revision: Option<String>,
pub metadata: BTreeMap<String, String>,
}Expand description
A parsed, backend-agnostic description of what the user wants to download.
Fields§
§kind: ResourceKindProtocol family and its identifying details.
name: StringDisplay name chosen by the parser, such as the URL filename or the repository name.
files: Vec<ResourceFile>Files that make up the resource. Protocols that only discover files while downloading, such as BitTorrent, leave this empty.
request: RequestOptionsRequest overrides carried over from the CLI and configuration.
checksum: Option<Checksum>Checksum supplied when the task was created, preserved in the sidecar and shown in CLI output.
revision: Option<String>Revision requested for the task, such as a Hub branch or tag.
metadata: BTreeMap<String, String>Protocol-private key/value data persisted in the sidecar. New protocol fields belong here rather than in new struct fields.
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn http_file(
url: Url,
request: RequestOptions,
checksum: Option<Checksum>,
) -> Result<Self>
pub fn http_file( url: Url, request: RequestOptions, checksum: Option<Checksum>, ) -> Result<Self>
Build a single-file ResourceKind::Http resource for url.
The display name and output path are derived from the URL’s last path
segment and validated with sanitize_relative_path, so an unsafe
filename fails the parse instead of being used.
Sourcepub fn total_size(&self) -> Option<u64>
pub fn total_size(&self) -> Option<u64>
Sum of the known file sizes, or None if any file size is unknown.
An empty file list sums to Some(0).