pub type Fetcher<'a> = dyn Fn(&str, &Path) -> Result<(), String> + 'a;Expand description
How bytes at a URL are written to a local path.
The transport is the caller’s: this crate has no HTTP dependency and is not
going to acquire one for a single asset kind. roteiro security prefetch
supplies an implementation over the ureq client already in the tree; tests
supply one that writes fixture bytes and never opens a socket, which is how
the download path is exercised without a network.
§The contract, and why it cannot be checked here
An implementation must write the whole file or fail. A truncated download
that returned Ok would be renamed into place, digested, and recorded as the
asset’s pin — and AssetSource::Download has no compile-time digest to
contradict it, so status would then report the short file as present and
matching. Staging through a .partial file guards against a crash, not
against a fetcher that misreports success.
Nothing in this crate can verify that: completeness is a property of the
transport’s framing, and this crate deliberately has no transport. The
shipped implementation is download_asset_file in the CLI, which establishes
it from the response’s declared length and refuses a body whose length cannot
be established at all.