Skip to main content

Module file_utils

Module file_utils 

Source

Enums§

FileError

Functions§

cache_dir
Local cache directory for downloaded files, e.g. ~/Library/Caches/commonmeta/{namespace} on macOS, ~/.cache/commonmeta/{namespace} on Linux. Falls back to the system temp dir if no cache dir is available.
decompress_zst_file
Stream-decompress the zstd file at src into dest, creating dest (and its parents) if needed. Returns the number of decompressed bytes.
download_file
Download the content of a URL.
download_file_cached
Like download_file, but checks a local cache first and populates it on a miss. namespace/cache_key locate the cached file under cache_dir; ttl is how long a cached copy stays valid before being treated as a miss and re-downloaded. Returns (bytes, true) on a cache hit, (bytes, false) after a fresh download.
download_file_to_path
Stream-download url directly into a file at path, bypassing an in-memory buffer. Suitable for files that are too large to hold in RAM (e.g. the pidbox dump). Parent directories are created if needed. Returns the number of bytes written.
ensure_cached_path
Like download_file_cached but the cached copy is a file on disk rather than a Vec<u8> in memory, making it suitable for very large downloads. Returns (path, was_cache_hit). The file at path is always valid on Ok; a partial write from a previous interrupted download is replaced.
get_extension
read_file
Read the content of a file into a byte vector.
read_tar_gz_entries
Read each entry of a gzip-compressed tar (.tgz) archive separately, in archive order.
read_zip_entries
Read each entry of a ZIP archive separately (in archive order), as opposed to unzip_content, which concatenates every entry’s bytes together — not useful when entries are independently-encoded blobs (e.g. each a separate zstd-compressed Parquet batch) rather than plain text.
read_zip_file
Opens a ZIP file and extracts the content of a specific file.
read_zst_file
Opens a ZSTD-compressed file and returns its decompressed content.
unzip_content
Extract the content of a ZIP archive into a byte vector. If a filename is provided, only that file is extracted.
unzst_content
Decompress a Zstandard-compressed byte buffer.
write_file
Saves the content to a file.
write_gz_file
Saves the content to a GZIP-compressed file.
write_tar_gz_archive
Saves multiple named entries into a single gzip-compressed tar (.tgz) archive.
write_zip_archive
Saves multiple named entries into a single ZIP archive.
write_zip_file
Saves the content to a ZIP file.
write_zst_file
Saves the content to a Zstandard-compressed file.

Type Aliases§

Result