pub struct Downloads<'a, 'gctx> {Show 17 fields
set: &'a PackageSet<'gctx>,
pending: HashMap<usize, (Download<'gctx>, EasyHandle)>,
pending_ids: HashSet<PackageId>,
sleeping: SleepTracker<(Download<'gctx>, Easy)>,
results: Vec<(usize, Result<(), Error>)>,
next: usize,
progress: RefCell<Option<Progress<'gctx>>>,
downloads_finished: usize,
downloaded_bytes: u64,
largest: (u64, InternedString),
start: Instant,
success: bool,
timeout: HttpTimeout,
updated_at: Cell<Instant>,
next_speed_check: Cell<Instant>,
next_speed_check_bytes_threshold: Cell<u64>,
_lock: CacheLock<'gctx>,
}
Expand description
Helper for downloading crates.
Fields§
§set: &'a PackageSet<'gctx>
§pending: HashMap<usize, (Download<'gctx>, 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
.
sleeping: SleepTracker<(Download<'gctx>, Easy)>
Downloads that have failed and are waiting to retry again later.
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<'gctx>>>
Progress bar.
downloads_finished: usize
Number of downloads that have successfully finished.
downloaded_bytes: u64
Total bytes for all successfully downloaded packages.
largest: (u64, InternedString)
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: CacheLock<'gctx>
Global filesystem lock to ensure only one Cargo is downloading at a time.
Implementations§
Source§impl<'a, 'gctx> Downloads<'a, 'gctx>
impl<'a, 'gctx> Downloads<'a, 'gctx>
Sourcepub fn start(&mut self, id: PackageId) -> CargoResult<Option<&'a Package>>
pub fn start(&mut self, id: PackageId) -> CargoResult<Option<&'a Package>>
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.
fn start_inner(&mut self, id: PackageId) -> CargoResult<Option<&'a Package>>
Sourcepub fn wait(&mut self) -> CargoResult<&'a Package>
pub fn wait(&mut self) -> CargoResult<&'a Package>
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.
fn enqueue(&mut self, dl: Download<'gctx>, handle: Easy) -> CargoResult<()>
Sourcefn wait_for_curl(&mut self) -> CargoResult<(usize, Result<(), Error>)>
fn wait_for_curl(&mut self) -> CargoResult<(usize, Result<(), Error>)>
Block, waiting for curl. Returns a token and a Result
for that token
(Ok
means the download successfully finished).
fn add_sleepers(&mut self) -> CargoResult<()>
fn progress(&self, token: usize, total: u64, cur: u64) -> bool
fn tick(&self, why: WhyTick<'_>) -> CargoResult<()>
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'gctx> !Freeze for Downloads<'a, 'gctx>
impl<'a, 'gctx> !RefUnwindSafe for Downloads<'a, 'gctx>
impl<'a, 'gctx> !Send for Downloads<'a, 'gctx>
impl<'a, 'gctx> !Sync for Downloads<'a, 'gctx>
impl<'a, 'gctx> Unpin for Downloads<'a, 'gctx>
impl<'a, 'gctx> !UnwindSafe for Downloads<'a, 'gctx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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: 440 bytes