Struct squid::download::Task [] [src]

pub struct Task { /* fields omitted */ }

Represents a single file's download task.

Methods

impl Task
[src]

Creates a new download task.

Errors

Returns Err(Error::InvalidOption(...)) when an option is improperly configured.

Returns Err(Error::Io(...)) when a filesystem IO-related operation fails.

Returns Err(Error::Http(...)) when an HTTP-related operation fails.

Returns Err(Error::Tls(...)) when the establishment of the TLS client fails.

Returns Err(Error::MissingResponseHeader(...)) when the server response is missing a required header.

Returns Err(Error::EmptyTarget(...)) when the target content is reported by the server to have a length of zero bytes.

Examples

let options = download::Options
{
    output_directory: "./Downloads/".to_string(),

    ..Default::default()
};
// let task = download::Task::new("https://www.google.com/", &options).unwrap();

Starts the download.

Errors

Returns Err(Error::Http(...)) when an HTTP-related operation fails.

Returns Err(Error::Io(...)) when a filesystem IO-related operation fails.

Returns Err(Error::UnexpectedResponseLength(...)) when a response from the server is not of the expected length.

Returns Err(Error::Internal) when an internal unknown error has occurred. This usually indicates a problem in thread management in concurrent download strategies.

Examples

// let task = download::Task::new("https://www.google.com/", &options).unwrap();
// let output_file_path = task.start().unwrap();

Starts the download and reports back status changes via a supplied callback function.

Errors

Returns Err(Error::Http(...)) when an HTTP-related operation fails.

Returns Err(Error::Io(...)) when a filesystem IO-related operation fails.

Returns Err(Error::UnexpectedResponseLength(...)) when a response from the server is not of the expected length.

Returns Err(Error::Internal) when an internal unknown error has occurred. This usually indicates a problem in thread management in concurrent download strategies.

Examples

// let task = download::Task::new("https://www.google.com/", &options).unwrap();
// let output_file_path =
//    task
//        .start_and_report(|message| println!(message))
//        .unwrap();

Gets a reference to the options container.

Gets a reference to the target URL.

Gets the target's content length (in bytes).

Gets a reference to the target's file name.

Indicates whether the target supports partial content fetching.

Gets the output file's name.

Gets the output file's path.

Trait Implementations

impl Debug for Task
[src]

Formats the value using the given formatter.