lucem_hub
lucem-hub: verified downloads of published artifacts (model weights) and their local cache,
as dsp-kitchen’s dspk-hub. All network access of lucem’s models is here.
A file is fetched to a temporary name, hashed while it streams, and committed to the cache only
when its SHA-256 and size match; a file without a hash is refused. The cache is
$LUCEM_MODELS, else $XDG_CACHE_HOME/lucem/models, else ~/.cache/lucem/models, one folder
per model family.
Functions
Section titled “Functions”cache_dir
Section titled “cache_dir”pub fn cache_dir(family: &str) -> PathBufThe cache folder of a model family.
sha256_file
Section titled “sha256_file”pub fn sha256_file(path: &Path) -> Result<String>The SHA-256 of a file (lowercase hex).
is_valid
Section titled “is_valid”pub fn is_valid(path: &Path, sha256: &str, bytes: u64) -> boolWhether path holds the expected file (size first, then hash).
read_verified
Section titled “read_verified”pub fn read_verified(path: &Path, sha256: &str) -> Result<Vec<u8>, String>Reads a file only if its hash matches (what a model loads).
pub fn fetch( url: &str, dest: &Path, sha256: &str, bytes: u64, progress: &mut dyn FnMut(u64, u64),) -> Result<PathBuf, String>Downloads url to dest unless a valid copy is there; progress(done, total) follows the
bytes. The file is committed only when its SHA-256 (and size, when given) match.
fetch_archive
Section titled “fetch_archive”pub fn fetch_archive( url: &str, archive: &Path, sha256: &str, bytes: u64, dest_dir: &Path, progress: &mut dyn FnMut(u64, u64),) -> Result<PathBuf, String>Downloads a .tgz (verified like fetch) and unpacks it into dest_dir, unless
dest_dir already holds what it unpacked (a .complete mark is written last).