Skip to main content

Module policy_content

Module policy_content 

Source
Expand description

What a lifecycle offers content policies, and its candidates once prepared. What: What one lifecycle offers the content policies, and the candidates it prepared for them, read once and shared by every content policy of the invocation. Why: A forwarded command other than git add has no candidates, so its content policies find nothing. git add and the direct commands have candidates, which are prepared the first time a content policy reads them: an invocation whose content policies are all off or escaped starts no Git process for them. A failure to prepare is remembered, so it is reported once and never retried.

In TS you’d write (pseudocode):

// const version = await content.version(lifecycle, facts); for (const c of version.candidates) await content.bytes(c);

Structs§

ContentState
What: The candidates of one invocation once prepared, or the remembered failure. Option<Result<..>> is “not yet asked”, “prepared” or “failed”. Why: Every content policy of the invocation reads the same version through one store.
Correction
What: One proposed full-content correction: the file, the bytes it held when the policy read it, and the bytes it should hold. #[derive(...)] generates cloning, debug printing and ==. Why: A correction replaces a file’s whole content, so applying it needs no patch format; the bytes it replaces are kept so the original of a file is known without reading it again.

Enums§

LifecycleContent
What: What the current lifecycle offers a content policy. An enum is a closed set of named alternatives; Requested carries what to prepare. #[derive(...)] generates cloning, debug printing and ==. Why: “There are no files to check” and “there are files, prepared on demand” must never be confused: the first is clean, the second must be read.

Functions§

candidate_failure
What: The outcome of a content policy whose candidates could not be prepared or read. &CandidateError borrows the failure; its code follows its cause. Why: Every cause but a sequencing defect is unreadable content; the message is the layer’s own, which never contains a candidate’s pathname.