Struct cargo::core::package::Downloads

source ·
pub struct Downloads<'a, 'cfg> {
Show 16 fields set: &'a PackageSet<'cfg>, pending: HashMap<usize, (Download<'cfg>, EasyHandle)>, pending_ids: HashSet<PackageId>, results: Vec<(usize, Result<(), Error>)>, next: usize, progress: RefCell<Option<Progress<'cfg>>>, downloads_finished: usize, downloaded_bytes: u64, largest: (u64, String), start: Instant, success: bool, timeout: HttpTimeout, updated_at: Cell<Instant>, next_speed_check: Cell<Instant>, next_speed_check_bytes_threshold: Cell<u64>, _lock: PackageCacheLock<'cfg>,
}
Expand description

Helper for downloading crates.

Fields§

§set: &'a PackageSet<'cfg>§pending: HashMap<usize, (Download<'cfg>, EasyHandle)>

When a download is started, it is added to this map. The key is a “token” (see Download::token). It is removed once the download is finished.

§pending_ids: HashSet<PackageId>

Set of packages currently being downloaded. This should stay in sync with pending.

§results: Vec<(usize, Result<(), Error>)>

The final result of each download. A pair (token, result). This is a temporary holding area, needed because curl can report multiple downloads at once, but the main loop (wait) is written to only handle one at a time.

§next: usize

The next ID to use for creating a token (see Download::token).

§progress: RefCell<Option<Progress<'cfg>>>

Progress bar.

§downloads_finished: usize

Number of downloads that have successfully finished.

§downloaded_bytes: u64

Total bytes for all successfully downloaded packages.

§largest: (u64, String)

Size (in bytes) and package name of the largest downloaded package.

§start: Instant

Time when downloading started.

§success: bool

Indicates all downloads were successful.

§timeout: HttpTimeout

Timeout management, both of timeout thresholds as well as whether or not our connection has timed out (and accompanying message if it has).

Note that timeout management is done manually here instead of in libcurl because we want to apply timeouts to an entire batch of operations, not any one particular single operation.

§updated_at: Cell<Instant>

Last time bytes were received.

§next_speed_check: Cell<Instant>

This is a slow-speed check. It is reset to now + timeout_duration every time at least threshold bytes are received. If the current time ever exceeds next_speed_check, then give up and report a timeout error.

§next_speed_check_bytes_threshold: Cell<u64>

This is the slow-speed threshold byte count. It starts at the configured threshold value (default 10), and is decremented by the number of bytes received in each chunk. If it is <= zero, the threshold has been met and data is being received fast enough not to trigger a timeout; reset next_speed_check and set this back to the configured threshold.

§_lock: PackageCacheLock<'cfg>

Global filesystem lock to ensure only one Cargo is downloading at a time.

Implementations§

Starts to download the package for the id specified.

Returns None if the package is queued up for download and will eventually be returned from wait_for_download. Returns Some(pkg) if the package is ready and doesn’t need to be downloaded.

Returns the number of crates that are still downloading.

Blocks the current thread waiting for a package to finish downloading.

This method will wait for a previously enqueued package to finish downloading and return a reference to it after it’s done downloading.

Panics

This function will panic if there are no remaining downloads.

Block, waiting for curl. Returns a token and a Result for that token (Ok means the download successfully finished).

Trait Implementations§

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 416 bytes