Skip to main content

Crate nifty_download

Crate nifty_download 

Source
Expand description

download(…), shared by the interpreter and compiled apps: each download runs on its own thread and sends reports back over a channel, waking the UI thread, which writes them wherever the app’s call bound them.

Modules§

connection 🔒
One connection to the server, on its own thread: it asks for the file and writes the body into the file the download gives it, telling the download each step.
follow 🔒
Keeping a download’s bindings on its item when the list holding it changes.
http 🔒
Talking to web servers: the client every download uses, and what a server says about a file before sending it.
id 🔒
The ids that name downloads to code, such as download-3.
name 🔒
Choosing a downloaded file’s name and creating it without replacing anything.
part 🔒
The parts of a file a download fetches, each over its own connection: the whole file for one connection, or for several, stretches that end where the next begins.
report 🔒
What a download tells the app, and what each report writes into the state it bound.
retry 🔒
Trying a connection again after it fails in a way that may pass, waiting longer after each failure in a row.
size 🔒
format_bytes(n): a size in bytes the way people read it.
speed 🔒
How fast a download is going, averaged over its last moments so the number doesn’t jump with every chunk.
worker 🔒
A download’s own thread, which handles everything that happens to it, in order: its connections’ progress, and what the app asks of it.

Structs§

DownloadId
A download’s id, unique for as long as the process runs.
Downloads
The downloads an app has running, and the channel their reports arrive on.
Progress
The bytes received so far, of total when the server said, at speed bytes a second.
Request
A download an action asked for, started once the action has finished. targets says where its reports go, in whatever terms the app uses.
Running 🔒

Enums§

Report
How far a download has got, sent to the UI thread.
Written
A value a report writes: a whole number or text, as its field holds.

Traits§

StatePlace
A place in an app’s state, as its runner names one.
StateReader
Reading an app’s state, for finding where a download’s id went.

Functions§

follow_id
Moves bindings to the item that holds id now. false when no item holds it any more, so nothing shows the download. Bindings without an id: stay where they are.
format_bytes
bytes as text: "1 byte" and "999 bytes", then one decimal place in the largest unit that keeps the number at least 1, such as "1.5 MB".
join 🔒

Type Aliases§

Worker 🔒