Skip to main content

Module download

Module download 

Source
Expand description

Native weight download and on-disk cache (download feature).

Fetches a model’s weight files over HTTP, verifies their SHA-256, and stores them under super::cache_dir. This is the “download on use” path for native hosts (e.g. QSMxT). WASM hosts do not use this module — they fetch weights in JavaScript and feed the bytes to super::onnx directly.

Enums§

DownloadError
Error from resolving or downloading model weights.

Constants§

MAX_ATTEMPTS 🔒
Max HTTP attempts for a single weight file (1 initial + 4 retries).

Functions§

checksum_ok 🔒
ensure_file
Ensure a single weight file is present locally, downloading it if needed, and return its path. See ensure_file_with_progress.
ensure_file_with_progress
Like ensure_file, but reports download progress via on_progress(downloaded, total) (bytes). total is the registry-declared size (WeightFile::bytes), falling back to the response Content-Length. Not called on a cache hit.
ensure_model
Ensure every weight file for a model is present, returning their paths in ModelSpec::files order.
http_get 🔒
Fetch a URL with exponential-backoff retries, streaming the body and reporting on_progress(downloaded, total) as it goes (total from expected_total, else the response Content-Length, else 0 = unknown). Progress resets to 0 at the start of each attempt (a retried download restarts from the beginning).
http_get_once 🔒
One HTTP GET, streamed in chunks. Returns (message, retryable) on failure.
primary_bytes
Read the primary (first) weight file of a model into memory. Convenience for handing bytes straight to super::onnx::OnnxModel::load.
sha256_hex
Lowercase hex SHA-256 of a byte slice.