Skip to main content

Module download

Module download 

Source
Expand description

Remote files downloaded to local ones, and stdin spooled to one. Reading and writing are on separate threads (writing on the caller’s, never a runtime worker) with at most QUEUED_CHUNKS between them, so a slow disk backs the transfer up instead of memory. Store streams poll on the app’s runtime; blocking readers (HTTP, stdin) get their own thread.

Structs§

TempDownload
A downloaded file, removed from disk when its last holder drops it: the app keeps one to read the file again, the dataset scanning it keeps another, and an event carrying one that is never handled removes it as it drops.

Enums§

StreamError
Why a download did not arrive whole.

Constants§

QUEUED_CHUNKS
Chunks queued between the side reading a download and the thread writing it.

Functions§

read_into
Run open on its own thread and pass each chunk to write here, in order, returning the bytes written (a stated length must match). Reads run at most QUEUED_CHUNKS ahead; a silent server holds the reader, not this thread, with stop checked between chunks and every STALL_CHECK. The reader ends at its next chunk once this side goes.
stream_into
Run open on runtime and pass each stream chunk to write on this thread, in order, returning the bytes written. stop (and whether this side still listens) is checked between chunks and every STALL_CHECK of silence. Errors, never a short success, on open or chunk failure, a refused write, a stop, or runtime shutdown. Blocks: never call on a runtime worker.

Type Aliases§

Opened
What opening a download answers: its stream or reader and its length, when the source gave one, or why it could not be opened.