pub struct Corpus { /* private fields */ }Expand description
Handle for accessing cached test-image datasets.
Create with Corpus::new() (default cache location) or
Corpus::with_cache_root() (explicit path). Then call Corpus::get()
to obtain the local path to a dataset — downloading it if necessary.
Implementations§
Source§impl Corpus
impl Corpus
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Initialize with default cache location.
Resolves cache root via CODEC_CORPUS_CACHE env var, then
dirs::cache_dir(). Performs no I/O beyond directory creation.
Sourcepub fn with_cache_root(path: impl Into<PathBuf>) -> Result<Self, Error>
pub fn with_cache_root(path: impl Into<PathBuf>) -> Result<Self, Error>
Initialize with explicit cache root. Overrides the environment variable.
Files will live at {path}/codec-corpus/v{major}/.
Sourcepub fn get(&self, path: &str) -> Result<PathBuf, Error>
pub fn get(&self, path: &str) -> Result<PathBuf, Error>
Get the local path to a corpus subdirectory, downloading if needed.
path is any path into the repository (e.g. "webp-conformance",
"webp-conformance/valid", "clic2025/training"). The top-level
folder is the download unit — requesting any path under it fetches
the entire folder recursively.
§Examples
let corpus = codec_corpus::Corpus::new()?;
let webp = corpus.get("webp-conformance")?;
let valid = corpus.get("webp-conformance/valid")?;
let training = corpus.get("clic2025/training")?;Sourcepub fn is_cached(&self, path: &str) -> bool
pub fn is_cached(&self, path: &str) -> bool
Check if a path is already cached locally, without downloading.
Sourcepub fn list_cached(&self) -> Vec<String>
pub fn list_cached(&self) -> Vec<String>
List datasets currently cached on disk.
Returns directory names under the cache root, excluding internal
files (.version, .lock, .tmp-*).