Skip to main content

Corpus

Struct Corpus 

Source
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

Source

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.

Source

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}/.

Source

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")?;
Source

pub fn is_cached(&self, path: &str) -> bool

Check if a path is already cached locally, without downloading.

Source

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-*).

Auto Trait Implementations§

§

impl Freeze for Corpus

§

impl RefUnwindSafe for Corpus

§

impl Send for Corpus

§

impl Sync for Corpus

§

impl Unpin for Corpus

§

impl UnwindSafe for Corpus

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.