Skip to main content

FragmentCorpus

Struct FragmentCorpus 

Source
pub struct FragmentCorpus { /* private fields */ }
Expand description

Every fragment file’s text, scanned at most once however many times the packs around it are loaded (ADR-0018).

One proef test loads packs up to four times — the suite, then [run] setup and [run] teardown, each validated and then run — against different feature paths but always the same corpus. Rescanning per load measured ~75% of a run’s total work on a 200-file corpus, and it grows with the corpus, which is the direction adoption goes.

The memo lives here rather than in the caller because the scan must stay lazy: load_collecting runs it only when some pack actually has a ref:, which is what makes CONFIG.md’s “pointing at a corpus you did not write costs nothing” true of the scan. A caller that scanned eagerly in order to share the result would buy speed by breaking that promise. Nothing here reads a file — the texts arrive already read, so core stays sans-IO.

Implementations§

Source§

impl FragmentCorpus

Source

pub fn new(sources: Vec<PackSource>, kinds: &[StepKindSpec]) -> Self

A corpus over already-read file texts.

Source

pub fn with_read_errors(self, errors: Vec<Diag>) -> Self

Record files the caller could not read. They are reported like any other per-file corpus problem — never sinking their siblings, and never at all unless something ref:s the corpus.

Source

pub fn unreadable_file(name: &str, cause: &str) -> Diag

The diagnostic for a corpus file that could not be read at all.

Here rather than at each caller because there are two — the CLI walks the fragment root, the editor reads through its overlay provider — and they had drifted: the CLI’s carried the “the rest of the corpus still loads” help that is the whole point of per-file resilience, and the editor’s did not, so the same unreadable file explained itself in the terminal and went unexplained in the pane beside the code. The reading differs and always will; what it means when reading fails does not.

Source

pub fn empty() -> Self

The empty corpus — no [run] fragments configured, so no ref: can resolve and nothing is ever scanned.

Source

pub fn fragments(&self) -> &BTreeMap<String, Fragment>

Every annotated fragment in the corpus, keyed by name. Scans on first use, like every other reader.

Public because the scan is otherwise gated: load parses the corpus only when some pack actually names a fragment, so PackSet::fragments is empty for a suite that references none — which is exactly the suite a listing has the most to say about.

Source

pub fn unannotated(&self) -> &BTreeMap<String, Vec<usize>>

Per file, the 1-based lines of entries carrying no # @proef annotation — the one class of corpus content nothing else can report, since an unannotated entry has no name to be listed by.

Source

pub fn diagnostics(&self) -> &[Diag]

Whatever was wrong with the corpus: unreadable files first, then scan failures. Already shaped as diagnostics.

Trait Implementations§

Source§

impl Debug for FragmentCorpus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.