Struct parallel_getter::ParallelGetter[][src]

pub struct ParallelGetter<'a, W: Write + 'a> { /* fields omitted */ }

Type for constructing parallel GET requests.

Example

extern crate reqwest;
extern crate parallel_getter;

use reqwest::Client;
use parallel_getter::ParallelGetter;
use std::fs::File;
use std::path::PathBuf;
use std::sync::Arc;

let client = Arc::new(Client::new());
let mut file = File::create("new_file").unwrap();
ParallelGetter::new("url_here", &mut file)
    // Additional mirrors that can be used.
    .mirrors(&["mirror_a", "mirror_b"])
    // Optional client to use for the request.
    .client(client)
    // Optional path to store the parts.
    .cache_path(PathBuf::from("/a/path/here"))
    // Number of theads to use.
    .threads(5)
    // threshold (length in bytes) to determine when multiple threads are required.
    .threshold_parallel(1 * 1024 * 1024)
    // threshold for defining when to store parts in memory or on disk.
    .threshold_memory(10 * 1024 * 1024)
    // Callback for monitoring progress.
    .callback(16, Box::new(|progress, total| {
        println!(
            "{} of {} KiB downloaded",
            progress / 1024,
            total / 1024
        );
    }))
    // Commit the parallel GET requests.
    .get();

Methods

impl<'a, W: Write> ParallelGetter<'a, W>
[src]

Initialize a new ParallelGetter

Notes

  • The url is the location which we will send a GET to.
  • The dest is where the completed file will be written to.
  • By default, 4 threads will be used.

Submit the parallel GET request.

If defined, downloads will be stored here instead of a temporary directory.

Notes

This is required to enable resumable downloads (not yet implemented).

Specify a callback for monitoring progress, to be polled at the given interval.

Allow the caller to provide their own Client.

Specify additional URLs that point to the same content, to be used for boosted transfers.

Number of attempts to make before giving up.

If the length is less than this threshold, parts will be stored in memory.

If the length is less than this threshold, threads will not be used.

Number of threads to download a file with.

Auto Trait Implementations

impl<'a, W> !Send for ParallelGetter<'a, W>

impl<'a, W> !Sync for ParallelGetter<'a, W>